Hello Community!
So I got 3 Z-Wave thermostats which are working beautifully with Home Assistant. I am trying to automate the thermostats that if either the fist floor or the second floor thermostats turn to operating_state: Heating than the basement thermostat should just turn on. And when both fist floor and second floor thermostats change their operating_state to idle then the basement thermostats turns off. Below are my states for the thermostats:
[climate.first_floor_heat]
min_temp: 45
max_temp: 95
temperature: 75
operation_mode: heat
operation_list: heat,off
node_id: 19
value_index: 1
value_instance: 1
value_id: 72057594361987090
operating_state: Idle
friendly_name: First Floor Heat
supported_features: 129
Its pretty much the same for [climate.basement_heat] and for [climate.second_floor_heat]. How can I go about this? Any help is greatly appreciated.
Looking at the code I donât think zwave climate entities support climate.turn_on and climate.turn_off, but I could be wrong. (Of course, âsupported_features: 129â seems to agree. 129 corresponds to setting target temperature, and setting operation mode. It does not indicate that turning on and off is supported.) I think you may need to use the climate.set_operation_mode service instead. Assuming that is the case, then something like this might work for you:
automation:
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat, climate.second_floor_heat
action:
service: climate.set_operation_mode
entity_id: climate.basement_heat
data_template:
operation_mode: >
{% if is_state_attr('climate.first_floor_heat', 'operating_state', 'Heating') or
is_state_attr('climate.second_floor_heat', 'operating_state', 'Heating') %}
heat
{% else %}
off
{% endif %}
This will set the operation mode of the basement thermostat to heat when either of the other thermostats are indicating Heating, or off otherwise. Is that what youâre looking for?
pnbruckner;
Thanks for the quick reply. This looks like what I am looking for, but I get an error when I check config:
Invalid config for [automation]: expected a dictionary for dictionary value @ data[âactionâ][0][âdata_templateâ]. Got None
extra keys not allowed @ data[âactionâ][0][âoperation_modeâ]. Got None. (See /config/configuration.yaml, line 83). Please check the docs at https://home-assistant.io/components/automation/
It must be the way you entered it. I just tried adding it verbatim to my config and I did a check config and it found no problems. Where did you enter it?
I put it in the automation.yaml file.
Then it depends on how you include automation.yaml in your configuration.yaml, which is not standard (i.e., there are multiple ways to do that.) What does the line look like in your configuration.yaml file that starts with automation:
?
automation: !include automations.yaml
I have other automations in the automations.yaml that work. By the way, I didnt setup second floor thermostat so I modified your code a bit to reflect that.
#Thermostat Automation
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat
action:
service: climate.set_operation_mode
entity_id: climate.basement_heat
data_template:
operation_mode: >
{% if is_state_attr(âclimate.first_floor_heatâ, âoperating_stateâ, âHeatingâ) %}
heat
{% else %}
off
{% endif %}
Ok, that explains it. Since you have your configuration laid out that way you need to know that you should not include the automation:
line, since that is already in your configuration.yaml file. The error occurred because you effectively had:
automation:
automation:
- alias: ...
Also, when you post YAML code, please format using the instructions at the top of the page so everyone can read it properly.
In any case, Iâm glad I could help. Let us know how it works for you.
Actually I removed the automation line. This is exactly how my code looks like in automation.yaml file.
#Thermostat Automation
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat
action:
service: climate.set_operation_mode
entity_id: climate.basement_heat
data_template:
operation_mode: >
{% if is_state_attr('climate.first_floor_heat', 'operating_state', 'Heating') %}
heat
{% else %}
off
{% endif %}
As soon as I remove your code the config checks out.
The line with operation_mode is not indented correctly. Compare against my post above.
pnbruckner:
Your code works great. I now have a good idea how to proceed on modifying the code to my needs.
Thank you!
1 Like
How would I create a notification when the heat turns on? Can I put a service action inside the if statement?
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat
action:
service: climate.set_operation_mode
entity_id: climate.basement_heat
data_template:
operation_mode: >
{% if is_state_attr('climate.first_floor_heat', 'operating_state', 'Heating') %}
heat
{% else %}
off
{% endif %}
service: notify.ios_xxx_iphone
data:
message: The heat is on!
You need to add dashes since you have multiple steps (i.e., multiple service calls.) Also, to get the notification to only happen when the heat is turned on you need to add a condition step before it. So:
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat
action:
- service: climate.set_operation_mode
entity_id: climate.basement_heat
data_template:
operation_mode: >
{% if is_state_attr('climate.first_floor_heat', 'operating_state', 'Heating') %}
heat
{% else %}
off
{% endif %}
- condition: template
value_template: >
{{ trigger.to_state.attributes.operating_state == 'Heating' and
trigger.to_state.attributes.operation_state !=
trigger.from_state.attributres.operating_state }}
- service: notify.ios_xxx_iphone
data:
message: The heat is on!
The condition is written a bit different to make sure the notification is only sent (once) when climate.first_floor_heatâs operating_state attribute changes to Heating.
Please HELP!
I updated to 0.100.2 and now the automation doesnât work. I know the template works, but it doesnât trigger basement thermostat. What am I missing.
#Thermostat Automation - Turn on basement if first floor turns on
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat
action:
service: climate.set_hvac_mode
entity_id: climate.basement_heat
data_template:
operation_mode: >
{% if is_state('climate.first_floor_heat', 'heat') %}
heat
{% else %}
off
{% endif %}
See SERVICE CLIMATE.SET_HVAC_MODE. The parameter is hvac_mode
, not operation_mode
.
BTW, you may be able to simplify to:
#Thermostat Automation - Turn on basement if first floor turns on
- alias: Set basement thermostat
trigger:
platform: state
entity_id: climate.first_floor_heat
action:
service: climate.set_hvac_mode
entity_id: climate.basement_heat
data_template:
hvac_mode: "{{ trigger.to_state.state }}"
1 Like
Thank you! I completely missed that part.
In your script the hvac_mode: â{{ trigger.to_state.state }}â takes the state of the climate.first_floor_heat? Am I reading that correctly?
Yes. I donât know if you want climate.basement_heat
to track exactly all the states of climate.first_floor_heat
, but if you do, then this is probably the easiest solution.
I just need it to monitor the heat and off state. The trigger.to_state.state monitors all states? If so, how can it monitor just the heat and off states with your script?
trigger.to_state.state
doesnât âmonitorâ anything. It is a variable that will contain whatever state the trigger entity (in this case climate.first_floor_heat
) changes to. What states can it change to? If it can change to other states than heat and off, then what do you want climate.basement_heat
to change to when climate.first_floor_heat
changes to something else than heat and off, or do you want it to change at all in that case?