Requesting EDGE driver to accumulate time (see post #11 for edge driver)

Hi all,

I’m looking for an EDGE driver that will accumulate time (until automatically reset) based upon how long a switch is on or a contact is open/closed.

I have a use case with my HVAC system where I accumulate the total time the electric resistance heat (backup heat) operates in a given day. Gives me an idea of system performance and how high my electric bill will be. Currently doing this through Webcore (with variables) and a Value Tile which is reset at midnight every night.

Anything available with EDGE?

Thanks.

So you want a basically a counter?

@ygerlovin or @TAustin could this be done as virtual device?

I guess so. Totalize the time that a switch is on or a contact is open/closed. Keep totalizing as that switch/contact continues to change over time until the totalizer is reset.

Sure, that could be done. I’ll look at adding it to my vEdge driver.

2 Likes

It would be great to have such a virtual device!

I know some drivers make use of timers, but I’m not aware if those can pause and continue… I’m thinking of @Mariano_Colmenarejo 's Light Driver which changes light levels over time. At least in that case the timer would have an equivalent in Light Level or Color Temperature which could be used as a reference condition for time.

I suppose the other challenge is how to have the total reported daily, before or upon reset.

Question:

Because I have no idea, really.

Would/could the accumulated time be a value that could be used in a routine, like temperature value, humidity, and so on…?

Also, on a personal wish list, one would be a virtual device that could do a simple tally, like +1 or -1 with a when “pressed” etc… would be a useful device, I think.

You can certainly build conditions based on numbers with ‘matches’, ‘equal or above’, ‘equal or below’, or a range. So your tally or counter or whatever you want to call it, would need to be just a simple number. Not time or anything like that, because I don’t think you could do anything with a time value. I’m not up on the latest Rules engine options, so maybe there are more sophisticated conditions you could build there.

So let’s say that the device is configurable to count either seconds/minutes/hours/days/etc while the switch/contact is in a certain state. You would have to have a routine that gets triggered to do something based on that value.

The other device you mention could be a simple button that just increments a counter each time it is pushed. It could be pushed from an automation routine or manually in the mobile app screen.

1 Like

I’m finishing up some other updates, but will start work on this soon and have something for you to look at and test. We might need to go through a couple iterations to maximize its usefulness!

3 Likes

Excellent, looking forward to it! Thank you!

1 Like

Yeah, the tally counter or incrementor, or whatever came back to mind while I was imagining a way to mark time through whatever method.

I wasn’t set how to implement to clock/timer part, but was imagining a momentary button to trigger an increment and maybe an additional momentary to subtract (or some configuration to accomplish either). In any case it seems like an alternative to multiple on/off conditions in a virtual multi-switch.

Just some ideas. Looking forward to what you come up with.

Thanks for all your efforts!

I’ve put a first pass driver out on my test channel.

Name: Edge Utility Device V1
Version: 2022-08-21T04:40:53.23049633

Enroll your hub and choose the driver above from the list to install.

Once the driver is on your hub, the next time you run a Scan for nearby devices, you should get a new device created in your ‘No room assigned’ room.

When you open the device you’ll see that it provides both functions you were looking for: a duration for how long the switch is on (Main component), and a counter for how many times the momentary button is pressed (Counter component). There are also reset buttons in both components, and a button to create additional devices.

First, go into device Settings via the 3 vertical-dot menu in the upper right:

  • Duration Resolution - choose the granularity you want
  • Duration Auto-Update Frequency - this determines how often the driver keeps the duration value current; this will depend on your needs.
  • Contact sensor Behavior - I included a contact in the main component as a companion to the switch in case you prefer it.
  • Profile Icon - will allow you to change the icon and category of the device to suit your needs (I haven’t implemented this yet)

Operation

On the device Controls screen, turning on the switch will update the contact sensor state per your preferences and begin the duration tracking and auto-updating of the duration field. The duration field will show the value in the units you chose in settings (seconds, minutes, hours, etc). Turning the switch off will reset the duration to 0 and terminate the auto-updating. If you want to refresh the fields between auto updates, just perform the swipe-down action on the screen.

Tapping the reset button with the switch on causes the tracking to start over at 0.

The ‘create another device’ button does just that - if you need multiple of these devices. Each will need to be uniquely configured in settings.

In the Counter component, each time you tap the momentary button, the counter simply increments by 1. Tapping reset will set it back to 0.

Note there is a problem currently with some iOS apps not showing the correct field labels or units. (The duration field should show both the number and units but doesn’t for me at the moment). Don’t know if you’ll see this or not.

Duration and counter fields are available as IF conditions in automation routines.


To be discussed:

  • duration value is an integer - is this ok?
  • duration calculation persists through driver restarts when the switch is ON
  • counter gets reset to 0 any time the driver is restarted
  • dashboard: action is the switch; do we need option to change this to the momentary button?; state shown is also the switch; do we need options to display duration or counter values instead?
9 Likes

Could this be optional and changed from the settings?

Thanks @TAustin, I will be taking a look shortly.

Ideally, I’d like to be able to see the totalized value from the tile.

My current setup (using Webcore) would also send a notification at midnight to tell me the totalized value; at that time, it would also reset to 0. I realize that the loss of Webcore is going to take some of my features away, but if I could at least get the value on the tile and from its history, this would probably suffice.

Hey @TAustin,

I’ve played around with this, thanks very much for the start! Couple of questions and comments:

  • For my purposes, everything could probably be done with a switch: when the switch is turned on, start the timer and increment the counter; when the switch is turned off, pause the timer. But switch+momentary will work too if it adds flexibility.
  • I’m not sure that the contact adds much value to me. When I was thinking of this, I was imagining it would “watch” another switch or contact sensor to do its business, but now I’m realizing I will need to have a Routine doing the watching. So I think having the Routine turn on the switch will be enough.
  • I would prefer the duration not reset when the switch is turned off, but instead pause and then resume accumulating time every time the switch comes back on. For my use case, backup heat could come on 10x per day, and I’d like to know the total time across the day that it comes on.
  • Can the reset(s) be activated externally from a Routine? Or will they need to be a manual press? Again, for my use case, I like to know how long backup heat was on in a day. With Webcore, that timer currently is resetting at midnight every day automatically and sending the value to me as a notification at that time.
  • I would like to see the total time or the total number of counts from the tile, with a unit (i.e., minutes) if possible.
  • I’m not sure what is meant by ‘driver restarts’ in your list above.

Thanks!

Wow, I certainly didn’t expect to see a test driver so soon!

This is definitely a fantastic utility, as it is, presently.

I don’t know if it’s possible, but pausing duration vs reset would be a great option. Otherwise counting 10 second increments appears to most accurate use of the counter for marking time.

example (with Duration Resolution: seconds):

IF

Counter Utility> Duration Matches = 10 secs

THEN

Counter Utility > ON (which resets duration)
Counter Utility > Momentary > Pressed Momentary (Counter +1)

So, a counter value of 6 = 1 minute. A value of 7 = 1 minute 10 secs. etc.

Setting the Counter Utility > Off would be effectively a pause with the above logic, and continue with setting back to On.

At least that’s the best I can come up with this morning.

Again, It’s amazing enough as it is.

The only other thing, at the moment, is maybe the possibility of having the counter subtract by one, as a settings option if not a proper subtract button, .

Thanks for the feedback guys. I’m away for most of the day, so won’t get too much time to work on this until later, but sounds like I should go ahead and make these changes:

  • switch = off will pause tracking, not reset
  • settings option to display either duration or count on dashboard

Regarding the inclusion of the contact: if you’d ever want to test the value of the switch from an Alexa routine, you’d need this. I could remove it from being visible on the Controls screen if it has no value for most people.

Resets can be performed from an automation routine.

“Driver restarts” means whenever the driver is reinstalled on the hub (an update, for example), or when the hub reboots.

To have a possibility to use Alexa is a good thing. You never know when it’s needed. But could that contact sensor indicator be moved bottom so it wouldn’t be right under our noses when opening the device?

Could this be option in the settings too?

I think what I will do is just make it invisible. I don’t there is much value in even keeping it on the Controls screen. It will still exist as part of the device and be available for automations.

Maybe - I’ll see what I can do

Since my mobile app is screwed up, can someone tell me if you see the units displayed in the duration field on the device Controls screen? Or maybe post an image.

They are there, spelled out and all… All of them display correctly when changed around.

sorry can’t post an image at the moment.