I have 2 thermostats, named ‘living_room’ and ‘tv_room’. The returned temperature is saved in ‘climate.ac_currenttemp’, which happens to be a virtual thermostat in Hubitat Integration.
However, I want this automation to return the temperature of either ‘living_room’ OR ‘tv_room’ based on the value of another device (another virtual thermostat in Hubitat). That device is identified as: “sensor.ac_unit_id_temperature”.
So I try this syntax in my automation, and it does not work:
The error returned is: “expected float for dictionary value @ data[‘temperature’]. Got None”
Any idea? Not sure why it works in a singular return value but not in the template. I’m very new to YAML, so I’m sure it’s just a syntax or it needs a pipe to convert the number. And sorry if my code is not formatted correctly in this post, I was getting the “Unformatted Code Warning”. Thanks.
{% set t = 'climate.living_room' if is_state('sensor.ac_unit_id_temeprature','1') else 'climate.tv_room' %}
{{ state_attr(t,'current_temperature')|float(0) }}
Can you post your YAML again but this time -
Pressing the button that looks like this </> so it formats properly just so we can check for any other odities.
I have tested this in the template editor, and get errors until I change it to devices I actually have. Which is leading me to wonder what exactly sensor.ac_unit_id_temperature is showing?
sensor.ac_unit_id_temperature is a virtual thermostat on my Hubitat that I’m using to identify the parameters of each AC unit in Cielo Home that I want to set. I’m sure there’s a more elegant method, but I’m trying to set values on the Hubitat side and then trigger HA to see these values and use them to set the climate entities (my AC units).
As mentioned above, this same virtual thermostat is used in if-else logic to identify the entity_id. So it should also work for determining what AC unit temperature should be set in climate.ac_currenttemp.
Well, it did happen to be something other than 1 or 2, but I just set it to 1 and the template editor shows it as 1, and the automation still fails. Regardless of the value being compared, the automation does not like the syntax, so it won’t even run.
Why can the same syntax to determine entity_id not also work for temperature, like this: