Page 1 of 1

Python script using datetime module

PostPosted: Fri Oct 20, 2017 12:34 pm
by mpleeds
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?

Re: Python script using datetime module

PostPosted: Fri Oct 20, 2017 1:41 pm
by FlyingDiver
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.

Re: Python script using datetime module

PostPosted: Fri Oct 20, 2017 2:28 pm
by jay (support)
+1 on FlyingDiver's suggestion - it's exactly what I used to do.

Re: Python script using datetime module

PostPosted: Sat Oct 21, 2017 6:06 am
by howartp
Also the Timed Devices plugin has various options if you want to tweak further.


Sent from my iPhone using Tapatalk Pro

Re: Python script using datetime module

PostPosted: Sat Oct 21, 2017 3:19 pm
by mpleeds
Thanks for the suggestions. Creating the washer cycle completion alert was straightforward using the Timers and Pesters plug in.