Timers - Request for ideas

I have a sauna. My goal is to create a lovelace card that allows me to define a delay to turn it on and for how long it will be on. More than that, I would like to know when it will be turned on.

To accomplish this I have created, first, a boolean input so it can be used on an automation:

input_boolean:
  sauna_switch_on:
    name: Turn on sauna
    initial: off
    icon: mdi:lightning-bolt

Then I have created two input numbers, one to define the delay before turning it on and another to define for how long it will be on:

input_number:
  sauna_start_delay:
    name: Delay in Minutes
    icon: mdi:clock-start
    initial: 0
    min: 0
    max: 240
    step: 15

  sauna_duration:
    name: Duration in Hours
    icon: mdi:clock
    initial: 2
    min: 1
    max: 4
    step: 0.5

Finally, I have defined a lovelace card so I can turn the sauna on; define a delay if I want to do so; define the working time:

type: entities
entities:
  - entity: input_boolean.sauna_switch_on
  - entity: input_number.sauna_start_delay
  - entity: input_number.sauna_duration
  - entity: sensor.termo_sauna_ds18b20_temperature
    name: Current Sauna Temperature
title: Sauna Control

What I miss here, when I set the sauna to start like in 1 hour, is the information on the lovelace card telling me when it will turn it on and for how long. I guess that to do so I need to get the current time on the automation, add the delay time, get the time plus delay and, in somehow, publish it so it can show on the lovelace card.

As a beginner on this kind of automation, I am asking here help on ideas of how I could accomplish this.

Thanks!

Have you considered using a Timer instead of an Input number for the delay?

To be honest, I didn’t know about the “Timer”. However, I want to be able to, at any time, remember that I should program the sauna to be on and do it. If the delay is a fixed number, then it will not allow flexibility. You may ask why, so let me explain: I may get home delayed from several reasons like working til late or to due to the traffic to get home. I don’t have a VPN to my home place so I need to program it when I am at home. That is why the delay should be settable.

The duration of a timer is only “kind of” fixed, it can be changed by using the timer.start service call. There are custom cards and card features that can be used together with a script to create a card to adjust a timer and monitor the remaining duration.

Card mock-up:

If you want to stick with the input numbers, you will likely want to use the values from the input numbers to set the value Input datetime helpers which can be used to provide the target time for Time triggers. But the exact way to do it in an automation will depend a lot on the way you want to interact with the card.

So far I got a solution. What I don’t know is if it would be possible to do it in a easier way. O my solution I have created, using the HA GUI, this automation:

  alias: TimeTurnOnSauna
  trigger:
  - platform: state
    entity_id:
    - input_boolean.sauna_switch_on
  action:
  - service: mqtt.publish
    data:
      qos: '0'
      retain: false
      topic: sauna/turnon
      payload_template: '{% if is_state(''input_boolean.sauna_switch_on'', ''on'') %}
        {% set delay = int(states(''input_number.sauna_start_delay'')) %}
        {% set hora = now() + timedelta(minutes=delay) %}
        {"time": "{{ hora.strftime(''%H:%M'') }}"}
        {% else %}
        {"time": "---"}
        {% endif %}'
  mode: single

As I publish via MQTT the turn on time, I can update the lovelace card with the time. If I turn off the sauna, then I get “—” meaning it will not turn on.

Now I have to either, find a way to load a timer and turn on the sauna. As I am using a ESP32/Tasmota device, I can just use MQTT to load a counting down timer on it.

What I don´t know is if it would be possible to load a timer into HA to do the same. But for me the problem is solved, while not sure if it is the best way of doing it.

By the way, thank you for your help.