Stopwatch with start/stop/resume, lap and reset

You can do it with something like this:

alias: XXX
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.xxx
    from: "off"
    to: "on"
action:
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.start_stopwatch
    data: {}
mode: single

Hello everyone,
unfortunately I’m a newbie.
Unfortunately the stopwatch doesn’t work for me, I did something wrong. I copied the code completely and unchanged into a package file. But Sensor.stopwatch always shows “unavailable”. What do I have to change?

Hi, have you performed a reset since setting it up? If not, activate/toggle the input_boolean.reset_stopwatch, and that should sort it out

It works, thank you very much! :slight_smile:

Has anyone else noticed issues with this stopwatch recently? It’s been working fine for me for about 6 months, but over the last few days it seems to have weird behavior and is producing incorrect times when its being called in automations. The automations haven’t changed though. I’m thinking perhaps its related to the recent 2024.4 release so it would be helpful to know if others are seeing any issues.
Thanks.

Hallo, I have had the same problem since updating to 2024.4.2.
My 3 stopwatches ran without any problems until the update. Afterwards the stopwatches do not start or the times are not displayed.
Nothing has changed in terms of automation.

Same here, since updating to latest HA my stopwatch has started behaving incorrectly. I noticed it just now, when a seemingly random time just displayed for my tumble dryer running duration, which has been running for just a few minutes. I’m not sure where the duration is coming from:

image

but clicking ‘reset’ no longer puts the timer back to zero, it just changes the timer to a different seemingly random duration like this:

image

EDIT - I believe I have figured out what it is. Yesterday, I removed ‘beat’ from my sensors.yaml file under the platform: time_date section, due to seeing the warning about ‘beat’ being deprecated in my logs. I’ve just tried adding ‘beat’ back in again here:

image

and restarted HA, and my stopwatch is back working correctly again. Unless this is just a coincidence and restarting HA has temporarily fixed it for now until it stops working again, but with beat being related, it seems like too much of a coincidence to not be that? @miguelpucela - are you able to confirm please?

Well the weird times are showing up again, even with ‘beat’ included again, so it must have simply been the HA restart that seemed to temporarily fix things :frowning:

Has anyone figured out a workaround/fix for this issue yet?

After the latest update I installed today it’s working properly again. I skipped the 5.0 and 5.1 releases, and after installing 5.2 the timings are correct again for now.

Thanks for the udpate - I’ve just updated to 5.2 this morning so will give it a try shortly :slight_smile:

Hi! Is there an easy way to create a unique ID for the sensor.stopwatch? If yes, should it be added in the stopwatch.yaml?

hi great stopwatch I want todo bit of a custom job how do I remove the seconds from showing and make the : flash so it looks like 00:00 please can you help ive put the file in my packages folder. what code do I need to change thanks

Hello Everyone, i got a problem with the Reset and the Lap Button.
It only works once. After that i have to reload the Page or the App.
Untill that, the Button stays “blocked”.
I have no clue where to start.
Latest Version of HA. Code is 1:1 from above. Thanks for your help.

1 Like

Something similar to me too…
Some times, hitting Reset gives random numbers

Hi, same thing here. Resetting the timer does not work. Instead, the time is increased by a seemingly random but increasing amount of time.

edit: actually, there is a pattern to the time change. I started writing down the time that is displayed on the timer. My last 3 times were:
22:07:44
22:12:21
22:27:58

I then looked at the differences between those times and those were:
9:37
10:37

I waited exactly 1 minute between the 22:12:21 time and resetting again. I then got 22:27:58. The difference between the last two differences is exactly 0:01:00 which is exactly how long I waited. Does that make any sense? I tested it several times and it is always exactly the time I waited between the resets. The timer has been inactive/stopped the whole time I checked those numbers.

Did you ever get this figured out? I’d like to use this timer but I am not sure how to install it. He refers to the “package” at the beginning but I don’t know what package, and he says to install it as a Helper, but doesn’t say what kind of helper, and most of the Helpers don’t allow for YAML changes.

Is anyone having problems with this since recent HA updates? Ive noticed that my sensor.stopwatch remains at 0 even though the automation is running, which should reset and then start the stopwatch. Not seeing any errors when it runs, and i can manually start, stop and reset the stopwatch ok. I wondered if it was the recent change from the term ‘service’ to ‘action’, however that wasn’t a breaking change, so it should not cause issues. Any ideas?

Did you find anything?

I’ve got the same issues. I’m using this code to keep track of my washing machine, but since a couple of weeks, it shows me that the machine would be running since ~22 hours.

No, not yet, im still trying to look at my automations to see exactly what isn’t triggering anymore.

I’ve done some further testing today, and I can manually toggle the stopwatch to start it or stop it, and also reset it, which all works correctly, but it just isn’t working via automation any longer.

The input_boolean.start_stopwatch isn’t being triggered any longer via automation, and I’m not sure how to debug that any further, as the automation trace shows the correct flow :thinking: