Unable to set current time on input_datetime

I have an input_datetime entity that I would like to populate with the current time through an automation.

To test, I tried setting the state manually in the Developer Tools but I’m unable to.

1

But this results in this error:

input_datetime/set_datetime must contain at least one of date, time, datetime, timestamp.

I don’t think you need the data template, I think you would just put:

value: '{{ now().strftime("%H:%M") }}'

Same error I’m afraid :frowning:

Also tried this with no luck

time: '{{ now().strftime("%H:%M") }}'

Have you specified input_datetime.time correctly, https://www.home-assistant.io/integrations/input_datetime/?

I use this line to set the time one hour from now.

      - service: input_datetime.set_datetime
        entity_id: input_datetime.stue_pa
        data:
          datetime: '{{ (now().strftime("%s")|int +3600|int) |timestamp_custom("%Y-%m-%d %H:%M:%S", false) }}'

So trying changing time with datetime and see if that works first.

Still the same error :frowning:

Just to verify and I am not sure if it is relevant for this entity, but have you activated time and date in Home Assistant?

I have this under group:

  time_and_date:
    name: Time and Date
    entities:
      - group.time_date_sensors
  time_date_sensors:
    name: Time Date
    entities:
      - sensor.date
      - sensor.time

And your input_datetime.time is specified to have both time and date like this?

  kamera_av:
    name: Kamera av
    has_date: true
    has_time: true
    icon: mdi:clock-in

I have the time_date platform set up, yes.

my input_datetime only has time activated as I’m not interested in the date.

Looks like the template doesn’t like this input, so perhaps report it as a bug.

But I just check it in the automation and the below works for me.

      - service: input_datetime.set_datetime
        entity_id: input_datetime.matbodvifte_av
        data:
          time: '{{ now().strftime("%H:%M") }}'

You’re right, it works perfectly in automations, just tested.
Thanks :smiley: