Best way to verify (fail safe) a scheduled device OFF

Posted on
Fri Jan 03, 2020 8:11 am
Espressomatic offline
Posts: 73
Joined: Dec 30, 2018

Best way to verify (fail safe) a scheduled device OFF

So I have both a schedule and a trigger that can turn a particular outlet off. It's a Z-wave outlet powering a coffee machine, but this question isn't specific to the interface or device.

The schedule turns the outlet ON at 7AM and OFF at 9AM

The trigger turns the outlet OFF when power usage hits within a specific range.

Both work well nearly 100% of the time, but I've found a that every now and then, for whatever reason, the outlet remains ON. Yesterday the trigger was missed, which is OK. The scheduled OFF command was sent when it was supposed to be at 9AM, but the outlet didn't turn off - no errors in the log.

So I'm looking for a good way to account for such a failure and turn that outlet OFF, with the least amount of wheel spinning and impact on the server process.

Quick and dirty would probably be to set a variable in the above schedule and trigger, then check every hour to compare the variable to the state of the outlet, then send a new OFF command if the device was still ON when it wasn't supposed to be.

Thanks for any ideas in advance, I'm sure this has come up but my searching directly in the forum and through google hasn't turned up the right threads.

Posted on
Fri Jan 03, 2020 8:42 am
FlyingDiver offline
User avatar
Posts: 7210
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Best way to verify (fail safe) a scheduled device OFF

Add another off command with a delay of 1 minute or so. Or multiple ones.

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

Posted on
Tue Jan 07, 2020 7:18 am
Espressomatic offline
Posts: 73
Joined: Dec 30, 2018

Re: Best way to verify (fail safe) a scheduled device OFF

FlyingDiver wrote:
Add another off command with a delay of 1 minute or so. Or multiple ones.


That's definitely simple and straight forward, but doesn't guarantee that Indigo will keep trying until the outlet is actually OFF. :lol:

But in any case, I suppose thethe easiest way to do this would be to make two new off actions? First one a scheduled item to fire 1 minute after the initial ON period schedule and the second a duplicate of the power usage trigger +1 minute for the OFF?

Posted on
Tue Jan 07, 2020 11:19 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Best way to verify (fail safe) a scheduled device OFF

If you want it to repeat until it's off, there are a variety of ways of doing that. If I wasn't going to attempt to solve the actual problem (why it isn't turning off correctly), then I'd probably just write an external Python script action (so it'll run as long as needed). The script would be something like this:

Code: Select all
import time

# Loop until an explicit break
while True:
    # Get a fresh copy of the device from the server in case
    # it's on state changes during the script execution
    d = indigo.devices[IDOF_DEVICE]
    # If it's not on
    if not d.onState:
        # Turn it off and sleep for a minute (60 seconds) and repeat
        indigo.device.turnOff(d)
        time.sleep(60)
    else:
        # Since it's now off, leave the loop and exit the script
        break


Note that there are other non scripting ways (timers, enabling/disabling other schedules, etc) but I like the script approach above because it's fewer moving pieces.

However, what I would actually do is in conjunction with your off action, start a one minute timer. Then create a trigger such that when that timer goes off, it sends you a notification (something that will definitely get your attention) IF the device is still on (you can put that in a condition on the trigger). Then you can check the logs to see what actually happened and manually turn it off (via Indigo Touch, the Mac App, whatever). This would hopefully lead you to why it's failing to turn off so that you can solve the actual problem. But that's just me... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jan 12, 2020 3:27 pm
Espressomatic offline
Posts: 73
Joined: Dec 30, 2018

Re: Best way to verify (fail safe) a scheduled device OFF

Thanks for the suggestions Jay. I did plan to investigate, but it's been so infrequent and I've been so (otherwise) busy. :) I combed the logs to no avail for the period where it last happened.

The tip about setting the notification is great as well, because the last time it happened, I only found out the next day after the new schedule (for that day) kicked ON - and only because my machine will go into sleep mode after some hours ON, whereas it's always hot and ready to go after my morning schedule.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest