Setting input_datetime.set_datetime helper

Hi All,
I am struggling to find a way to set a time to my helper…
I have set up the datetime helper as TIME only and tried to make sure my code also outputs time…

service: input_datetime.set_datetime
target:
  entity_id: input_datetime.time_to_sell
data:
  value: >
    {{ as_timestamp(strptime(([states('sensor.nordpool_most_expensive_times_2'),
    states('sensor.nordpool_2nd_most_expensive_time'),
    states('sensor.nordpool_3rd_most_expensive_time')] | min), '%H:%M'))|
    timestamp_custom('%H:%M:%S', true) }}

the error seems to point to not giving correct input - and this is hh:mm:ss format…

Executed: 3 May 2024 at 14:20:22
Error: must contain at least one of date, time, datetime, timestamp.
Result:

params:
  domain: input_datetime
  service: set_datetime
  service_data:
    value: '18:00:00'
    entity_id:
      - input_datetime.time_to_sell
  target:
    entity_id:
      - input_datetime.time_to_sell
running_script: false

Again I would need some help figuring this out…

If you run your template through Developer Tools > Template, does it indeed return a timestamp?

{{ as_timestamp(strptime(([states('sensor.nordpool_most_expensive_times_2'),
    states('sensor.nordpool_2nd_most_expensive_time'),
    states('sensor.nordpool_3rd_most_expensive_time')] | min), '%H:%M'))|
    timestamp_custom('%H:%M:%S', true) }}

result is 18:00:00

You need to use time, not value in your service call.

service: input_datetime.set_datetime
data:
  time: "18:00:00"
target:
  entity_id: input_datetime.time_to_sell
1 Like

Great advice !

Just had to replace value with time and it worked!

Thankyou!

1 Like