Modify trigger time with input_number

Hi there.

I’m trying to modify the Trigger value (Time) of an automation, from an Input-number in the front end.

Example:

Th input number goes like:

input_number:
  start_time:
    name: Start Time
    initial: 4
    min: 0
    max: 23
    step: 1

And the automation is:

  trigger:
  - at: '{{ states.input_number.start_time.state | int }}:00:00'
    platform: time
  condition: []
  action:
  - data:
      entity_id: switch.plug_151515151515
    service: switch.turn_on

But this trigger returns me an error. I just want to modify the hours, not the minutes or seconds.

Someone knows how i can get this working?

Thanks!

Well, this has been answered many times on this forum. The docs should probably be updated to add an example of how to do this. :slight_smile:

Anyway, the time trigger’s at parameter does not accept a template. So you should enable the Time sensor:

sensor:
  - platform: time_date
    display_options:
      - 'time'

Then use a template trigger:

trigger:
  platform: template
  value_template: >
    {{ states('sensor.time').split(':')[0]|int ==
       states('input_number.start_time')|int }}

It’s funny that you say this. The docs do have it for a input_datetime, just not an input_number.

1 Like