Set thermostat temperature from one of 2, based on state attribute of another

Well I don’t know if it makes any difference and we are just clutching at straws at this point - but - it looks to me like there is an extra space before |- on the temperature: line. Whether that upsets YAML or not I don’t know. I still don’t know why it’s not happy to let you use >- which is how I always do it, otherwise you risk having newlines in your Jinja which will upset services that are expecting a number.

Again, thanks for your diligence to get this working!!

It turns out that your last suggestion of using the double brackets with your other syntax was correct. The problem I was having was the live value of the temperature was not being accessed from the AC unit (the “climate.bedford_living_room”), because the Cielo Home integration it was getting info from had failed. However, the integration author (bodyscape) quickly fixed and updated the integration so now it works. My automation was not complaining of the syntax, it was just getting a null value.

I guess I’ll need to first set the temperature value to 0 in Hubitat before triggering this HA automation, and if it’s still zero after it’s done, then the AC unit can’t be accessed. This is probably best since there will be other instances where the data can’t be accessed (network or server failure).

Cheers to all, have a great holiday!

Here’s the final automation:

alias: Current room temperature to be read by Hubitat
service: climate.set_temperature
target:
  device_id: 01b0d4df48ec86f84488cafa28e80a0f
  entity_id: climate.ac_currenttemp
data:
  temperature: |-
    {% if is_state("sensor.ac_unit_id_temperature" , '0') %} 
      null
    {% elif is_state("sensor.ac_unit_id_temperature" , '1') %} 
      {{ states.climate['bedford_living_room'].attributes.current_temperature }}
    {% elif is_state("sensor.ac_unit_id_temperature" , '2') %} 
      "{{ states.climate['bedford_tv_room'].attributes.current_temperature }}
    {% elif is_state("sensor.ac_unit_id_temperature" , '3') %} 
      {{ states.climate['bedford_bed_room'].attributes.current_temperature }}
    {% elif is_state("sensor.ac_unit_id_temperature" , '4') %} 
      {{ states.climate['bedford_peggy_s_office'].attributes.current_temperature }}
    {% elif is_state("sensor.ac_unit_id_temperature" , '5') %} 
      {{ states.climate['bedford_jim_s_office'].attributes.current_temperature }}
    {% elif is_state("sensor.ac_unit_id_temperature" , '6') %} 
      {{ states.climate['samoset_living_room'].attributes.current_temperature }}
    {% elif is_state("sensor.ac_unit_id_temperature" , '7') %} 
      {{ states.climate['samoset_bedroom'].attributes.current_temperature }}
    {% endif %}