Retrieve and average past values of variables

Posted on
Thu May 03, 2018 7:13 am
bluehouse offline
Posts: 13
Joined: May 04, 2011

Retrieve and average past values of variables

Is it possible to retrieve and average say, the last 5 stored values of a variable? For instance, I want to compare the most recent period between sump cycles with an average of the last few and alert me if it’s overdue. (Sump failure: the whole reason I started down the home automation path; now I have a whole house full of fun!)

I could do it by storing each of the five most recent in separate variables and updating all of them each cycle but wondered if there was a more elegant & efficient way to do it?

Thanks for any thoughts!


Sent from my iPhone using Tapatalk

Posted on
Thu May 03, 2018 10:37 am
kw123 offline
User avatar
Posts: 6251
Joined: May 12, 2013
Location: Dallas, TX

Re: Retrieve and average past values of variables

thats roughly it, you could use one complicated variable ( with json)

indigo does NOT offer averages etc. you could also use sql retrieval from the last events, but that requires some programing
Indigo utilities has a menu and action that retrieves the last xx values of a device/state, but does not do averages.

Karl

Posted on
Fri May 04, 2018 7:36 am
Colorado4Wheeler offline
User avatar
Posts: 2755
Joined: Jul 20, 2009
Location: Colorado

Re: Retrieve and average past values of variables

The way I handle this (and it's something I've written into Device Extensions if I ever get time to finish the updates and release it) is to stash the variable into a single variable in JSON format so you can extract it easily. That way you can stash as many days worth of variables as you want in one called, for instance, "DailyValues" and use json.dumps and json.get to store or use them.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sat May 05, 2018 5:52 pm
bluehouse offline
Posts: 13
Joined: May 04, 2011

Re: Retrieve and average past values of variables

Thanks guys. I’ll take a look at options you suggested when I’m back at my computer.


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests