I noticed a typo in my above example … sorry - try pasting this into the developer testing area:
"{{ states.sensor.hvac_setpoint.state }}"
I noticed a typo in my above example … sorry - try pasting this into the developer testing area:
"{{ states.sensor.hvac_setpoint.state }}"
On it! Let me set everything back up. I wiped out or commented out much of it so I would stop getting the errors.
Okay, I put that in the developer testing and get the return of “Unknown”. Which I know is not good, but not sure how to fix it. I am signed into Gitter now also.
@automateit for completeness, I am going to post my config as it is now, with my best effort and utilizing your config, then I am going to have to comment everything out as my error log is filling up with:
homeassistant.components.sensor.template: UndefinedError: 'None' has no attribute 'attributes'
INPUT SLIDER
###
### hvac_target_temp input_slider used in the thermostat-related
### automation rule to set the thermostat temperature based on input
### from this slider
###
hvac_temp:
name: 'Temperature Set Point'
min: 65
max: 90
step: 1
initial: 72
unit_of_measurement: '°F'
SENSOR
- platform: template
sensors:
hvac_setpoint:
value_template: "{{ states.climate['climate.trane_model_tzemt400ab32maa_heating_1_34_1'].attributes.temperature }}"
friendly_name: "Heating Setpoint"
AUTOMATION
### Set the thermostat temperature based on the setting of the Input Slider.
- alias: 'Set Temp Setpoint'
trigger:
- platform: state
entity_id: input_slider.hvac_temp
action:
- service: climate.set_temperature
data_template:
entity_id: >-
{% if is_state('input_select.hvac_operation_mode', 'Heat') %}
climate.trane_model_tzemt400ab32maa_heating_1_34_1
{% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
climate.trane_model_tzemt400ab32maa_cooling_1_34_2
{% endif %}
temperature: '{{ states.input_slider.hvac_temp.state | int }}'
### Set the slider position based on the thermostat set point. This is in
### case the temperature is manually set at the thermostat itself. We
### want any such changes reported back to HA and reflected in the slider
### value.
- alias: Set Slider Setpoint
trigger:
- platform: state
entity_id: sensor.hvac_setpoint
action:
service: input_slider.select_value
data_template:
entity_id: input_slider.hvac_temp
value: '{{ states.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature | int }}'
### Sets the thermostat fan_mode when the hvac_fan_mode input_select
### is changed
- alias: 'Set Thermostat Fan Mode'
trigger:
platform: state
entity_id: input_select.hvac_fan_mode
action:
service: climate.set_fan_mode
entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
data_template:
fan_mode: >-
{%- if is_state('input_select.hvac_fan_mode', 'Auto') -%}
Auto Low
{%- elif is_state('input_select.hvac_fan_mode', 'On') -%}
On Low
{%- endif -%}
### Sets the thermostat operation_mode when the hvac_operation_mode
### input_select is changed
- alias: 'Set Thermostat Operation Mode'
trigger:
platform: state
entity_id: input_select.hvac_operation_mode
action:
service: climate.set_operation_mode
entity_id: climate.trane_model_tzemt400ab32maa_cooling_1_34_2
data_template:
operation_mode: "{{ states('input_select.hvac_operation_mode') }}"
I have three entities that show up with my thermostat:
climate.trane_model_tzemt400ab32maa_heating_1_34_1
climate.trane_model_tzemt400ab32maa_cooling_1_34_2
sensor.trane_model_tzemt400ab32maa_temperature_34_1
I will try some things out in the meantime, but basically, the error I posted above or some variant thereof, is what I keep getting. I can use the input slider in HA to change the thermostat, but when I change the temp at the thermostat, the input slider does not update.
Just curious, are you sure that the ‘Set Slider Setpoint’ is actually being triggered?
Nope, and, unfortunately, I do not know exactly how to check that.
An easy way would be to add another action that sends you an email or some other type notification. You can even just set an additional action to turn a light on and off in a room you’re in to make sure that it’s running.
You need to make the template sensor like so:
- platform: template
sensors:
hvac_setpoint:
value_template: "{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}"
friendly_name: "Heating Setpoint"
I’d also DELETE: unit_of_measurement: '°F'
from the input_slider; it should default to that
Alright, let me give that a shot and see how far I get. Stand-by, we launch in 3…2…1…
Also, nice use of the service template…I currently have 2 sliders for heating and cooling, so that is cool if you can get that to work…try this for it:
#######################
### Set the thermostat temperature based on the setting of the Input Slider.
- alias: 'Set Temp Setpoint'
trigger:
- platform: state
entity_id: input_slider.hvac_temp
action:
- service: climate.set_temperature
data_template:
entity_id: >-
{% if is_state('input_select.hvac_operation_mode', 'Heat') %}
climate.trane_model_tzemt400ab32maa_heating_1_34_1
{% elif is_state('input_select.hvac_operation_mode', 'Cool') %}
climate.trane_model_tzemt400ab32maa_cooling_1_34_2
{% endif %}
temperature: '{{ trigger.to_state.state | int }}'
Okay, that was a no-go also. I go to the thermostat and change the temperature there and the slider does not track/update.
Also, I cannot take credit for the service template and unfortunately I do not recall where I saw that at initially to give proper credit. It did not work out of the box for me and I had to ‘fiddle’ with it some, but at least that portion of it all is working. If I could get the slider to work I would have a decently functioning thermostat that I could write some automations against.
What I am seeing is the sensor is showing a state of “unknown”.
One other thing … if you go to the list of entities, how is temp reported? In other words, mine shows the temperature as an “attribute” and I therefore must use: "{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}"
For your situation, if you show a value (say, 70 degrees) as the state, you can likely make that sensor like so:
- platform: template
sensors:
hvac_setpoint:
value_template: "{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.state }}"
friendly_name: "Heating Setpoint"
The difference is in how the state is reported…so you need to grab the temperature value…just CTRL+F in the list of entities and search for temp until you see that as a either an attribute or state value…you are SUPER close dude…send me some screen shots of the entity reporting and I can build it
Let me get some screen shots in a few after I try your last couple of suggestions.
This:
"{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.state }}"
=Heat
This:
{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}
=Current Setpoint Temp
Also of note … look way down that list for a SENSOR value for the thermostat, which may report the temp…Mine has the following:
sensor.2gig_technologies_ct101_thermostat_iris_temperature_18_1
With Values of:
69.5 node_id: 18
battery_level: 81
friendly_name: Downstairs Temp
unit_of_measurement: °F
If yours is similar, then it will be as follows:
- platform: template
sensors:
hvac_setpoint:
value_template: "{{ states.sensor.trane_model_tzemt400ab32maa_heating_1_34_1.state }}"
friendly_name: "Heating Setpoint"
…be sure to edit that entity_ID to match your Trane…value
if you get the “Heat Setpoint” value to return the temp, as in my last post, then use this to return the slider:
### Set the slider position based on the thermostat set point. This is in
### case the temperature is manually set at the thermostat itself. We
### want any such changes reported back to HA and reflected in the slider
### value.
- alias: Set Slider Setpoint
trigger:
- platform: state
entity_id: sensor.hvac_setpoint
action:
service: input_slider.select_value
data_template:
entity_id: input_slider.hvac_temp
value: '{{ states.sensor.hvac_setpoint | int }}'
Okay, we are almost there. The slider is now updating. Yaaaaaaay! That’s the good news.
The bad news is that it updates to the current temperature reading (air temp.) not the setpoint.
That should be an easy fix … check that last post
You need the SENSOR value if you can
…good news is that this is likely the most difficult thing you’ll do (HVAC and Locks are tough)
NOTE - You may run into issues when you switch to COOLING…you’ll likely need another fancy service template to make it 100% but let’s get this working first…I may adopt/steal that service template myself, in which case I;ll be of more help then
Okay, when I changed to this:
value: '{{ states.sensor.hvac_setpoint | int }}'
The slider stopped updating when the thermostat was changed.
When I used:
value: '{{ states.sensor.trane_model_tzemt400ab32maa_temperature_34_1.state | int }}'
The slider updated, but it acted like it was updating to the current room temp and not the actual setpoint.
And yes, this have been a bit frustrating and yes I have three zwave locks that are still sitting on my Vera controller because I cannot change the user codes in HA.
I think this is what gets a bit strange or confusing.
This:
sensor.trane_model_tzemt400ab32maa_temperature_34_1
Reports the current air temperature, not the setpoint
This:
climate.trane_model_tzemt400ab32maa_cooling_1_34_2
And this:
climate.trane_model_tzemt400ab32maa_heating_1_34_1
Only report the modes (i.e. Heating or Cooling)
I worked this out at one point using the developer area to see where all the attributes were and how to pick them out, but that has been several weeks ago and I go so frustrated I think I tossed all my notes, LOL
This:
{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature }}
Returns the current temperature setpoint
when I change it to:
{{ states.climate.trane_model_tzemt400ab32maa_cooling_1_34_2.attributes.temperature }}
It returns the cooling setpoint
So I assume, that I need to change:
value: '{{ states.sensor.hvac_setpoint | int }}'
To:
value: '{{ states.climate.trane_model_tzemt400ab32maa_heating_1_34_1.attributes.temperature | int }}'
Yes?