I'm looking for help with a template

Here I am again asking you for help. I really don’t know what to do with templetes!
I am trying, also copying from the forum, to perform this “simple operation”:
I have an identity “input_datetime.fun” expressed in minutes and an identity “timer.timer_fun”.
What I would like to do is:
-load the datatime value into the timer
-start the timer
-at zero of the timer activate a relay (already configured as “switch.fan”.
I sincerely thank anyone who can give me some solutions.

That is not a template, it is a script.

You can create scripts via the UI.

That will use the timer.start service call:

You might need a template to convert your input_datetime entity into seconds.

That will need an automation (which is simply a script with a trigger), which you can also create from the UI.

Set up an Event Trigger for the timer.finished event for your timer.timer_fun, and the action should fire the switch.turn_on service for the fan.

Thanks for the advices. In my H.A. I have automations and a couple of scripts.
What I just can’t do is the operation:
“load the datatime value into the timer”
This really drives me crazy.

A Date/time input helper contains a moment in time: either a date, or a time of day, or both. A timer requires a duration. Those are fundamentally different things.

If you want something to happen at a given time, a timer is not the best way to do it. If you really want a timer for a duration you enter, a date/time input is not the best way to do it. So what exactly are you trying to do?

1 Like

I have a small fan that needs to extract hot air from a box. At my command and/or at a temperature (which I receive from an esphome with a DHT22 sensor) I have to activate the fan based on a value that I can modify via the

“input_datetime.fun”

entity that I have already configured in lovelace.
In my reasoning I believed that operating

-load the datatime value into the timer
-start the timer

it was the best thing to do

  - service: timer.start
    target:
      entity_id: timer.timer_fun
    data:
      duration: "{{ state_attr('input_datetime.fun', 'timestamp') }}"

Thanks 123 Taras. Now I can’t count the times you helped me.
Now everything works as I wanted.
If it doesn’t bother you, I would like to ask you if it is possible to display the remaining time backwards on the timer.fun entity.