I’m new to Home Assistant, but I have setup my various integrations and now want to start some automations.
I have a Nest thermostat and I want to use it to control more than just the heater it controls.
I would like to setup an automation so that if the measured temperature drops below the temperature set then I can turn on a Tuya switch. Then once the measured temperature is the set temperature turn that switch off.
Is this possible somehow?
In creating a new automation I can see that I can trigger based on the Nest measured temperature, and on the Set Temperature being changed but there is no trigger for when the measured temp crosses the set temp. Also the measured temperature triggers only fixed values only.
Is there a way I could set a variable somehow, so one automation stores the temperature that has been set on the Nest thermostat. Then a second automation uses that stored value as the threshold for the measured temperature.
Wouldn’t that correspond to when the thermostat’s hvac_action is heating? In other words, when ambient temperature decreases below setpoint temperature (and the thermostat is in heat mode), the thermostat’s activates heating (hvac_action changes from idle to heating). When the ambient increases to setpoint, the thermostat returns to idle.
Your automation can be based on a State Trigger that monitors the hvac_action attribute for state-changes to heating and idle. Its action turns on the switch if it’s heating otherwise it turns it off.
Something like this:
alias: Example
mode: single
trigger:
- platform: state
entity_id: climate.your_thermostat
attribute: hvac_action
to: 'heating,idle'
condition: []
action:
- service: "switch.turn_{{ 'on' if trigger.to_state.state == 'heating' else 'off' }}"
entity_id: switch.your_switch
Just have an automation that triggers whenever the current temperature changes. I’m not sure if can trigger an automation if an attribute change directly, (I use Node Red so don’t know all the possibilities of HA), but you can certainly create a template sensor based on an attribute and then trigger an automation based on a change to that. Then, check that against the set temperature and change your Tuya switch as appropriate.
Thanks, the HVAC action does seem to work as the trigger.
I setup a test automation to send a notification to my phone and that triggers fine when then temperature threshold is crossed either way - I had node in the settings that was what HVAC mode meant.
My next challenge is that I am going to set two automations, one for when HVAC is set to heat, and one is set to off.
So in my first automation I am setting the condition “When set to a specific HVAC mode” and setting the hvac_mode to “Heat”. When I try and save that though I get an error message:
Message malformed required key not provided @ data['to']
alias: Example 2
mode: single
trigger:
- platform: state
entity_id: climate.your_thermostat
to: 'heat,off'
condition: []
action:
- service: notify.notify
data:
title: Thermostat mode has changed.
message: 'Thermostat mode is now {{ trigger.to_state.state }}.'
You’re welcome! Glad to hear it now works the way you wanted.
Please consider marking my post (above) with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. It will also place a link below your first post that leads to the solution post. All of this helps users find answers to similar questions.
Excellent explanation, I almost have the same use case and i was struggling a little bit on the UI but this has helped me.
For anyone else out there who wants to try it here’s the example of what I am doing.
The problem statement:
Kids room having just one vent (abnormal airflow) and in winters it doesn’t reach to the overall temperature set on HVAC and in summers it doesn’t cool the room depending upon what again is set on HVAC.
Created four basic automations, for winter and summers
Both automations are time bound and works after 8:00 pm for weekdays only
Trigger is the HVAC action if heating is ON and condition is if the temp is below 65F then Action is to turn on smart plug (smart vent is connected with smart plug and fan setting on smart vent is pre-configured to 8) also also I get whatsapp notification
Turn off scenario is if the room reaches desired temperature then just turn off the smart plug
For weekends the conditions are slightly different
For Summers if the temp crosses 71 and if the HVAC mode is cooling then turn on vent again and as soon as the temp reaches to 65 turn it off again.
For temperature measurements I am using Aeotec’s multi sensor.