SecondsSinceLastChange

Posted on
Mon Jun 08, 2015 6:00 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

SecondsSinceLastChange

LATEST VERSION:
in indigo store https://www.indigodomo.com/pluginstore/96/



older versions:

This plugin can be used to track or trigger on the number of seconds since a device/state or variable has changed.
It will show the seconds since last change in a variable .. :
devName_seconds_since_change;
devName_seconds_since_previous_change;
devNameprevious__value

You can set
1. In CONFIG: Name of folder where the variables should go.
Screen Shot 2018-10-30 at 13.36.19.png
Screen Shot 2018-10-30 at 13.36.19.png (72.33 KiB) Viewed 6376 times

2. IN CONFIG: use subscription to changes(indigo calls this plugin for any change in any device) or test values of the selected device/state in a loop every xx seconds.
both work. you can try both modes. the load on the system depends on the number of changes, number of devices and # of device/states you like to track.
3. IN CONFIG: frequency of checks . This is essentially the "self.sleep( time)" between actions : 0.5 seconds .. 10 seconds.
In LOOP mode nothing happens in-between. In Subscribe mode, the variable gets set to "0" if there was a change for the device/state.
4. In MENU: the update frequency -if no change - for EACH device/state or variable, i.e. how often the # of seconds should be updated: 1 second .. 3 minutes
Screen Shot 2018-10-30 at 13.38.15.png
Screen Shot 2018-10-30 at 13.38.15.png (39.31 KiB) Viewed 6376 times


Once running you can set a trigger on these variables
if variable "devName_seconds_since_change" > 60 ==> action.

I suggest to not use 0.5 seconds sleep time and 1 seconds update frequency initially as this will be creating some load on the MAC, start slower and then increase frequency.
Reasonable settings are 3 seconds sleep time and 5 seconds update frequency.

Change log:
v 0.3.1: added option to choose between testing for change in a loop and subscription to changes of devices/ states in indigo.
v 0.3.2: fixed spelling and tool tips in menus
v 7.1.8 major rewrite, now requires indigo 7
Karl

This is how the variables look like, the numbers are the seconds since last change:
Screen Shot 2018-10-30 at 12.49.01.png
Screen Shot 2018-10-30 at 12.49.01.png (16.08 KiB) Viewed 6376 times


print config to logfile (Menu):
Code: Select all
13:40:20 DevID                    -Dev-Name----------       ---------------State  Data----------
13:40:20 1746527826               -s-0-tmp006                        Temperature  {u'lastCheck': 1540924773.071432, u'lastChange': 1540924773.071432, u'checkFrequency': 60, u'lastValue': u'72.3', u'previousChange': 1540924722.987179}
13:40:20                          -Configuration
13:40:20 VarID                    -Var-Name----------         Data-------------
13:40:20 1794464921               -youGotmail                 {u'previousChange': 1540923119.143105, 'lastValue': u'true', "'checkFrequency": 60, 'checkFrequency': 60, 'lastCheck': 1540924803.118547, 'lastChange': 1540923120.584453}

Posted on
Tue Jun 09, 2015 12:02 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: SecondsSinceLastChange

Very nice, thanks, I will give it a try :)

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

Re: SecondsSinceLastChange

Cool, I'll look at this later.

Have you spotted the typo in the screenshot above?

Posted on
Tue Jun 09, 2015 1:36 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

New version 0.3.1: Added "subscription to changes" option instead of testing devices/states in a loop every xx seconds.

Karl

Posted on
Tue Jun 09, 2015 3:31 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

version 0.3.2 posted: fixed some "spleeing" errors and added some tool tips..

Posted on
Thu Aug 27, 2015 4:02 am
Shutter offline
Posts: 345
Joined: Mar 07, 2014
Location: London, UK

Re: SecondsSinceLastChange

Hi Karl,

Is there a workaround for devices with spaces in their names?

Simon

Posted on
Thu Aug 27, 2015 6:31 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

[urlhttps://www.dropbox.com/s/xaik1booyfch82a/secondsSinceLastChange-v-0-5-0.zip?dl=0[/url]-v-0-5-0

fixes:
if your device name contains a space the resulting variable name is not valid.
Now " " is replaced with "_" in variable names.
eg:
device name = "abc 123" and state ="xyz"
then variable names becomes
variable name ="abc_123_xyz"

Karl

Posted on
Thu Aug 27, 2015 8:37 am
shapa offline
Posts: 483
Joined: Sep 08, 2014
Location: Swindon

Re: SecondsSinceLastChange

Some (can be very useful) idea - to track not only last change but previous one.

For example, it will help a lot to understand that no one was (motion sensor) in the room for last XXX seconds - i.e. some "delayed" actions only in case the room is (un)occupied for some time.

In fact, a lot of interesting things can be made.

Can you please implement it? It should be very simple - just to store data in a "_previous" variable when new event happens with the device.

Posted on
Thu Aug 27, 2015 8:39 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

https://www.dropbox.com/s/rmfogsn1cpalxyj/Info.plist?dl=0-v-0-5-1

fixed a bug I introduced in 0.5.1

Posted on
Thu Aug 27, 2015 8:43 am
Shutter offline
Posts: 345
Joined: Mar 07, 2014
Location: London, UK

Re: SecondsSinceLastChange

kw123 wrote:
https://www.dropbox.com/s/rmfogsn1cpalxyj/Info.plist?dl=0-v-0-5-1

fixed a bug I introduced in 0.5.1


Hi Karl,

The link is only to the info.plist.

Posted on
Thu Aug 27, 2015 8:56 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

check first before you click :oops:

Posted on
Thu Aug 27, 2015 9:34 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

https://https://www.dropbox.com/s/n890x0jt9k0611f/secondsSinceLastChange-v-0-6-1.zip?dl=0 -v-0-6-1

added:
Two variables will be created for each device/state you select:

1. seconds_devName_stateName <== seconds since last change
2. secondsPrevious_devName_stateName <== seconds since the change before


eg

set Thermostat to 71 ==>
seconds_Thermostat_setPointCool = 0;
secondsPrevious_Thermostat_setPointCool =300 (if seconds_Thermostat_setPointCool was 300)

both values are incremented at the check / update frequency selected.


Karl

ps I hope I posted the right version ... :P

Posted on
Thu Aug 27, 2015 9:47 am
jeffgtx offline
Posts: 43
Joined: Aug 19, 2007

Re: SecondsSinceLastChange

would you sue this with fingscan in order to track cell phones home/away?

for instance, sometimes the phone leaves teh network for a minute, but i am still home. could i have it wait until it has been off the network for 5 minutes before triggering any away actions?

Posted on
Thu Aug 27, 2015 9:50 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: SecondsSinceLastChange

fingscan offers that already. you can set 2 timers for each event:

1. how fast to (re) trigger Home: how long does the device have to be not home before home can retrigger.
2 how long after device is away " away" is triggered.


Karl
Attachments
Screen Shot 2015-08-27 at 10.49.52 AM.png
Screen Shot 2015-08-27 at 10.49.52 AM.png (14.54 KiB) Viewed 9190 times

Posted on
Thu Aug 27, 2015 10:35 am
jeffgtx offline
Posts: 43
Joined: Aug 19, 2007

Re: SecondsSinceLastChange

Oh. Thank you.

Who is online

Users browsing this forum: No registered users and 1 guest