EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Posted on
Tue Jun 18, 2019 10:56 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

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.)

Posted on
Tue Jun 18, 2019 1:02 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

You REALLY REALLY don't want to do them all. Insteon networks are very susceptible to lots of traffic (collisions), so doing status requests to every device is generally going to wreak havoc while it's happening.

I'd look for opportunities to minimize Insteon traffic as much as possible, not increase them. If you've got a network reliability issue, then it's usually better to attempt to address the issue itself rather than the symptom (devices becoming out of sync).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jun 18, 2019 4:37 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Note that this line in your script:

Code: Select all
binaryOutput8 = ezio8t.states["binaryOutput8"]

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. But there is a command you can call to get it refreshed/updated. What you probably want to do instead is something like:

Code: Select all
indigo.device.statusRequest(ezio8t)
time.sleep(1)
ezio8t.refreshFromServer(waitUntilServerIdle=True)
binaryOutput8 = ezio8t.states["binaryOutput8"]

Image

Posted on
Wed Jun 19, 2019 8:33 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

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.


Good catch - I totally missed that... :oops:

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 19, 2019 9:26 am
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Ah, excellent. Exactly what I was after. I was concerned that I was only reading what Indigo "assumed" about the state, and not the actual state...

Posted on
Tue Dec 03, 2019 2:29 pm
mgolden50 offline
User avatar
Posts: 259
Joined: Jan 29, 2007
Location: Chandler, AZ

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Hi,
After converting over 200 AppleScripts to Python, I'm stumped on this one. I can't find on any of the forums the Python command to accomplish the first line of the AppleScript below. I need to set 4 different outputs on my EZIO40 and io4T devices. I wrote this script to overcome the terrible reliability of these devices in receiving Insteon commands. The code has worked perfectly for over two years. Now I just need to get it two work perfectly in Python. Almost complete with all conversions... Phew!

Code: Select all
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

Posted on
Tue Dec 03, 2019 2:45 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

https://wiki.indigodomo.com/doku.php?id ... ce_class&s[]=iodevice#set_binary_output

Code: Select all
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)

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Dec 03, 2019 3:28 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Having similar issues with my EZIO8T, I explored this issue with Matt's and Jay's help and I came up with the following. Instead of doing what you're doing for 10 times (which is how I similarly used to handle this problem), I now run a loop instead, which turns off all the outputs and then tests each one to see if they're really off. The loop continues until they really are off. The key is the line "ezio8t.refreshFromServer(waitUntilServerIdle=True)", which forces Indigo to go and get the actual outputs' states, instead of just reading the last-set states from the server's memory.

Then I do a similar loop that turns one output on, and tests for its actual state and repeats that until the output is really on.

I should modify the loops a bit, so that they expire after so many tries, in case something is really wrong with the device and it's never going to turn an output off/on as needed. I think I just have to replace the line "while True:" with Python's version of AppleScript's "repeat 30 times". Matt? Jay? How would that look? Would the "break" still exit the repeat loop as it's doing now, even if the loop was supposed to run for X-number of times?

Anywho... this way, if the off and on commands are received, executed and confirmed the first time through, or the second, whatever, the script moves on instead of pounding on the device (and the server and the traffic) eight or nine more times when it's not necessary. Which also speeds up the whole script when the EZIO8T is in a good mood.

So far this is working, though because I have six outputs to check (for off), and a seventh (for on), that sometimes takes more than Indigo's ten second script execution limit. I'll likely have to solve for that in some way, maybe moving the script to an external file (to eliminate the 10 second limit), or splitting the script into parts (to shorten the execution time).

Code: Select all
# 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

Posted on
Tue Dec 03, 2019 3:37 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Matt, I just noticed, your example is:
Code: Select all
indigo.iodevice.setBinaryOutput(123, index=0, value=False)
but I've been using
Code: Select all
indigo.iodevice.setBinaryOutput(134979129, 0, False)
which I think you showed me. Are those functionally the same, or should I fix my code to include the parameter names?

Posted on
Tue Dec 03, 2019 3:38 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Mark wrote:
Are those functionally the same, or should I fix my code to include the parameter names?


They're the same unless you're skipping parameters (to use the default value). Standard Python.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Dec 03, 2019 3:41 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Thanks Joe!

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...

Posted on
Tue Dec 03, 2019 3:45 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

I suppose I could to this, instead of using "break".:


Code: Select all
   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"]


Ugh, that doesn't look right either... I'm supposed to be working right now, better set this one aside for now...
Last edited by Mark on Tue Dec 03, 2019 3:47 pm, edited 1 time in total.

Posted on
Tue Dec 03, 2019 3:46 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

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...


Yes, a break will always exit the innermost loop. Could be while, for, or do. The continue statement will go back to the top of the loop.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Tue Dec 03, 2019 3:50 pm
Mark offline
User avatar
Posts: 262
Joined: Apr 21, 2005
Location: California

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Like a dog with a bone... maybe this?

Code: Select all
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"]

Posted on
Tue Dec 03, 2019 3:52 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: EZIO8SA, EZIO2X4, EZIO8T support in Indigo

Did you leave part of that out? You don't have a break anywhere.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Who is online

Users browsing this forum: No registered users and 6 guests