Automation start at time from inputer_number

Hello,

I need some help with my automation. I try to start my vacuum at a time which I set with an input_number slider. The slider just adjust the hour, so I compare the current hour with the slider.

- id: '1558202812387'
  alias: Staubsaugen Uhrzeit
  trigger:
  - platform: template
    value_template: '{{ now().hour == (states("input_number.uhrzeit_staubsauger")
      | int )}}'
  condition: []
  action:
  - entity_id: vacuum.rockrobo
    service: vacuum.start

The template works fine. I tested it in the “developer tool / template”.
The template is “true” if the current hour matches the value of the input_number.

Somehow the automation doesn’t start, so it seems to be a problem with the trigger.

I hope some of you can help me.
Thank you in advance.

The problem is that you don’t have an entity that changes in your trigger template.

You need to setup the time sensor and then use sensor.time instead of now(). The time sensor changes state every minute and therfore the template will be evaluated every minute.

I would use the time_pattern trigger every hour and a condition that matches the input number.

There is an input_datetime which I suggest you use. Way easier than a number! Gives you a cool date/time picker in the UI which is useful.

And yes, you’ll need a time_sensor setup so you can trigger based on it.

  trigger:
    - platform: template
      value_template: "{{ states('sensor.time') == (states.input_datetime.vacuum_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"

That is how I trigger an automation to happen compared to my input_datetime.

@Burningstone Thank you, that was my mistake.

I found the solution.

- id: '1558202812387'
  alias: Staubsaugen Uhrzeit
  trigger:
  - platform: template
    value_template: '{{ states("sensor.time").split('':'')[0] | int == (states("input_number.uhrzeit_staubsauger") | int )}}'
  condition: []
  action:
  - entity_id: vacuum.rockrobo
    service: vacuum.start

@VDRainer @jocnnor Also thank you for the alternative way for my automation.