Can you use the "Last Echo" device as a condition in a event that uses a "has been off at least" option? What I want to accomplish is when there is no Echo for at least 30 min. Fire event. Can I use this device for that?
Announcement
Collapse
No announcement yet.
Last Echo question
Collapse
X
-
Try something like this (not tested)
This uses M1 as the sensor and triggers an event called Test1
Run this from a recurring event
This is a vb.net script
Code:Sub Main(ByVal parms As Object) Dim mySensor As Object = Nothing mySensor = hs.Plugin("BLRadar").GetSensorByDeviceCode("M1") If Not mySensor Is Nothing Then Dim diffMinutes As Long = DateDiff(DateInterval.Minute, mySensor.LastOn, DateTime.Now) If diffMinutes >= 30 Then hs.TriggerEvent("Test1") End If diffMinutes = Nothing End If mySensor = Nothing End Sub
Comment
-
You could even do something like this so you could reuse the same script for multiple sensors
You would need to call this from your recurring event and pass the parameter info for the sensor
Parameter info should be passed like this:
sensorDeviceCode|minutes|eventName|occupancyDeviceCode
Example:
M1|30|Test1|M99
Code:Sub Main(ByVal info As String) Dim splitArray As String() = info.Trim.Split("|") If splitArray.Length = 4 Then Dim mySensor As Object = Nothing mySensor = hs.Plugin("BLRadar").GetSensorByDeviceCode(splitArray(0)) If Not mySensor Is Nothing Then Dim diffMinutes As Long = DateDiff(DateInterval.Minute, mySensor.LastOn, DateTime.Now) If diffMinutes >= Integer.Parse(splitArray(1)) Then If hs.IsOn(splitArray(3)) Then hs.TriggerEvent(splitArray(2)) End If End If diffMinutes = Nothing End If mySensor = Nothing End If splitArray = Nothing End Sub
Last edited by Blade; June 5, 2012, 03:41 PM.
Comment
-
Hi Bob,
I'm also interested in this script. What I would like to accomplish is the following:
Check the last echo, if the last echo was more then 10 minutes then set the status on "vacancy" .
These are my screen shoots of what I have done so far. Your script is a vb script.
This is what I get so far
6/2/2012 2:03:15 PM Error 3 Running script BLRadarLastEcho.vb :method not found6/2/2012 2:03:15 PM Event Running script in background: BLRadarLastEcho.vb("main", "#1|2|Test1")
Please see attached print screens.
Comment
-
Thanks Bob, almost, right now I'm getting this message, I changed few codes with the same results.
6/3/2012 10:46:22 AM BLRadar Error GetSensorByDeviceCode(): Device Code (A6) was NOT found in the Sensor Collection!6/3/2012 10:46:22 AM Event Running script in background: BLRadarLastEcho.vb("Main", "A6|2|Test1")
Comment
-
Bob, you are correct, I assumed that I could use the other devices from BLRadar as the last echo sensor. I can still work around this issue by creating other virtual sensors.
Thank you very much,
Aldo
P.S. in the future if you could, would it be possible to create a trigger using the same concept?
Comment
-
Originally posted by aldo View PostHi Bob,
I created an active zone that includes all the occupancy sensors, I would like to use it to trigger your script so when there is no occupancy it will set the the device vacancy, it seems like it is not working, it always trigger the event, any suggestions?Hector
____________________________________
Win.2003 OS, HS3
BLDSC,BLstat,BLRadar,BLRamdom,BLOccupied
BLups,BLrain8,HSTouch,Ultrajones Weatherbug,
MyTrigger,ACRF2,W800,Zwave
AP800,Honeywell Stat
Comment
Comment