Setting a timer, stopping a timer, showing time left

I’m having issues trying to figure out how to do something like this.

I have a bathroom fan and when it gets turned on, I want a timer to start for 30 minutes and then automatically shut off after that time. If someone shuts off the fan, I want the timer to turn off and zero out. But I also want the amount of time left on the timer to be shown on one of my HA pages. See screenshot of example.

Overview – Home Assistant — Mozilla Firefox

When the fan is off, the timer part of the label would just say “Bathroom Fan”.

Any ideas how to accomplish this? Thank you.

Have a look at timer-bar-card . It does it differently to what you’re asking for, but may meet your needs.