[ANSWERED]: Count how long a device has been on for

Posted on
Mon May 25, 2015 11:35 am
pegoto offline
Posts: 27
Joined: Jul 21, 2011

[ANSWERED]: Count how long a device has been on for

I am trying to think through this but I am failing but I am sure the solution is simple.

How do I count how long a device has been on for?

What I am trying to do is to count how long the Nest has been on for, and if it reached, for example, 100 hours, txt me to replace the air filter.

Posted on
Mon May 25, 2015 12:05 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Count how long a device has been on for

One way, of many I'm sure, would be to have a variable hold the hour count that would be incremented
up every hour using a Schedule with the condition the Nest is running or whatever.

Carl

Posted on
Mon May 25, 2015 1:33 pm
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Count how long a device has been on for

I don't know what communication you get from Nest, but I'd have a variable that stores the Nest_turned_on date/time, then every hour run a script basically saying 'if current time - nest_turned_on time is >100 then send me a text'.

Posted on
Tue May 26, 2015 1:51 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Count how long a device has been on for

As suggested, run a schedule every hour which increments by 1 (hour) a variable.
The schedule shall run only if NEST_ON=TRUE (depending on how you identify that device is ON)

Posted on
Tue May 26, 2015 10:50 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Count how long a device has been on for

Use a timer device. For the first time, when the nest is on, manually start the timer. Create a trigger for when the nest goes off that pauses the timer. Create a trigger for when the nest comes back on that resumes the timer. Finally, create a trigger for when the timer expires that sends your email and restarts the timer.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue May 26, 2015 11:13 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: [ANSWERED]: Count how long a device has been on for

Now why didn't we think of that?

Posted on
Tue May 26, 2015 7:44 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: [ANSWERED]: Count how long a device has been on for

howartp wrote:
Now why didn't we think of that?


Ha...only two solutions? Guys just aren't trying ;-)

Carl

Posted on
Wed Jun 03, 2015 2:43 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: [ANSWERED]: Count how long a device has been on for

You could check the logger database for last change of device. But a trigger on that info would be more difficult.


Sent from my iPhone using Tapatalk

Posted on
Fri Jun 05, 2015 3:51 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: [ANSWERED]: Count how long a device has been on for

we could create a plugin where you could register devices / variables to be tracked for changes.
you then could use that info for trigger.

it would look like:

menue:
add == device : e.g. Nest
add == state: e.g. FAN
<confirm>

After that the state "Nest:FAN" in the plugin DEVICE "SECONDSsinceCHANGE" would show the seconds since last change.


Any interest?

in the background it would read once (at startup) SQLlogger for last change and then subscribe to any device/ variable change message in indigo and update its states accordingly.

Just an idea, don't know where the problems are..

Karl


we would need:

1. config menue setup to enable/disable subscription to tracking changes

2. track devices
indigo.devices.subscribeToChanges() # setup the subscription
def deviceUpdated(self, origDev, newDev): # called whenever a device gets updated
if origDEV ....:

3. track variables..
indigo.variables.subscribeToChanges() ## same for variables
def variableUpdated(self, origVar, newVar):
if origVar .... :

and then some logic to just filter out the ones we are interested in.

Posted on
Fri Jun 05, 2015 7:32 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: [ANSWERED]: Count how long a device has been on for

Matt, Jay

(a) is there an UNsubscribe to "indigo.*.subscribeToChanges()"
(b) if indigo calls e.g. "deviceUpdated" and in the method a device is updated, will "deviceUpdated" be called immediately again or can we UN-sbubscribe while in deviceUpdated?

thx

Karl

Posted on
Fri Jun 05, 2015 2:11 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: [ANSWERED]: Count how long a device has been on for

There is currently no way for a plugin to unsubscribe to changes. Changing the device inside deviceUpdated() should cause another call to deviceUpdated(), but it will occur after the current callback has exited (it will not be recursive).

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest