Oven Incremental Timer

There have been many times when I will put something in the oven, like a batch of cookies, and forget to set a timer. I have added a contact sensor to my oven door to track when the door opens and closes. Is there some sort of Lovelace card that would show the amount of time in “minutes:seconds” since the oven was last opened? Then if the timer/counter ever got above like 15 minutes or something it would stop counting and hide the card?

This question is twofold. What would be the best way to create this “stopwatch” - a counter, a number, using history states, etc.?
How do I display the value of that timer in minutes:seconds live on a Lovelace dashboard?

Thanks!

The helper timer counts down.
If that is useful the you can have the timer set to default 15 minutes and ever time you close the door it should reset and start the timer.

Untested but something like:

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.oven_door
    from: 'on'
    to: 'off'
condition: []
action:
  - service: timer.cancel
    data: {}
    target:
      entity_id: timer.cookies
  - service: timer.start
    data:
      duration: '00:15:00'
    target:
      entity_id: timer.cookies

I could do something like this as a workaround and just know the timer started at 15 minutes and subtract the amount of time that has changed to find how long something has been in the oven, but I’m really hoping for something that counts up.

You can just add a template to lovelace and do a time difference since the last time it was opened. like template-entity-row in hacs.

Or you can create a template sensor doing the time difference and add that as a regular entity?

But they will only update every minute.
I don’t think you can make them update every second.

There is one more dirty hack…
You create a counter, have an automation to reset it and have it count up (increment) every second when the door closes with some loop (I think).
You can then use the counter (seconds) and format this as mm:ss.

But I would say a timer that counts up is perhaps something to ask for as a feature request.

Do you know if doing something like this is taxing on the processor? I run my instance on a NUC, so I’d assume it wouldn’t really affect it, but just curious if it would.

How can I format it to be mm:ss?

It will load your CPU. But will it be noticable? I don’t believe so.
I had a similar automation running in the past and it worked fine on a pi4.

UNIX timestamps originate 1970-01-01 00:00:00, and that timestamp is UNIX 0.
So, converting a number 0 as UNIX => a datetime will result in 00:00 (if we ignore date and hour).

{{ states([counter entity id]) | int(0) | timestamp_custom("%M:%S") }}

Will probably work as a template sensor.
Not sure if it is %S but that is my best guess.