In the following, V1 is a virtual device, A6 is a Switchlinc V2 (controlling deck lights) being tracked by the virtual device, and B2 is another X-10 switch controlling landscape lights.
the first tap turns A6 ON,
the second turns B1 ON and A6 OFF,
the third turns A6 ON, leaving B1 ON,
the fourth turn both OFF, and so on.
The effect is:
tap 1 = deck lights ON, tap 2 = landscape lights ON, Deck lights OFF, tap 3 = both ON, tap 4 = Both OFF
Thanks to Gogs for his help in learning how scripting works, and the basic logic for this approach
Am I asking for trouble using A6 to trigger a script that changes the state of A6?
Is there a better way to accomplish the same end?
Lastly, should I tick the "Wait for the script to finish" box? There seems to be a delay that I can't account for. . .
Sub main()
dim x
x=hs.DeviceValue ("v1")
if x=0 then
hs.execX10 "A6","ON"
hs.SetDeviceValue "v1",1
exit sub
end if
if x=1 then
hs.ExecX10 "A6","OFF"
hs.execX10 "B2","ON"
hs.SetDeviceValue "v1",2
exit sub
end if
if x=2 then
hs.ExecX10 "A6","ON"
hs.SetDeviceValue "v1",3
exit sub
end if
if x=3 then
hs.ExecX10 "A6","OFF"
hs.ExecX10 "B2","OFF"
hs.SetDeviceValue "v1",0
exit sub
end if
end sub
The next script is associated with A6 OFF, which turns OFF A6 and B2, and resets v1's value to 0:
the first tap turns A6 ON,
the second turns B1 ON and A6 OFF,
the third turns A6 ON, leaving B1 ON,
the fourth turn both OFF, and so on.
The effect is:
tap 1 = deck lights ON, tap 2 = landscape lights ON, Deck lights OFF, tap 3 = both ON, tap 4 = Both OFF
Thanks to Gogs for his help in learning how scripting works, and the basic logic for this approach
Am I asking for trouble using A6 to trigger a script that changes the state of A6?
Is there a better way to accomplish the same end?
Lastly, should I tick the "Wait for the script to finish" box? There seems to be a delay that I can't account for. . .
Sub main()
dim x
x=hs.DeviceValue ("v1")
if x=0 then
hs.execX10 "A6","ON"
hs.SetDeviceValue "v1",1
exit sub
end if
if x=1 then
hs.ExecX10 "A6","OFF"
hs.execX10 "B2","ON"
hs.SetDeviceValue "v1",2
exit sub
end if
if x=2 then
hs.ExecX10 "A6","ON"
hs.SetDeviceValue "v1",3
exit sub
end if
if x=3 then
hs.ExecX10 "A6","OFF"
hs.ExecX10 "B2","OFF"
hs.SetDeviceValue "v1",0
exit sub
end if
end sub
Sub main()
dim x
x=hs.DeviceValue ("v1")
dim x
x=hs.DeviceValue ("v1")
hs.SetDeviceValue "v1",0
hs.ExecX10 "A6","OFF"
hs.execX10 "B2","OFF"
end sub
hs.ExecX10 "A6","OFF"
hs.execX10 "B2","OFF"
end sub
Comment