Problem with climate automation

Hoping someone could give me a quick hand. I am setting up an automation to set my climate to a temperate pulled from a sensor at a specific time, also pulled from a sensor. Both the time and the temperature come from an input number. I have verified that the sensors return back correct values, so I am assuming it is my automation that has the issue, most likely with the action. Thanks for any help!

input_number:

ac_morning_hour:
  name: Hour
  icon: mdi:timer
  initial: 9
  min: 5
  max: 12
  step: 1
  mode: slider
ac_morning_minutes:
  name: Minutes
  icon: mdi:timer
  initial: 30
  min: 0
  max: 55
  step: 5
  mode: slider
ac_morning_temperature:
  name: Morning temperature
  icon: mdi:temperature-fahrenheit
  initial: 76
  min: 68
  max: 80
  step: 1
  mode: slider

sensors:

  • platform: template
    sensors:
    ac_morning_time:
    friendly_name: ‘A/C morning time’
    value_template: ‘{% if states.input_number.ac_morning_hour.state| length < 4 %}0{{ states.input_number.ac_morning_hour.state | int }}{% endif %}{% if states.input_number.ac_morning_hour.state| length > 3 %}{{ states.input_number.ac_morning_hour.state | int }}{% endif %}:{% if states.input_number.ac_morning_minutes.state | length < 4 %}0{{ states.input_number.ac_morning_minutes.state | int }}{% endif %}{% if states.input_number.ac_morning_minutes.state | length > 3 %}{{ states.input_number.ac_morning_minutes.state | int }}{% endif %}’

Automation:

  • id: Set_thermostat_morning
    alias: ‘Set thermostat morning’
    trigger:
    platform: template
    value_template: ‘{{ now().strftime(“%H:%M”) == states.sensor.ac_morning_time.state }}’
    action:
    • service: climate.set_temperature
      data_template:
      entity_id: climate.thermostat
      temperature: ‘{{ states.sensor.ac_morning_temperature.state }}’

From the docs (albeit not worded very well):

What this is saying is that template triggers are only evaluated when one of the entities referenced in the template change state. In your template, the only entity is sensor.ac_morning_time. now() (or time in general) is not an entity, so it does not generate state changes, and hence, by itself, will not cause the template to be evaluated, meaning it cannot cause the automation to trigger.

Bottom line, you need to define and use this component:

Thank you, @pnbruckner, that worked.

I must have missed this as a change to the system, as previously I used to have a TV timer configured to turn my TV off at night, which was configured the same way. I stopped using it, and went a different route to turn my TV off, so never realized it was no longer valid.

I updated the trigger to be:

trigger:
platform: template
value_template: ‘{{ states.sensor.time.state == states.sensor.ac_morning_time.state }}’

and I was able to fire off the automation as expected.

1 Like