App: Device Tracker, Multiple Device On/Off Times, On Counts, Notifier, Battery Levels, Switches, Contacts, Temperatures, Power, etc.. With variables access

Hi @kampto ,
I can confirm that the refresh every X minutes is working.
A couple of questions,

  1. What is the meaning of "after the hour" in the text for the auto update?
  2. I did not see a refresh variable log when the measured device is closed.
    In order to reserve CPU it would be better if the refresh every X minute will happen only while the relevant device is ON (or OPEN or in the state you are timing). When the timed status is CLOSE it should send a refresh command to the variable attached and stop refreshing till next measured status happen.
    Does this make sence?
  1. Im using a CRON for the refresh, so if you picked 2, that would be 2, 4, 6,.. Min after the hour. So 7:00, 7:02, 7:04, etc.. if the hour is 7. If you picked 30 then 7:00, 7:30. 8:00, 8:30,...

  2. I just now added a log for device Inactive or Off. It updates variable every time it goes to the Off state, its always worked that way. Periodic updates keep you informed if its changed open or closed. I doubt the CPU usage will be high but your check the log stats. But I can look into it for On only.

Im thinking of adding an bool Option to have the time tracker variable written as a number in total seconds so it can be used in a rule rather then just displayed in string time format. "String format in time" or "number format in total seconds". Then you could use RM trigger things based on how long a device has been on or off.

2 Likes

I think you are right and other people might find it useful.
Me personally, I will stick to the string as I am mostly interested in displaying the variable value in a HH:MM:SS format.

That worked. And great work BTW on creating this. I might come up with some use cases in & around tracking how long someone has been sitting/becoming sedentary & sending out notifications based on time expended thresholds.

One catch is that you need to account for the different options when pulling the variable list:

if(state.newVar) {
					List vars = getAllGlobalVars().findAll{it.value.type == "string"}.keySet().collect().sort{it.capitalize()}

Will only pull variables that are set to type String. Flipping to having the pure seconds count would need to have a Number variable type to make sure the right operations are available in RM, etc..

Looks like pulling "number" is a no go, its actually "integer". So a slight mishap by hubitat I think for commonality.
String variable is "string", Boolean variable is "boolean", but Number is "integer". Trail and error to figure that out. In progress!

1 Like

Guess I need to go back and RTFM :slight_smile:. That's my bad.

Yes, but perhaps for commonality on the hub variables page it would be called "Integer" instead of Number to make it more intuitive. but all good.

1 Like

Current app functionality fully support my Boiler timer requirement as I am only interested in knowing how long was the boiler on since 02:00 AM last night.
So, I can trigger a reset at 02:AM and present the variable count on the dashboard.

As for my sprinkler system the requirement is a bit different and not fully covered. I am collecting watering data for each valve and presenting the last wateiring cycle on the dashboard. I am looking for an option to trigger the RESET only when the valve is ON (or OPEN) next time. This is ofcource doable using rules but I would love it to be part of the app.
If you think this is something you are willing to do I would love it.
If you are willing to give it a go you might want to consider allowing each variable get a diferent RESET meachnism. For example - Boiler timer variable will get a daily reset but the valves timers will reset only on the next ON command.

One last thing, I think (not sure) many users would love this app but might miss it when looking for a "timer" or "counter" app and getting no results due to the current app name. I might be wrong

I update it to have reset when On or what ever the active tracking state is, give it a shot.
Also add option to save variables as integer data type so you can set triggers or whatever in rule machine. And fixed a bug with power monitoring reset.
Note that these options apply to whole table.
Only need to copy paste the child App.

Option to have integer variables. Show up when you select variable.

1 Like

Hi @kampto

Is there a way of refreshing (and resetting) the variables/timers based on something other than the monitored devices?

I'm attempting to use this in conjuction with webcore to track activity times and use within displays/pistons.

will test later on today and let you know

You can use a boolean variable to reset the table from outside the app from rule machine and maybe webcore? Set variable to 'true'

Ah, I see. Ta.

That's half the job.

Is there a similar way to have the value/variable update?

Hi @kampto
I can confirm the "reset when device becomes active" is working as expected.
Thansk a lot.
I still see the log file gets a line every X minutes thus I understand that you did not find a solution to stop the refresh if and when the device is not active. I might need to reduce the refresh rate to get less logs and reduce CPU usage.
Also, the resetr options are still at the child app level and not in the device level and I might just create a child app for each device.
Thank you again for developing this app.

Yes, for now the entire table is tied to the options so a seperate child app is needed.

I can add an option to disable logs if that's needed. Its easy to do. An option for Variable refresh on devices that are Only Active is doable, but I need to figure it.
Checking Logs / App stats will give you an idea of the resources its using. In my case its not much.

Update: Added option to disable App based logs. But when a variable gets updated it will log that variable change, nothing I can do about that, its built into hubitat.

2 Likes

Hi @kampto

If this...

... Could be duplicated to read "update all variables every xx seconds whilst device is on", it would be perfect.

Appreciate your time so far! =.)

Here's a use case I'm trying to sort through.
Warning @kampto : I'm not a coder (nor do I play one on TV)

I'd like to be able to easily define a custom time span (i.e: 2 weeks) in which I could set up devices & let usage/active time tracking event timers freely run in order to capture everything the sensors generated during that time to create an initial general usage/activity baseline. For example, based upon using room occupancy sensors - how many hours did someone spend in various rooms over the course of those two weeks; using pressure sensors - how long has someone been sitting overall, where have they been sitting most of the time, etc.

With a captured baseline to start from I'd like to be able to (automatically) invoke simple math to determine simple things for now, such as daily/weekly/monthly/custom time frame averages, prioritization/sorting based on time, etc. Trend analysis/usage patterns is what I'm ultimately going for. A poor mans AI for sure - but its a start. Oh, & icing on the cake would be a streamlined way to graph this data (via Quick Chart?) and be able to simply drop into a dashboard (I love SharpTools).

Many more thoughts/use cases bouncing around in my fat head; any & all thoughts/comments/critiques/criticisms welcomed.

1 Like

@mark1 @kampto
I'm seeking similar data that mark1 is seeking - with the added granularity of how long was each session (vs total cumulative duration of all sessions).

My specific use case is to establish a baseline for how long my dehumidifier runs in normal operation, so that I can program the plug that controls it to turn off if it is running for 1.3 x normal or some such duration. Several humidity sensors trigger the plug to go on when the humidity is over 51% and to turn off when it gets to 47%. The dehumidifier is in the crawl space, and I've gone to great lengths to make the dehumidifier as quiet as I can.

Last summer the dehumidifier failed and iced up, so it stopped dehumidifying. Since it was no longer dehumidifying, the sensor never got to 47%, so the plug stayed on. Thus the compressor and fan on a non functioning dehumidifier ran for probably over a month, until I received the power bill and went looking for what went wrong... I want to prevent that.

I now have a notification set up to alert me if the humidity gets over x, but still, I want to automatically prevent the dehumidifier from running too long.

Me too. Hence...