Sends two reminders as notifications to a mobile device to close a window or door after opening it, if the temperature outside is below a certain degree.
#
# Home Assistant Automation Blueprint
#
# Sends two notifications to close a window or door after opening it,
# if the temperature outside is below a certain degree.
#
# Revision 2
# Roozbeh Farahbod, Jan. 2021
#
blueprint:
name: Notification to Close a Window
description: Notification to close windows if it is cold outside
domain: automation
input:
contact_sensor:
name: Contact Sensor
description: 'The window or door sensor that triggers the automation.'
selector:
entity:
domain: binary_sensor
first_timer:
name: 'First timer'
description: 'The first notification timer (in minutes).'
default: 10
selector:
number:
min: 1
step: 1
max: 60
mode: slider
second_timer:
name: 'Second timer'
description: 'The second notification timer (in minutes).'
default: 15
selector:
number:
min: 1
step: 1
max: 60
mode: slider
temperature:
name: 'Temperature'
description: 'The outside temperature below which the notification should be sent.'
default: 20
selector:
number:
min: 0
step: 1
max: 25
mode: slider
device_identifier:
name: Device to notify
description: >
The device to receive the notification; it needs to run the official
Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app
# We will have two triggers, for the two different reminders.
# However, a reminder will be ignored if the door or window is already closed by then.
trigger:
- platform: state
entity_id: !input contact_sensor
from: 'off'
to: 'on'
for:
hours: 0
minutes: !input first_timer
seconds: 0
- platform: state
entity_id: !input contact_sensor
from: 'off'
to: 'on'
for:
hours: 0
minutes: !input second_timer
seconds: 0
# Two conditions:
# 1. The door or window should still be open.
# 2. The temperature reading must be below the set value.
condition:
- condition: state
entity_id: !input contact_sensor
state: 'on'
- condition: numeric_state
entity_id: weather.pihome
attribute: temperature
below: !input temperature
# Send a notification to the mobile device.
action:
- device_id: !input device_identifier
domain: mobile_app
type: notify
message: 'Time to close {{trigger.to_state.attributes.friendly_name}}.'
title: 'Close {{trigger.to_state.attributes.friendly_name}}!'
mode: single
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app
@NKH Yes, sure; I can share a different version in a bit (in the middle of a busy workday now). I assume that you mean a sensor with a temperature reading, correct?
@r100gs anything is possible and I will be happy to help; however, in my view we will end up with a too generic of a blueprint. For me, the core point of a blueprint is to capture a pattern and reduce cost of creating similar automations by fixing the logic and common structure. To offer the freedom of choosing a temperature sensor or a binary sensor (and then with values), will make the blueprint too generic.
We can create a version that depends on the state of a binary sensor, and for example remove the temperature choice.
Hi @NKH , here is a version I made for a custom temperature sensor. Keep in mind that I set the class of the selector to limit the choices to temperature devices. Depending on your setup it may not list your device. If you find any problems, let me know and we can debug it together.
#
# Home Assistant Automation Blueprint
#
# Two Notifications to close a window or door after opening it,
# if the temperature reading of a given sensor is below a certain degree.
#
# Revision 1
# Roozbeh Farahbod, Jan. 2021
#
blueprint:
name: 'Notification to Close a Window (custom sensor)'
description: Notification to close windows if it is cold outside
domain: automation
input:
contact_sensor:
name: Contact Sensor
description: 'The window or door sensor that triggers the automation.'
selector:
entity:
domain: binary_sensor
first_timer:
name: 'First timer'
description: 'The first notification timer (in minutes).'
default: 10
selector:
number:
min: 1
step: 1
max: 60
mode: slider
second_timer:
name: 'Second timer'
description: 'The second notification timer (in minutes).'
default: 15
selector:
number:
min: 1
step: 1
max: 60
mode: slider
temperature_sensor:
name: Temperature Sensor
description: 'The sensor used for reading the temperature.'
selector:
entity:
domain: sensor
device_class: temperature
temperature:
name: 'Temperature'
description: 'The outside temperature below which the notification should be sent.'
default: 20
selector:
number:
min: 0
step: 1
max: 25
mode: slider
device_identifier:
name: Device to notify
description: >
The device to receive the notification; it needs to run the official
Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app
# We will have two triggers, for the two different reminders.
# However, a reminder will be ignored if the door or window is already closed by then.
trigger:
- platform: state
entity_id: !input contact_sensor
from: 'off'
to: 'on'
for:
hours: 0
minutes: !input first_timer
seconds: 0
- platform: state
entity_id: !input contact_sensor
from: 'off'
to: 'on'
for:
hours: 0
minutes: !input second_timer
seconds: 0
# Two conditions:
# 1. The door or window should still be open.
# 2. The outside temperature must be below the set value.
condition:
- condition: state
entity_id: !input contact_sensor
state: 'on'
- condition: numeric_state
entity_id: !input temperature_sensor
below: !input temperature
# Send a notification to the mobile device.
action:
- device_id: !input device_identifier
domain: mobile_app
type: notify
message: 'Time to close {{trigger.to_state.attributes.friendly_name}}.'
title: 'Close {{trigger.to_state.attributes.friendly_name}}!'
mode: single