So I set up some a Template Binary Sensor to check if the outside temperature is less than 71F:
configuration.yaml:
# binary sensor of outside vs 71
binary_sensor:
- platform: template
sensors:
hot_outside:
friendly_name: "Outside is warmer than 71"
device_class: heat
value_template: "{{ states('sensor.outside_window_temperature') | int > 71 }}"
And I use an Automation to notify me when it is hot out (so we can turn off the window fan and close the windows):
automations.yaml:
- id: notify_hot_out
alias: Notify when it is warmer outside
trigger:
- platform: state
entity_id: binary_sensor.hot_outside
from: 'off'
to: 'on'
for:
minutes: 1
condition:
- condition: template
value_template: > # don't trigger if it was triggered within the last 4 hours
{%- if states.automation.notify_when_it_is_warmer_outside.attributes.last_triggered -%}
{{(as_timestamp(now()) - as_timestamp(states.automation.notify_when_it_is_warmer_outside.attributes.last_triggered)) > 14400}}
{%- else -%}
true
{%- endif -%}
action:
- service: notify.dadsms
data:
title: Hot outside
message: It is now {{states.sensor.outside_window_temperature.state}} °F outside,
time to close the windows and turn off the fan
And this tries to trigger every time I reboot Home Assistant. Looking at the History graph shows a blip of “Normal” for less than a minute on every reboot, and the log records an “Outside is warmer than 71 detected heat” without a preceding “Outside is warmer than 71 cleared (no heat detected)”(see 2:03PM in these shots).
So the Automation tries to trigger since the sensor went from ‘off’ to ‘on’ even though there was never an ‘off’ recording logged? Anyone understand why this happens or if it should be reported as a bug?
For now, the solution I’m trying is using an Uptime sensor as described here.
Any cleaner methods?