Announcement
Collapse
No announcement yet.
Event question
Collapse
X
-
Try this:
Assuming the motion sensor is "M1" and the light is "L1"
This script would be triggered by M1 Off. Save it as a .VB script.
It's off the top of my head, but should do what you want.
Sub Main(Parm as Object)
Dim PrevBright as Integer = hs.DeviceValue("L1") ' Remember the level
hs.ExecX10("L1","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level
hs.WaitSecs(30)
If hs.IsOn("M1") Then
hs.ExecX10("L1","DDim",PrevBright) ' restore the level if motion is now on
Else
hs.ExecX10("L1","Off") ' otherwise turn off the light.
End If
End SubReal courage is not securing your Wi-Fi network.
-
Originally posted by Wadenut View PostTry this:
Assuming the motion sensor is "M1" and the light is "L1"
This script would be triggered by M1 Off. Save it as a .VB script.
It's off the top of my head, but should do what you want.
Sub Main(Parm as Object)
Dim PrevBright as Integer = hs.DeviceValue("L1") ' Remember the level
hs.ExecX10("L1","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level
hs.WaitSecs(30)
If hs.IsOn("M1") Then
hs.ExecX10("L1","DDim",PrevBright) ' restore the level if motion is now on
Else
hs.ExecX10("L1","Off") ' otherwise turn off the light.
End If
End Sub
Sorry to barf this up, but it seems like exactly (mostly! ) what I need to solve a problem. I can copy and substitute, but I think I'd need something slightly different here.
Since I'm by no means a scripting genius, if I already have motion events running to turn on the lights, what do I put to exit / quit the script if the motion is now on (the bolded line)? I.E., in our baby room, the lights will turn on by motion. If say, I'm not rocking the rocking chair far enough back, it thinks no one is in the room. The lights in this case would dim, so I'd rock back that extra few inches that allows the motion sensor to see I'm there, which would kick off the existing motion event to set the lights on to my desired level again. The same kind of feature would be useful when taking a shower, too, since you could be in there moving around but the motion sensor won't know...and WAF goes negative if the lights go off while in the shower.
If there's some hole in my logic, please feel free to point it out, too. More I'm finding automation is nice when you have it well thought out, and I haven't always done that.
Comment
-
You could try this. If the motion sensor is still off after 30 seconds, it turn off the light.
Code:Sub Main(Parm as Object) Dim PrevBright as Integer = hs.DeviceValue("L1") ' Remember the level hs.ExecX10("L1","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level hs.WaitSecs(30) If hs.IsOff("M1") Then hs.ExecX10("L1","Off") ' turn off the light. End If End Sub
Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
-
I'm getting this error:
1/6/2013 11:03:58 AM - Error - Running script, script run or compile error in file: msoff2GBR.txt1006:Expected ')' in line 1 More info: Expected ')'
Code:Sub Main(Parm as Object) Dim PrevBright as Integer = hs.DeviceValue("q26") ' Remember the level hs.transmit("q26","DDim",Int(PrevBright * .5)) ' dims to 50% of the previous level hs.WaitSecs(60) If hs.IsOff("d7") Then hs.transmit("q26","Off") ' turn off the light. End If End Sub
Comment
Comment