Write current time as text to a time helper “input_datetime.heizstart1”

Hello community,

I’ve tried a lot of things in the meantime, but without success. What am I trying to achieve?
I have a time value that I read as a string from a heat pump. The format is “08:00.”
I want to write this time to a time helper “input_datetime.heizstart1,” but unfortunately, I can’t get it to work.

This is my code:

  heizzeit1_auslasen_script:
    alias: "open3e Heizzeit1 auslesen script"
      {% set time_string = strptime(states('sensor.680_762_mixeronecircuittimescheduletuesday_schedules_0_start') + ':00', '%H:%M:%S', none)  %}
      {% set input_datetime.heizstart1 = time_string %}

Thanks for your help.
Christopher

Examples are documented here:
Input Datetime - Home Assistant

I have read and tried this several times, but I don’t understand it.
How do I convert a string variable with the format “08:00” into a time helper?

Not exactly sure where you are stuck but I assume you created the input_datetime helper?

If so then the ‘action’’ (see link) shows you how to update it
You need to provide the correct format e.g. if you only want the time then it needs to be “HH:MM:SS” (as per the link)
I suggest that you use the action to test it out.

Example:

  1. Helper

  2. Action

  1. result:

It looks like you are trying to create a Script, but you have not included the configuration variable sequence (or parallel) or a list of actions… both of which are required for scripts:

Instead you have dropped in a Jinja template without using any recognized YAML structure.

The way you set a value to an input datetime, is to use the action input_datetime.set_datetime:

Input Datetime - Actions - input_datetime.set_datetime

Lower down in the Examples section you will find examples for how to set up actions for each of the different varieties of Input Datetime entities i.e. date, time, date & time.

I created a helper called “input_datetime.heizstart1” and wrote an action based on your example, but unfortunately it doesn’t work.

I couldn’t find any examples of how to transfer the value of a sensor to a datetime helper.

Use the template session and verify what the “states(…)” shows, it needs to be in the proper format … as per the documentation. Try hard-coded date (or time or datetime) first to understand that part before using a template. And a template needs to be in “{{ … }}”

my example (different template)

When I assign a string under time: "01:01:00", it works.
In the template, {{states(‘sensor.680_761_mixeronecircuittimeschedulemonday_schedules_0_start’)+‘:00’}} returns the result “07:00:00”, which is also correct.

But how do I bring these two worlds together?

By putting what you have tested in the template section in the action within (!) double quotes “{{…}}”

Thank you very much for your support, it’s working now.

1 Like

HA is really great an super flexible … which comes with some (quite some) challenges. Until now, HA and underlying config allows me to control anything I like…not always without (more than above complex) code. It is one system that could rule-them-all :slight_smile: