Variable - Last Change

Posted on
Mon Oct 29, 2018 4:18 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Variable - Last Change

Hi all,

This is a variable and/or python question. How do I get the last changed time of a variable? Here is a simple example of what I'm trying to do for a few different scenarios, so once I figure this one I should be good for other use cases. This works for a device obviously but what is the variable equivalent for below?
Code: Select all
motion = indigo.devices[1987458174]
timeDelta = datetime.now() - motion.lastChanged
if light.onState and timeDelta.seconds > 60:
        indigo.device.turnOff(1606772561)

Posted on
Mon Oct 29, 2018 5:44 am
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Variable - Last Change

Colly wrote:
How do I get the last changed time of a variable?

To the best of my knowledge, Indigo doesn't track this. For each variable, Indigo tracks:

Code: Select all
folderId : 1863978771
globalProps : MetaProps : (dict)
id : 1961258112
name : Foo01
pluginProps : emptyDict : (dict)
readOnly : False
remoteDisplay : True
value : 1

I think you're going to have to track it on your own with another variable.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Oct 29, 2018 6:24 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Variable - Last Change

You could achieve this with Timed Devices plugin (or possibly Timers & Pesters, not sure) if desired.

Create a timer that doesn’t do much except change whenever the device/variable it’s watching changes.

Then use your code above to watch the device time instead.


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Oct 29, 2018 6:29 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Variable - Last Change

Thanks Dave for your reply. I considered the 2nd variable but wondered if I missed something.

howartp wrote:
You could achieve this with Timed Devices plugin (or possibly Timers & Pesters, not sure) if desired.


I'll give that a go as I already use that plugin.

Posted on
Tue Oct 30, 2018 12:45 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Variable - Last Change

checkout plugin "seconds since last change" ..
populates variables for seconds since last change, secs since previous change, and previous value for variables and or dev/states.
https://www.indigodomo.com/pluginstore/96/


Karl

Posted on
Tue Oct 30, 2018 2:46 pm
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Variable - Last Change

Thanks Karl, I'll give that a shot!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest