Creating a stopwatch - best way to accomplish this?

I find myself working overtime a few hours every month. Typically, I just write down the time worked and submit it to HR at the end of the month. I’m wondering what suggestions you guys have for manually tracking time.

Something like a “stopwatch” card where I can start/stop/pause and it adds the cumulative total to an entity until I manually reset.

So far, I have created an input boolean (input_boolean.stopwatch) and added the history stats integration like this, but from what I understand this will automatically reset at midnight.
image

  • platform: history_stats
    name: Overtime Worked
    entity_id: input_boolean.stopwatch
    state: “on”
    type: time
    start: “{{ now().replace(hour=0, minute=0, second=0) }}”
    end: “{{ now() }}”

I would like it to never reset, unless I reset the history stats for the sensor. Also, I’m stuck on figuring out how to reset the stats for the Overtime Worked sensor. I can manually set the sensor.overtime_worked state to 0.0 from Developer Tools, but I’m not sure how to create a script or automation to set it to 0 or reset it.

Any suggestions?

This will reset it at midnight. So why have it? Perhaps set duration to an impossibly long time.

Thinking about it some more:

Have a date-time helper set to the start of the current period.

Use this as the start: in the integration.

Write a script that when activated writes a markdown card with something like:

DJ Brookes has worked (state of Overtime Worked sensor) between (state of date time helper) and now().

Then the script should set the date time sensor to now() which will reset the value of Overtime Worked.

You can copy the markdown into whatever report you file with your HR people.

Although you question is a bit dated, maybe this is useful for you:

https://community.home-assistant.io/t/stopwatch-with-start-stop-resume-lap-and-reset/443994

1 Like