Page 1 of 1

Python-iodevice - not responding to command

PostPosted: Thu Apr 08, 2021 6:45 pm
by SMUSEBY
In the following script, the IODevice is not responding to either iodevice command. There is no error code. I've confirmed the device ID. I am able to change the value manually. I think I've eliminated all possibilities with the exception of the python code.
Suggestions?

Code: Select all
hseStatus = indigo.variables[1568794432].value
import time

if hseStatus == "Vacant":
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
    indigo.variable.updateValue(1568794432, value = str("Occupied")) # setHse Occupied
else:
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
    indigo.variable.updateValue(1568794432, value = str("Vacant")) # setHse Vacant

Re: Python-iodevice - not responding to command

PostPosted: Fri Apr 09, 2021 1:49 pm
by SMUSEBY
I created the following test script, and the second iodevice line (bold) produces the following error message:

Trigger run a script #1
Script Error test.py: output binary index out-of-range
Script Error Exception Traceback (most recent call shown last):

test.py, line 10, at top level
InvalidParameter: output binary index out-of-range


With 12 possible iodevice options, this suggests that format of the iodevice line is wrong.

Code: Select all
hseStatus = indigo.variables[1568794432].value
import time

if hseStatus == "Vacant":
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
else:
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   indigo.iodevice.setBinaryOutput(33341465, 1, True) # this line fails
   indigo.iodevice.setBinaryOutput(33341465, 2, 0)
   indigo.iodevice.setBinaryOutput(33341465, 3, 1)
   indigo.iodevice.setBinaryOutput(33341465, 4, false)
   indigo.iodevice.setBinaryOutput(33341465, 5, true)
   indigo.iodevice.setBinaryOutput(33341465, 6, True)
   indigo.iodevice.setBinaryOutput(33341465, 7, False)


[MODERATOR NOTE]: you can't use formatting inside code tags, so I removed them and added a comment

Re: Python-iodevice - not responding to command

PostPosted: Fri Apr 09, 2021 2:32 pm
by jay (support)
"True" and "False" (without quotes) are the correct value.

The error seems to indicate that the IODevice only has one binary output...

Re: Python-iodevice - not responding to command

PostPosted: Fri Apr 09, 2021 3:03 pm
by SMUSEBY
The test script is not relevant. The original script still fails, but I just discovered that sometimes it works.
My 'solution' below is not very elegant. Is there a way I can get the status of the output, and then make a loop?
Workaround 'solution':
Code: Select all
hseStatus = indigo.variables[1568794432].value
import time

if hseStatus == "Vacant":
    indigo.variable.updateValue(1568794432, value = str("Occupied")) # setHse Occupied
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, True)
else:
    indigo.variable.updateValue(1568794432, value = str("Vacant")) # setHse Vacant
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)
   time.sleep(1)
   indigo.iodevice.setBinaryOutput(33341465, 0, False)

Re: Python-iodevice - not responding to command

PostPosted: Fri Apr 09, 2021 3:43 pm
by jay (support)
Are you getting any errors in the Event Log window when the command to set the output fails? What kind of device is that? When the command to set the output fails, how do you know it fails? Does its state in Indigo not change?

Re: Python-iodevice - not responding to command

PostPosted: Fri Apr 09, 2021 3:59 pm
by SMUSEBY
The device is the Insteon iodevice - I/O linc controller. Selecting the device with Indigo reveals a section labeled Output Controls which has 12 squares, numbered 1-12. The squares become light/dark indicating their T/F status. - I apologize as I thought my mentioning "iodevice" at the top of this post was specific to this item.
To answer your questions,
- There is no mention of a failure to respond in the event log.
- I know the command fails because observing the device in Indigo, the square labeled "1" does not change to Light or Dark
- Its state in Indigo is not changing.
Now that I know the failure is intermittent, repeated send of the change command, sooner or later should change the device, although my 12 repetitions may not be sufficient. An if/then loop would be better.