Okay, I think I made some progress in understanding where things are going wrong, but I am not sure what to do about it.
I tried using the HA template editor (didnât previously know that was available, or that was what it was for I guess). You are correct @turboc, there is no to_state or a from_state. And, in fact when I put
{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}
into the template editor it returns the very error I am seeing in the logs:
Error rendering template: UndefinedError: 'trigger' is undefined
So I started playing around, just to see if I could hit on, figure out, stumble into, the code that would return the temperature set point. After several iterations, I hit it:
{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}
That returned the set point temperature whether I set it in HA or at the thermostat, it returned the correct set point value. S I then, to test out other values, tried:
{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.fan_mode }}
{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.operation_mode }}
Both returned the correct values. So that would seem to be the formatting to get the information. So the code:
value_template: '{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'
apparently needs to be changed but I am not sure how. How do I write that so that it is comparing the thermostat temperature set point, to the HA input slider temperature set point and updating HA if there is a difference?
This is the code that does the comparison:
- alias: 'Set input_slider based on thermostat temperature'
trigger:
platform: state
entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
condition:
condition: template
value_template: '{{ trigger.to_state.attributes.temperature != trigger.from_state.attributes.temperature }}'
action:
service: input_slider.select_value
entity_id: input_slider.hvac_target_temp
data_template:
entity_id: >-
{% if is_state('input_select.hvac_operation_mode', 'Heat') %}
'{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}'
{% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
'{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}'
{% endif %}
I ran the command:
sudo journalctl -fu home-assistant
So that I could watch the messages going back and forth. I then went to the thermostat and changed the temperature from 75* to 73* and I saw this come across:
Dec 31 19:45:55 HARPi3 hass[21176]: INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state climate.trane_model_tzemt400ab32maa_heating_1_34_1=Heat; unit_of_measurement=°F, operating_state=(âHeatingâ,), fan_mode=Auto Low, friendly_name=Heating Set Point, fan_list=[âOn Lowâ, âAuto Lowâ], max_temp=95.0, operation_list=[âAux Heatâ, âOffâ, âCoolâ, âHeatâ, âAutoâ], fan_state=Idle, current_temperature=73.0, node_id=34, min_temp=44.6, operation_mode=Heat, temperature=75.0 @ 2016-12-31T19:42:34.956696-06:00>, new_state=<state climate.trane_model_tzemt400ab32maa_heating_1_34_1=Heat; unit_of_measurement=°F, operating_state=(âHeatingâ,), fan_mode=Auto Low, friendly_name=Heating Set Point, fan_list=[âOn Lowâ, âAuto Lowâ], max_temp=95.0, operation_list=[âAux Heatâ, âOffâ, âCoolâ, âHeatâ, âAutoâ], fan_state=Idle, current_temperature=73.0, node_id=34, min_temp=44.6, operation_mode=Heat, temperature=73.0 @ 2016-12-31T19:42:34.956696-06:00>, entity_id=climate.trane_model_tzemt400ab32maa_heating_1_34_1>
So the message is getting to HA and I can, in fact, see it update in HA, but, the input slider does not update.
That is where I currently stand. I kind of see the problem, I just have no idea how to fix it. How to get HA to update that input slider to reflect any manual changes at the thermostat itself.