I have a sensor on a dryer that tells home assistant when it is on and off. I’d like to add a card to my lovelace that shows me how long the dryer has been on. I’m looking for it to display in HH:MM:SS. I know I could use the timer component to count down, but I want one that counts up. I looked at the history stat sensor but it was only showing me the amount of time the dryer had run in a 24 hour period. I want the elapsed time to reset every time the dryer turns on.
Here’s one way that might work for you. (I tested it and it seems to work ok. Obviously replace input_boolean.dryer with your dryer on sensor.) Don’t forget to exclude sensor.dryer_on_time from the recorder, otherwise it will “spam” your database.
Can you please clarify the code for the automation? I’m having trouble with the two triggers as I’ve never stacked them like that before. Could I have it this way instead as that passes the code checker.
Thanks for the tip. In my instance, I’m only interested in time between 0 and 30 minutes but that will be good to know for other appliances that may be on longer.
Is there a way to keep the 2nd automation from spamming my logbook? It looks like it shows it triggers roughly every second.
I have an automation that sends an ios notification when the dryer is done.
.....
action:
- data:
data:
action_data:
push:
badge: 5
category: fullautodryeroff
sound: fire-truck-air-horn_long-and-loud.wav
message: FULL-AUTO MODE The dryer turned off at {{ now().strftime("%I:%M:%S%p")
}}
service: notify.ios_mikes_iphone_11
This tells me what time the dryer turned off. Instead, could I have the notification include the amount of time the dryer ran by sending the state of the entity sensor.dryer_on_time? If so, how would I do that?
I also spoke too soon on this working. I tested this on my personal HA and it worked but it’s not working on the different HA that I’m trying to add this to. Not sure if it matters, but the different HA is running version 0.88.2. I plan to update that eventually, but can’t update it now.
Here is my config and automation file on the HA it’s not working on. I can see both automations trigger in the logbook, but the state of sensor.dryer_on_time is not changing. It just shows “unknown”.
binary_sensor.five is the sensor that tells me if the dryer is on or off.
Then you probably need to exclude it from the Logbook, too. See the second link above.
Ha ha ha ha ha ha!
Sorry, but couldn’t resist. Do you know how much has changed since then?! I suspect the time_pattern trigger didn’t exist yet. And maybe not the homeassistant.update_entity service either. If you want help with that old of a release, you might be on your own here.
Well shoot, that’s kind of what I figured. I’ll find a time to update that HA then try again. The HA is installed about an hour away at our farm and handles some automations for our harvest. We are in the middle of harvest and behind schedule. The last thing I want to do is update and cause issues that will slow us down.
Hi!
Adding my two cents to this older thread as it popped up in my search.
I was trying to make something that showed me the minutes my TV has been on.
sorry to bump an old thread but I managed to get this working, sort of. I can get the time on to display in minutes when the ‘input_boolean’ is switched on, but when the same ‘input_boolean’ is switched off it just keeps on counting up. i used @xbmcnut’s example. i feel like there’s something straightforward that I’m missing here…
Hi,
Sorry to revive this old thread again but I’ve faced a similar use case and I wanted to share my approach by using the “new way” of templating sensors instead of using the “legacy” version.
Preamble:
I have a Shelly PM mini that measures the power of my “dummy” washing machine
Code:
I’ve created a binary_sensor that tells me if the washing machine is on/off based on instantaneous power consumption
The delay (as per the example on the official documentation) is to avoid triggering on/off continuously at the latest stages.
Then I created a helper sensor that updates every minute but checks if the previous binary sensor is on. If true, keep counting the minutes, otherwise it remains still. Every time the sensor changes again from off to on, the timer resets.