Python script using datetime module

Posted on
Fri Oct 20, 2017 12:34 pm
mpleeds offline
Posts: 13
Joined: Jul 02, 2012

Python script using datetime module

I have connected an Aeotec Smart Switch 6 to a newer high efficiency washing machine with the goal of sending a text message when the wash cycle is complete. The idea was to have a variable changed to false when the switch reports o watts, which would trigger a text message reporting end of cycle. After monitoring it's energy consumption in real time during a typical cycle, I learned that this particular washer (Whirlpool HE top loader) periodically turns completely off (0.000 watts) for up to 3 seconds during various stages of the cycle.

I was unable to find any posts in the forums with information on how to create a trigger based on a variable remaining unchanged for a specified period of time (5 or more seconds). It appears that this can't be done using Indigo's native interface. Although I have virtually no coding expertise, it would seem reasonable to assume that this can be accomplished by running a python script using the datetime module:

1. Create an Indigo boolean variable for washer on (>0.000 watts) or off (=0.000 watts).
1. Create and Indigo (OFF) timestamp variable which would be updated each time that watts = 0.000 (false) after initial start of cycle.
2. Create 2nd Indigo (ON) timestamp variable which would be updated when watts > 0.000 (true).
3. Run python script each time ON timestamp is updated--
if difference between OFF and ON timestamp > 5 seconds, text message (messages app) is sent indicating end of cycle.

Any thoughts on how to build this script or if there may be a more straight forward way to achieve the Same results?

Posted on
Fri Oct 20, 2017 1:41 pm
FlyingDiver offline
Posts: 1805
Joined: Jun 07, 2014
Location: Cape Coral, FL

Re: Python script using datetime module

That seems more trouble than it's worth. Look at using the Timers and Pesters plugin. Have the action when the current goes to zero start a timer. If the current goes non-zero, cancel the timer. When the timer expires, send the text message.

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

Posted on
Fri Oct 20, 2017 2:28 pm
jay (support) offline
Site Admin
User avatar
Posts: 13359
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python script using datetime module

+1 on FlyingDiver's suggestion - it's exactly what I used to do.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Oct 21, 2017 6:06 am
howartp offline
Posts: 2902
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Python script using datetime module

Also the Timed Devices plugin has various options if you want to tweak further.


Sent from my iPhone using Tapatalk Pro

Posted on
Sat Oct 21, 2017 3:19 pm
mpleeds offline
Posts: 13
Joined: Jul 02, 2012

Re: Python script using datetime module

Thanks for the suggestions. Creating the washer cycle completion alert was straightforward using the Timers and Pesters plug in.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest