Variable Length Timer

I’m a bit embarrassed to post this. First, there are so many brilliant, sophisticated contributions to which this project does not hold a candle. Secondly, programatically turning off a bathroom fan may be the height of laziness. And thirdly, bothering to make the timeout period variable can only be described as [redacted].

That said, service.timer_start does not currently support a template for the duration, so I cobbled a workaround.

When the fan is started, the current value of an input_number is used to save a timestamp of the timeout moment, and a timer is started. When the timer finishes, the current timestamp is compared. If we have completed, the fan is turned off. If not, the timer is restarted. If the fan is physically turned off, the timer is cancelled. Four short automations do the “work”.

The automations and supporting items are contained in the attached file.

Maybe you have something more (or less) important to variably time. If so, have at it.

If you have a simpler or more elegant solution please post yours.

variable timer.yaml (3.6 KB)

1 Like