Files
Home-Assistant-Configs/blueprints/automation/Raukze/contact-sensor-left-open-notification.yaml

298 lines
9.8 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

blueprint:
name: "\U0001F6AA Contact Sensor Left Open Notification by Malte"
description: "\U0001F4F2 Notifies you when a door or window is left open.\n\nAre
you tired of worrying about open doors or windows? This blueprint has got you
covered! It's designed to send you a prompt notification when a door or window
remains open for a specified duration.\n\n\U0001F4D6 For Details see this [Blog
post](https://community.home-assistant.io/t/contact-sensor-door-or-window-left-open-notification/652571)\n"
domain: automation
source_url: https://gist.github.com/Raukze/27fe0c6bf6d91b8ae2ab5e11880509ba
input:
trigger_entity:
name: "\U0001F916 Entity"
description: 'The entity that will trigger the automation. This must be a binary
sensor or input_boolean. (e.g., binary_sensor.fridge)
'
selector:
entity:
domain:
- binary_sensor
- input_boolean
multiple: false
friendly_name:
name: "\U0001F3F7 Device Friendly Name"
description: What should we call the entity in the notification? (e.g. Fridge)
default: ''
selector:
text: {}
issue_state:
name: ⚠️ Issue State
description: 'The state that triggers the automation. Because this is a binary
sensor, it can only be on or off. Use the developer tools to find the correct
setting.
'
default: 'on'
selector:
select:
options:
- 'on'
- 'off'
multiple: false
sort: false
custom_value: false
duration_issue_state:
name: ⏰ Time before alert
description: The amount of time that the device can be in the issue state before
an alert is triggered.
default:
minutes: 10
selector:
duration:
enable_day: true
condition_send_notification:
name: "\U0001F50D Additional condition"
description: Define a condition that is checked after the initial trigger before
the notification is sent.
default: []
selector:
condition: {}
delete_notification:
name: "\U0001F5D1 Delete notification when not in issue state anymore."
description: 'Do you want the notification to be deleted automatically when
the device state is not in the issue state anymore.
'
default: true
selector:
boolean: {}
duration_from_issue_state:
name: ⏰ Time from issue state before alert removal
description: 'The amount of time that the device has not been in the issue state
before the alert gets removed.
'
default:
seconds: 5
selector:
duration:
enable_day: true
notify_services_string:
name: "\U0001F4F2 Notify Services"
description: 'The service that will be called to deliver the notification. (e.g.,
notify.mobile_app_my_phone).
It also supports multiple services, separated by a comma. (e.g., notify.mobile_app_my_phone,notify.mobile_app_my_spouse_phone).
'
default: notify.mobile_app_<your_device_id_here>
selector:
text: {}
notification_click_url:
name: "\U0001F517 Click URL"
description: 'Where the user will be taken if they tap the notification. (e.g.,
/lovelace/kitchen)
'
default: /lovelace/ROOM
selector:
text: {}
notification_title:
name: "\U0001F4E2 Notification Title"
description: The title of the notification.
default: The {{ friendly_name }} was left open
selector:
text: {}
notification_message:
name: "\U0001F4EC Notification Message"
description: 'The message of the notification.
'
default: The {{ friendly_name }} was left open at {{ as_timestamp(now()) | timestamp_custom('%T',
True) }}.
selector:
text: {}
repeat_notification:
name: "\U0001F501 Repeat Notification"
description: Whether or not a notification should be repeated after a certain
time.
default: false
selector:
boolean: {}
time_between_repeat_notification:
name: ⏳ Time Between Repeat
description: Time period after which the repeat notification is triggered.
default:
minutes: 10
selector:
duration:
enable_day: true
notification_icon_warning:
name: "\U0001F6A8 Notification Icon (Android Only)"
description: 'The icon that is shown when the issue is reported. (e.g., mdi:fridge-alert)
'
default: alert
selector:
select:
options:
- alert
- alert-circle
- door
- door-open
- motion-sensor
- fridge
- fridge-alert
- home
- home-alert
- home-assistant
- window-closed
- window-open
- window-open-variant
multiple: false
sort: false
custom_value: false
notification_color:
name: "\U0001F308 Notification Color (Android Only)"
description: The color of the notification.
default: red
selector:
select:
options:
- red
- orange
- yellow
- green
- blue
- purple
multiple: false
sort: false
custom_value: false
notification_persistent:
name: "\U0001F4CC Persistent Notification (Android Only)"
description: The notification cannot be closed manually.
default: false
selector:
boolean: {}
notification_interruption_level:
name: "\U0001F514 Interruption Level (iOS Only)"
description: 'The intrusiveness of the notification received. This also determines
whether the notification will be delivered while the device is in a focus
mode.
'
default: active
selector:
select:
options:
- passive
- active
- time-sensitive
- critical
multiple: false
sort: false
custom_value: false
custom_action_issue_state:
name: ⚙️ Custom Action Issue State
description: Custom actions that are executed when the device state enters the
issue state.
default: []
selector:
action: {}
custom_action_from_issue_state:
name: ⚙️ Custom Action From Issue State
description: Custom actions that are executed when the device state exits the
issue state.
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
variables:
friendly_name: !input friendly_name
trigger_entity: !input trigger_entity
issue_state: !input issue_state
duration_issue_state: !input duration_issue_state
condition_send_notification: !input condition_send_notification
delete_notification: !input delete_notification
duration_from_issue_state: !input duration_from_issue_state
notify_services_string: !input notify_services_string
notification_click_url: !input notification_click_url
notification_title: !input notification_title
notification_message: !input notification_message
repeat_notification: !input repeat_notification
time_between_repeat_notification: !input time_between_repeat_notification
notification_icon_warning: !input notification_icon_warning
notification_color: !input notification_color
notification_interruption_level: !input notification_interruption_level
custom_action_issue_state: !input custom_action_issue_state
custom_action_from_issue_state: !input custom_action_from_issue_state
trigger:
- platform: state
entity_id: !input trigger_entity
to: !input issue_state
for: !input duration_issue_state
id: send_notification
- platform: state
entity_id: !input trigger_entity
from: !input issue_state
for: !input duration_from_issue_state
id: delete_notification
action:
- variables:
notify_services_list: '{{ notify_services_string.split('','') }}'
number_of_notify_services: '{{ notify_services_list | count }}'
notification_tag: '{{ trigger_entity[-20:] }}-{{ friendly_name[-20:] }}-{{ notify_services_string[-20:]
}}'
- choose:
- conditions:
- condition: trigger
id: send_notification
- condition: !input condition_send_notification
sequence:
- repeat:
sequence:
- parallel:
- repeat:
count: '{{ number_of_notify_services }}'
sequence:
- service: '{{ notify_services_list[repeat.index-1] }}'
data:
message: !input notification_message
title: !input notification_title
data:
clickAction: !input notification_click_url
url: !input notification_click_url
tag: '{{ notification_tag }}'
color: !input notification_color
notification_icon: mdi:{{ notification_icon_warning }}
push:
interruption-level: !input notification_interruption_level
persistent: !input notification_persistent
sticky: !input notification_persistent
- choose: []
default: !input custom_action_issue_state
- if:
- '{{ repeat_notification }}'
then:
- delay: '{{ time_between_repeat_notification }}'
until:
- '{{ not repeat_notification }}'
- conditions:
- condition: trigger
id: delete_notification
- '{{ delete_notification }}'
sequence:
- parallel:
- repeat:
count: '{{ number_of_notify_services }}'
sequence:
- service: '{{ notify_services_list[repeat.index-1] }}'
data:
message: clear_notification
data:
tag: '{{ notification_tag }}'
- choose: []
default: !input custom_action_from_issue_state