I have a generic thermostat which is to control a 10 relay Z-Wave device.
How do I get the target_temp from the actual thermostat? I tried using template but HA complained it needed an integer:
target_temp:
friendly_name: "Target Temp"
unit_of_measurement: 'C'
value_template: "{{ state_attr('climate.battery_operated_thermostat_thermostat_mode', 'temperature') }}"
- platform: generic_thermostat
name: Study
heater: switch.relay_control_current_value_2
target_sensor: sensor.battery_operated_thermostat_air_temperature
min_temp: 15
max_temp: 25
target_temp: sensor.target_temp
cold_tolerance: 0.3
hot_tolerance: 0
min_cycle_duration:
seconds: 5
keep_alive:
seconds: 15
initial_hvac_mode: "off"
away_temp: 16
precision: 0.1
When you view that entity in dev tools what does it show?
It shows 28 (the target_temp) I set on the physical thermostat
metbril
(Robert 🇳🇱🇪🇺)
February 21, 2021, 6:41pm
4
Try to add | int
to your value template
value_template: "{{ state_attr('climate.battery_operated_thermostat_thermostat_mode', 'temperature') | int }}"
Good idea, but didn’t work. I have a theory that the reason is that it doesn’t resolve the variable correctly. Maybe i need some escape chars?
Have you tried pasting that in the template sandbox?
Yes just ran it through and all the variables resolve correctly.
Output:
target_temp:
friendly_name: “Target Temp”
unit_of_measurement: ‘C’
value_template: “24”
Is that with the int filter?
Looks like a string at the moment
This was the input:
target_temp:
friendly_name: "Target Temp"
unit_of_measurement: 'C'
value_template: "{{ state_attr('climate.battery_operated_thermostat_thermostat_mode', 'temperature') | int}}"
Same output. Does it make sense to input the portion of the config where the generic thermostat is set?
Well I did and the result was : This template does not listen for any events and will not update automatically.
Maybe this has something to do with the problem?
This is the actual error message from the log:
Invalid config for [climate.generic_thermostat]: expected float for dictionary value @ data[‘target_temp’]. Got ‘sensor.target_temp’. (See ?, line ?).
It seems it doesn’t resolve sensor.target_temp
1 Like
Try putting the template instead of the sensor in that line in the thermostat.
If that fails
Can you instead use an automation, triggers when the physical thermostat is changed to set the virtual thermostat to the same temperature?
Yeah that could be a workaround. But it produces a bit of overhead instead of using the actual methods included, also maybe a slight delay. I’ll see if I can debug some more. I do appreciate your time
Did you try putting the template in place of the sensor entity?
Like this?
- platform: generic_thermostat
name: Living Room Gen Therm
heater: switch.relay_control_current_value_2
target_sensor: sensor.battery_operated_thermostat_air_temperature
min_temp: 15
max_temp: 30
target_temp: {{ state_attr('climate.battery_operated_thermostat_thermostat_mode', 'temperature') | float }}
cold_tolerance: 0.3
hot_tolerance: 0
min_cycle_duration:
seconds: 5
keep_alive:
seconds: 15
initial_hvac_mode: "heat"
away_temp: 16
precision: 1
Just had a thought, remove the quote marks from the template
target_temp:
friendly_name: "Target Temp"
unit_of_measurement: 'C'
value_template: {{ state_attr('climate.battery_operated_thermostat_thermostat_mode', 'temperature') | float }}
This returns a float in the template engine
If it can’t resolve the sensor state, then try putting just this template in that line in the climate config