Variable check after scheduled event with delay

Posted on
Fri Dec 22, 2023 4:34 pm
BenjiBob offline
Posts: 1
Joined: Mar 23, 2022

Variable check after scheduled event with delay

Hello All,

I need some advice. Can anyone point me in the right direction? I would like to fire a scheduled event (turn on relay), have a delay for 5 seconds, then check a variable and depending on the result of the variable either turn the relay off or leave it on. Any suggestions how to do this?

Essentially......at a given time of day a relay will turn on a piece of equipment, if the equipment closes a relay in 5 seconds the relay will remain on otherwise the relay will open thus turning off the equipment.

Thanks

Posted on
Tue Dec 26, 2023 2:44 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: Variable check after scheduled event with delay

I think this should be easy to do. I assume the relay you want to have Indigo turn on is controllable by Indigo, yes?

And I assume the relay you want to check to see if it is on, can also update a variable in Indigo, yes?

If so, just create a new schedule to turn on your 1st relay as needed. Then in the same Schedule, create a 2nd Action with a delay of :05. For your 2nd Action, use this:Server Actions->Script and File Actions->Execute Script, and check "embedded Python:"

This script should get you close. Not sure I have the logic set up correctly for you needs, but this should be easy to change if necessary.

Code: Select all
relay = indigo.variables[1290294647] #variable ID of relay device ID to check
if relay.value == "false":
      indigo.device.turnOff(629297029) schedule relay deivice ID


So if the variable for your 2nd device is False(off), this will turn your first relay off. If the 2nd relay is True(on), nothing will happen. Again, not sure I have this logic set up as you need but should be trivial to change if necessary. AND, I am NOT a python expert , and no doubt there maybe better, easier ways to do this, but nevertheless this little script should work:

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 13 guests