How to use current_temperature in automation

Hi all.

I’m trying to have my radiator thermostats match the temperature of our Mitsubishi heater. However I can’t get it to work.

- id: set_radiator_temperature_in_living_room
  alias: Set radiator temperature in living room
  trigger:
  - platform: template
    value_template: '{{ climate.heater.current_temperature }}'
  action:
  - service: climate.set_temperature
    data_template:
      temperature: '{{ climate.heater.current_temperature }}'
      entity_id: climate.radiator

Can anyone tell me what I’m doing wrong?

  • Go to Developer Tools > States
  • Find climate_heater in the list
  • Look in the Attributes column and you’ll current_temperature listed there,
  • current_temperature is an *attribute* of climate_heater, not its state.

Try this:

- id: set_radiator_temperature_in_living_room
  alias: Set radiator temperature in living room
  trigger:
  - platform: template
    value_template: "{{ state_attr('climate.heater', 'current_temperature') > 0 }}"
  action:
  - service: climate.set_temperature
    data_template:
      temperature: "{{ trigger.to_state.attributes.current_temperature }}"
      entity_id: climate.radiator

The automation uses a Template Trigger. This kind of trigger must have a template that evaluates to true or false. The template I’ve created simply checks if the current_temperature is greater than zero. Whenever current_temperature changes, the template is evaluated (and will evaluate to true as long the temperature is above zero).

In the action, the temperature is set to whatever value caused the automation to be triggered.

1 Like

@123 hey your idea behind is amazing! In my head it works but in the automation it does not.

Would you mind have a look at this automation I reused your code above?

# The automation uses a Template Trigger. This kind of trigger must have a template that evaluates to true or false. The template I’ve created simply checks if the current_temperature is greater than zero. Whenever current_temperature changes, the template is evaluated (and will evaluate to true as long the temperature is above zero).
- id: set_radiator_temperature_in_labor
  alias: Set radiator temperature in labor
  trigger:
  - platform: template
    value_template: "{{ state_attr('climate.heizkorper_labor', 'current_temperature') > 0 }}"
  action:
  - service: climate.set_temperature
      temperature: "{{ trigger.to_state.attributes.current_temperature }}"
      entity_id: sensor.atc_5e8a1d_arbeitszimmer_rob_temperature

Thank you so much for any hint how I can set the external sensor to this climate entity.

Maybe it’s because it doesn’t work the way you think it does.

It will trigger the moment the temperature is greater than zero and never trigger again until the temperature first decreases below zero and then rises above it. It’s the transition from false to true that causes the trigger. If the temperature never decreases below zero, it will never trigger again (or at least not until the next restart).

@123 ahh thank you I did not read that out of the code.

I changed it to somewhat I assume makes sense. If the temperature on the heater is higher than the external sensor it should run the automation. Assumed this triggers everytime one sensor state chages.

- id: set_radiator_temperature_in_labor
  alias: Set radiator temperature in labor
  trigger:
  - platform: template
    value_template: "{{ state_attr('climate.heizkorper_labor', 'current_temperature') | float > state_attr('sensor.atc_5e8a1d_arbeitszimmer_rob_temperature') | float }}"

  action:
  - service: climate.set_temperature
    data_template:
      temperature: "{{ trigger.to_state.attributes.current_temperature }}"
      entity_id: sensor.atc_5e8a1d_arbeitszimmer_rob_temperature

Debug Error from Home-Assistant

Error: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'

Could you help me out Taras what is wrong with my code? Have a nice evening.