Announcement
Collapse
No announcement yet.
Flash Lamps with restore
Collapse
X
-
You need to use devicestatus not devicevalue. This should get you going but assumes you do not use dimming:
PHP Code:Sub Main()
dim v
v=hs.Devicestatus ("A2")
hs.writelog "initial state of lamps", v
hs.execx10 "A2","on"
hs.execx10 "A2","off"
hs.execx10 "A2","on"
hs.execx10 "A2","off"
hs.execx10 "A2","on"
If v=2 then
hs.ExecX10 "A2", "on"
hs.writelog "final set lamps to on"
else
hs.ExecX10 "A2", "off"
hs.writelog "final set lamps to off"
end if
End Sub
-
To show code in the blue box, highlight the text you want and then press the php button: . You will see it when you reply.
Try the following:
PHP Code:Sub Main()
dim v,x
v=hs.Devicestatus ("A2")
x=hs.devicevalue ("A2")
hs.execx10 "A2","off"
hs.execx10 "A2","on"
hs.execx10 "A2","off"
hs.execx10 "A2","on"
hs.execx10 "A2","off"
If v=2 then
hs.ExecX10 "A2", "on"
hs.writelog "final set lamps to on"
elseif V=3 then
hs.ExecX10 "A2", "off"
hs.writelog "final set lamps to off"
elseif V=4 then
hs.ExecX10 "D3", "DDim", x
hs.writelog "final set lamps to dim value " & x
else
hs.writelog "lamp status is unknown"
end if
End Sub
Please note that X10 is very bad for flashing lights due to it's transmission method.
Comment
-
I've made a few tweeks, mainly arround log entries so i can see what's going on. And changed lamp moduelto teh office desk light so I don't have to go downstairs to see results! However the final dimmed state doesn't get set even though according to the log the value is correct
PHP Code:Sub Main()
dim v,x
v=hs.Devicestatus ("A16")
x=hs.devicevalue ("A16")
hs.writelog "initial state of lamps", v
hs.writelog "initial dim value of lamps", x
hs.execx10 "A16","off"
hs.execx10 "A16","on"
hs.execx10 "A16","off"
hs.execx10 "A16","on"
hs.execx10 "A16","off"
If v=2 then
hs.ExecX10 "A16", "on"
hs.writelog "final set lamps to on", v
elseif v=3 then
hs.ExecX10 "A16", "off"
hs.writelog "final set lamps to off", v
elseif v=4 then
hs.ExecX10 "A16", "DDim", x, 0
hs.writelog "final set lamps to dim value " , x
else
hs.writelog "lamp status is unknown"
end if
End Sub
PHP Code:20/06/2010 11:17:33 final set lamps to dim value 30
20/06/2010 11:17:33 X-10 Command sent to Office Desk Light: A16 DDim Dimval: 30 Data: 0
20/06/2010 11:17:33 X-10 Command sent to Office Desk Light: A16 off Dimval: 0 Data: 0
20/06/2010 11:17:33 X-10 Command sent to Office Desk Light: A16 on Dimval: 0 Data: 0
20/06/2010 11:17:33 X-10 Command sent to Office Desk Light: A16 off Dimval: 0 Data: 0
20/06/2010 11:17:33 X-10 Command sent to Office Desk Light: A16 on Dimval: 0 Data: 0
20/06/2010 11:17:33 X-10 Command sent to Office Desk Light: A16 off Dimval: 0 Data: 0
20/06/2010 11:17:33 initial dim value of lamps 30
20/06/2010 11:17:33 initial state of lamps 4
20/06/2010 11:17:33 Event Running script in background: Flash Lights with restore
20/06/2010 11:17:16 Device Control Device: Office Desk Light (A16) Dim by 70%
Comment
-
It may be due to the sheer number of X10 signals being sent. I've added a delay between X10 commands.
Try this:
PHP Code:Sub Main()
dim v,x
v=hs.Devicestatus ("A16")
x=hs.devicevalue ("A16")
hs.writelog "initial state of lamps", v
hs.writelog "initial dim value of lamps", x
hs.execx10 "A16","off"
hs.waitsecs 2
hs.execx10 "A16","on"
hs.waitsecs 2
hs.execx10 "A16","off"
hs.waitsecs 2
hs.execx10 "A16","on"
hs.waitsecs 2
hs.execx10 "A16","off"
hs.waitsecs 2
If v=2 then
hs.ExecX10 "A16", "on"
hs.writelog "final set lamps to on", v
elseif v=3 then
hs.ExecX10 "A16", "off"
hs.writelog "final set lamps to off", v
elseif v=4 then
hs.ExecX10 "A16", "DDim", x, 0
hs.writelog "final set lamps to dim value " , x
else
hs.writelog "lamp status is unknown"
end if
End sub
Comment
Comment