Well, that was easy. Thanks Jay!
Is there an Indigo command that forces Indigo to request status from every device? Or do I need to use Python and loop through each device one at a time? (Which is how I did it previously with AppleScript.)
binaryOutput8 = ezio8t.states["binaryOutput8"]
indigo.device.statusRequest(ezio8t)
time.sleep(1)
ezio8t.refreshFromServer(waitUntilServerIdle=True)
binaryOutput8 = ezio8t.states["binaryOutput8"]
matt (support) wrote:will always return the same result within the while loop because ezio8t is a copy/snapshot of the device at the time it is assigned.
set binary outputs of device "Bedroom Curtain Controller" to {0, 0, 1, 0}
delay 0.3
repeat 10 times
execute group "Put Curtain Control States Into Variable"
set BedroomCurtainControlStates to value of variable "BedroomCurtainControlStates"
if BedroomCurtainControlStates = "0,0,0,0" then exit repeat
delay 0.3
end repeat
set binary outputs of device "Bedroom Curtain Controller" to {0, 1, 0, 0}
delay 0.3
repeat 10 times
execute group "Put Curtain Control States Into Variable"
set BedroomCurtainControlStates to value of variable "BedroomCurtainControlStates"
if BedroomCurtainControlStates = "0,0,0,0" then exit repeat
delay 0.3
end repeat
indigo.iodevice.setBinaryOutput(123, index=0, value=False)
indigo.iodevice.setBinaryOutput(123, index=1, value=False)
indigo.iodevice.setBinaryOutput(123, index=2, value=True)
indigo.iodevice.setBinaryOutput(123, index=3, value=False)
# turns off EZi08T outputs 1–6 and repeats until they are all off, then turns on irrigation valve 1 and repeats until it is really on
import time
ezio8t = indigo.devices[134979129] # "EZi08T"
tTimerDuration = unicode(indigo.variables[128363799].value) # "irrigation_duration_1" value as unicode
# turn off all valves and repeat until they are really off
while True:
indigo.iodevice.setBinaryOutput(134979129, 0, False) # "EZi08T" output 1 OFF
indigo.iodevice.setBinaryOutput(134979129, 1, False) # "EZi08T" output 2 OFF
indigo.iodevice.setBinaryOutput(134979129, 2, False) # "EZi08T" output 3 OFF
indigo.iodevice.setBinaryOutput(134979129, 3, False) # "EZi08T" output 4 OFF
indigo.iodevice.setBinaryOutput(134979129, 4, False) # "EZi08T" output 5 OFF
indigo.iodevice.setBinaryOutput(134979129, 5, False) # "EZi08T" output 6 OFF
indigo.device.statusRequest(134979129) # "EZi08T"
time.sleep(1)
ezio8t.refreshFromServer(waitUntilServerIdle=True)
binaryOutput1 = ezio8t.states["binaryOutput1"]
binaryOutput2 = ezio8t.states["binaryOutput2"]
binaryOutput3 = ezio8t.states["binaryOutput3"]
binaryOutput4 = ezio8t.states["binaryOutput4"]
binaryOutput5 = ezio8t.states["binaryOutput5"]
binaryOutput6 = ezio8t.states["binaryOutput6"]
if (not binaryOutput1) and (not binaryOutput2) and (not binaryOutput3) and (not binaryOutput4) and (not binaryOutput5) and (not binaryOutput6):
break
# turn on valve 1 and repeat until it is really on
while True:
indigo.iodevice.setBinaryOutput(134979129, 0, True) # "EZi08T" output 1 ON
indigo.device.statusRequest(134979129) # "EZi08T"
time.sleep(1)
ezio8t.refreshFromServer(waitUntilServerIdle=True)
binaryOutput1 = ezio8t.states["binaryOutput1"]
if binaryOutput1:
indigo.variable.updateValue(126668483, value=tTimerDuration) # "irrigation_timer"
break
indigo.iodevice.setBinaryOutput(123, index=0, value=False)
indigo.iodevice.setBinaryOutput(134979129, 0, False)
Mark wrote:Are those functionally the same, or should I fix my code to include the parameter names?
binaryOutput1 = True
binaryOutput2 = True
binaryOutput3 = True
binaryOutput4 = True
binaryOutput5 = True
binaryOutput6 = True
while (not binaryOutput1) and (not binaryOutput2) and (not binaryOutput3) and (not binaryOutput4) and (not binaryOutput5) and (not binaryOutput6)::
indigo.iodevice.setBinaryOutput(134979129, 0, False) # "EZi08T" output 1 OFF
indigo.iodevice.setBinaryOutput(134979129, 1, False) # "EZi08T" output 2 OFF
indigo.iodevice.setBinaryOutput(134979129, 2, False) # "EZi08T" output 3 OFF
indigo.iodevice.setBinaryOutput(134979129, 3, False) # "EZi08T" output 4 OFF
indigo.iodevice.setBinaryOutput(134979129, 4, False) # "EZi08T" output 5 OFF
indigo.iodevice.setBinaryOutput(134979129, 5, False) # "EZi08T" output 6 OFF
indigo.device.statusRequest(134979129) # "EZi08T"
time.sleep(1)
ezio8t.refreshFromServer(waitUntilServerIdle=True)
binaryOutput1 = ezio8t.states["binaryOutput1"]
binaryOutput2 = ezio8t.states["binaryOutput2"]
binaryOutput3 = ezio8t.states["binaryOutput3"]
binaryOutput4 = ezio8t.states["binaryOutput4"]
binaryOutput5 = ezio8t.states["binaryOutput5"]
binaryOutput6 = ezio8t.states["binaryOutput6"]
Mark wrote:Want to weigh in on the question in bold in my answer to mgolden50? Do you know how to get a Python loop to repeat for x number of times, but still exit when a condition is met? The way I have them now, they repeat forever until a condition is met, which is not particularly good practice...
binaryOutput1 = True
binaryOutput2 = True
binaryOutput3 = True
binaryOutput4 = True
binaryOutput5 = True
binaryOutput6 = True
while binaryOutput1 or binaryOutput2 or binaryOutput3 or binaryOutput4 or binaryOutput5 or binaryOutput6:
indigo.iodevice.setBinaryOutput(134979129, 0, False) # "EZi08T" output 1 OFF
indigo.iodevice.setBinaryOutput(134979129, 1, False) # "EZi08T" output 2 OFF
indigo.iodevice.setBinaryOutput(134979129, 2, False) # "EZi08T" output 3 OFF
indigo.iodevice.setBinaryOutput(134979129, 3, False) # "EZi08T" output 4 OFF
indigo.iodevice.setBinaryOutput(134979129, 4, False) # "EZi08T" output 5 OFF
indigo.iodevice.setBinaryOutput(134979129, 5, False) # "EZi08T" output 6 OFF
indigo.device.statusRequest(134979129) # "EZi08T"
time.sleep(1)
ezio8t.refreshFromServer(waitUntilServerIdle=True)
binaryOutput1 = ezio8t.states["binaryOutput1"]
binaryOutput2 = ezio8t.states["binaryOutput2"]
binaryOutput3 = ezio8t.states["binaryOutput3"]
binaryOutput4 = ezio8t.states["binaryOutput4"]
binaryOutput5 = ezio8t.states["binaryOutput5"]
binaryOutput6 = ezio8t.states["binaryOutput6"]
Users browsing this forum: No registered users and 7 guests