Hello! I’ve been tweaking a new automation to tell me what to do with my windows during the summer months (open if cooler outside, closed if not). I’ve only started with HA somewhat recently but I feel like I’m getting a better grasp of the systems, which is why this is puzzling me somewhat.
This Trigger has been added to a Choose Action as a Condition with a unique ID, as I have another Trigger with the opposite function. What I’m hoping to achieve is “If the Temperature Outside is Cooler than Inside, then…” When I run a Test on this code, it sends back a result of “Condition Did Not Pass”
platform: template
value_template: >-
{{ is_state_attr('weather.thermostat', 'temperature')|float(0) <
is_state_attr('climate.thermostat', 'current_temperature')|float(0) }}
for:
hours: 0
minutes: 15
seconds: 0
alias: Outside Temperature is Lower than Inside Temperature
id: Outside Temperature is Lower than Inside Temperature
The current outside temperature here is 10 C and inside it is 22 C. Am I missing something obvious here?
is_state_attr() requires 3 arguments… and returns true/false, which doesn’t make sense with a <… I think you mean to use state_attr(). Also, conditions don’t use platform they use condition.
condition: template
value_template: >-
{{ state_attr('weather.thermostat', 'temperature')|float(0) <
state_attr('climate.thermostat', 'current_temperature')|float(0) }}
for:
hours: 0
minutes: 15
seconds: 0
alias: Outside Temperature is Lower than Inside Temperature
id: Outside Temperature is Lower than Inside Temperature
Tried your suggestion and it’s still throwing the same result of “Condition Did Not Pass”. Hopefully, it’s okay to paste a wall of code here. This is the entire YAML for the Automation I’m building. Maybe it’s something else that’s bugging out here?
alias: Thermostat Cost Savings
description: >-
Sends Alert if exterior temperature is lower than interior and air quality is
good enough to open windows for passive ventilation.
trigger:
- platform: template
value_template: >-
{{ state_attr('weather.thermostat', 'temperature')|float(0) <
state_attr('climate.thermostat', 'current_temperature')|float(0) }}
for:
hours: 0
minutes: 15
seconds: 0
alias: Outside Temperature is Lower than Inside Temperature
id: Outside Temperature is Lower than Inside Temperature
- platform: template
value_template: >-
{{ state_attr('weather.thermostat', 'temperature')|float(0) <
state_attr('climate.thermostat', 'current_temperature')|float(0) }}
for:
hours: 0
minutes: 15
seconds: 0
alias: Outside Temperature is Higher than Inside Temperature
id: Outside Temperature is Higher than Inside Temperature
- platform: state
entity_id:
- sensor.u_s_air_pollution_level
from: good
id: Outside Air Quality Worsens
for:
hours: 0
minutes: 30
seconds: 0
condition: []
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id: Outside Temperature is Lower than Inside Temperature
alias: Outside Temperature Below Inside Temperature
- condition: state
entity_id: device_tracker.brandon_s_galaxy_s20
state: home
- condition: state
entity_id: sensor.u_s_air_pollution_level
state: good
for:
hours: 0
minutes: 30
seconds: 0
- condition: template
value_template: "{{ 5 <= now().month <= 9 }}"
alias: Between May and September
alias: >-
Am I Home AND is it between May and September AND is Outside
Temperature Below Inside Temperature And is the U.S. Air pollution
level Good for 30 Minutes?
sequence:
- service: notify.mobile_app_brandon_s_galaxy_s20
data:
message: >-
It's cooler outside than in the house. Why not open a window to
passively ventilate instead?
title: Ecobee Smart Thermostat
alias: Push a Notification to Brandon's Phone
- conditions:
- condition: or
conditions:
- condition: trigger
id: Outside Temperature is Higher than Inside Temperature
- condition: trigger
id: Outside Air Quality Worsens
alias: >-
Outside Temperature Above Inside Temperature OR Air Quality
Worsens
- condition: and
conditions:
- condition: state
entity_id: device_tracker.brandon_s_galaxy_s20
state: home
- condition: template
value_template: "{{ 5 <= now().month <= 9 }}"
alias: Between May and September
alias: Am I Home AND is it between May and September?
sequence:
- service: notify.mobile_app_brandon_s_galaxy_s20
data:
message: >-
It's warmer outside than in the house. Close the windows and let
the A/C cool things off instead.
title: Ecobee Smart Thermostat
alias: Push a Notification to Brandon's Phone
mode: single
I don’t use the condition tester very often, but I remember there was a bug with it a while back where it wouldn’t work properly with template conditions… that may still be the case.