Skip to content

Instantly share code, notes, and snippets.

@frdmn
Created November 21, 2021 16:20
Show Gist options
  • Save frdmn/39d17ce1f63de73dad2457e3a17e38ca to your computer and use it in GitHub Desktop.
Save frdmn/39d17ce1f63de73dad2457e3a17e38ca to your computer and use it in GitHub Desktop.
Improved version of @home-IoT/hass-blueprints:reminder_to_close_window.yaml
#
# 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 3
# Roozbeh Farahbod, Jan. 2021
# Jonas Friedmann, Nov. 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
home_identifier:
name: Home identifier
description: >
This entity is used to read the outside temperature from.
selector:
entity:
domain: home
# 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: !input home_identifier
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment