Automation Error - Sensor Value


Why is this not working?

- alias: Holiday Radiators
    # initial_state: 'off'
      platform: time
      at: '{{ states.sensor.holidaytime.state }}'
      condition: state
      state: 'on'
    - service: switch.turn_on
      entity_id: group.radiators
    - delay: '{{ states.input_number.hours.state | int }}:00'
    - service: switch.turn_off
      entity_id: group.radiators


- platform: template
        friendly_name: 'Time'
        value_template: '{{ "%0.02d:%0.02d" | format(states("input_number.holidayhours") | int, states("input_number.holidaymins") | int) }}'


At the very least, trigger, condition and action do not line up with alias. Also, the time trigger’s at parameter does not accept a template.

the yaml spacing works fine. It s obviously as you have said the template isnt accepted? Do you have any suggestions?

See the Time & Date Sensor. If you enable the time option, a sensor named sensor.time will be created whose state will be the current time as a string that is formatted HH:MM, just like your sensor.holidaytime appears to be, and updates once a minute. Then you can use a Template Trigger like this:

      platform: template
      value_template: "{{ is_state('sensor.time', states('sensor.holidaytime')) }}"

I’m not entirely sure that will work. I think sensor.time updates minutely on an arbitrary second. Might have to strfttime it, I could be wrong. I’m basing it off the code, not personal use.

Both sensors in the template only provide hours and minutes in the same format. So it shouldn’t matter on what second sensor.time changes, as long as it changes for every minute.

I’m thinking of input_datetime

I just did the same thing yesterday! :rofl:

1 Like

does that mean the automation will fire when sensor.time is equal to sensor.holidaytime?

Basically, yes. Whenever either sensor.time or sensor.holidaytime change state (either their state string, or any of their attributes, change), the template will be evaluated. If it’s true – i.e., if sensor.time’s state string is exactly the same as sensor.holidaytime’s state string – then the trigger will “fire.”