Hello, I’ve recently made the plunge into Home Assistant after many years of looking in from the outside but being worried about being overwhelmed by YAML and other ‘scary’ looking code-related things. Now that there are more user-friendly ways to do things with GUI’s and such, I decided to finally get HA set up and try and automate my Ecobee Thermostat, but I’m not 100% sure I’ve done this correctly.
What I’m hoping to have happen is the following:
If the outside temperature falls below 22 Degrees Celsius but is above 7 Degrees Celsius and the following conditions are met:
The AQI is below 50
I’m Home
It’s Summer
Then it is to set the HVAC to ‘off’ and push a notification to me to open the windows to get free colder air from outside.
One other question: If these conditions are no longer valid, say the temperature goes back up to 23. Would the HVAC system then kick back in? Or do I need to add another line somewhere in this? Another Automation altogether? Sorry if these seem like rookie questions, but I’m just getting my feet wet and would really appreciate any guidance you could offer!
alias: Thermostat Cost Savings
description: Turn off Thermostat if Temperature Outside is cooler than Inside
trigger:
- platform: numeric_state
entity_id: weather.thermostat
for:
hours: 0
minutes: 15
seconds: 0
attribute: temperature
below: 22
above: 7
condition:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.thermostat_air_quality_index
below: 50
- condition: zone
entity_id: device_tracker.brandon_s_galaxy_s20
zone: zone.home
- condition: state
entity_id: sensor.season
state: summer
action:
- device_id: 7675a73a57abeef797ed2eec27849b3d
domain: climate
entity_id: climate.thermostat
type: set_hvac_mode
hvac_mode: "off"
- device_id: 99447db31907827069d1d3181482c80b
domain: mobile_app
type: notify
message: >-
The exterior temperature is below HVAC Cool setting. HVAC temporarily
disabled.
mode: single
This will trigger whenever the temperature attribute of weather.thermostat changes from outside the 7–22°C range to inside it and stays there for 15 minutes.
At that point in time, it will check the conditions. If all are true, it will run the action. Nothing will then happen until next time the temperature goes outside the range then comes back inside the range.
If you want it to, for example, also trigger when you’re home, add an additional trigger, and include an additional numeric state condition for the temperature — basically, trigger off any of the things but only run if all are true.
You don’t need the condition: and — conditions are AND by default.
Thank you for the speedy response. The way it’s set up now, I believe it would only trigger if I was home. So I don’t think I’d need the extra trigger. Or am I maybe misunderstanding something?
One other question, do I need to make a separate routine to do basically the opposite of this? For example, the temperature outside has now gotten back up to over 22c and I want it to kick back into cool mode instead of staying off. Or could I tack that all into this one automation somehow?
It will only trigger the instant the temperature has been inside the range for 15 minutes. If you’re not home, nothing will happen as the condition will block it.
If the temperature moved inside the range whilst you were away (triggering but blocked by the condition), and then you came home at a later point, nothing would happen. If that’s what you want, then fine.
Same story with the AQI: it’s checked only at the point of triggering.
You could do a separate automation or combine them, but let’s be sure this one is exactly as you want it first.
The first trigger example only monitors the outside temperature for changes, If a change occurs in the outside temperature then the comparison is made.
The second trigger example monitors both sensors for changes. If a change occurs in the outside or inside temperature then the comparison is made.
In both cases the outside temperature must cross from above the inside temperature to below the inside temperature for the trigger to fire. Changing from below to further below will not trigger the automation.
Thank you for the examples, if I was trying to utilize the second trigger example, does this look correct overall? I can’t seem to find any sort of sensors though listed as sensor.outside_temperature or inside_temperature. I do see climate.thermostat and weather.thermostat. Weather shows a lot more than just the temperature too, it’s showing air pressure, humidity, wind speed, etc. I don’t really have a ton of sensors yet in the house for monitoring.
alias: Thermostat Cost Savings
description: >-
Turns off Thermostat if exterior temperature is lower than interior and air
quality is good enough to open windows for passive ventilation.
trigger:
- platform: template
value_template: >-
"{{ states('sensor.outside_temperature')|float(0) <
states('sensor.inside_temperature')|float(0) }}"
for:
hours: 0
minutes: 15
seconds: 0
condition:
- condition: state
entity_id: sensor.u_s_air_pollution_level
state: good
- condition: template
value_template: "{{ 5 <= now().month <= 9 }}"
alias: Between May and September
action:
- device_id: 7675a73a57abeef797ed2eec27849b3d
domain: climate
entity_id: climate.thermostat
type: set_hvac_mode
hvac_mode: "off"
- device_id: 99447db31907827069d1d3181482c80b
domain: mobile_app
type: notify
message: >-
HVAC Disabled due to cooler outside temperature. Open a window to
passively ventilate instead.
mode: single
Sorry, yes I copied your example, but after sending that previous post I looked a little closer into the template trigger documentation. I have an Ecobee Thermostat that gets weather data, so I tried to set this up using the attributes of the entities I have at my disposal. climate.thermostat has all the information related to inside temperature, and weather.thermostat has all the outside weather related information.
Sorry if I’m not being super clear on what you need from me. I’m still a little new to all of this, and as soon as I have to weed into YAML and code, things get a little tricky for me.
Alright, I’ve removed the quotes. Other than that, this should theoretically work? If the temperature value from weather.thermostat is below current_temperature from climate.thermostat for 15 minutes, then trigger the actions?
Your attributes are likely already numbers (only state values are always strings, attributes can be any type) so you probably don’t need the float filters, also you have not quite got the template correct. Try this: