Climate match temperature + 2deg

Hi I have a template like this which works perfectly. Except I would like to change it so that the midea_ac is at the same temperature as the climate living room +2deg?

service: climate.set_temperature
data_template:
  entity_id:
    - climate.midea_ac_d9610200000e
  temperature: '{{ state_attr(''climate.living_room'' , ''temperature'')}}'
service: climate.set_temperature
data_template:
  entity_id:
    - climate.midea_ac_d9610200000e
  temperature: '{{ state_attr(''climate.living_room'' , ''temperature'') + 2 }}'

This works because unlike states, which are always strings, attributes can be other types, like numbers as in this case. If it wasn’t a number you would have to convert it to one with either the floating point |float or |int integer filter, like this:

  temperature: '{{ states(''sensor.some_temperature'')|float(0) + 2 }}'

The (0) in brackets is what |float produces if the sensor has some value that can’t be converted to a number, like if the state was 'unknown' because it was off-line.

1 Like

Works perfectly thank-you