forked from panhans/HomeAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binary_sensor_notification.yaml
executable file
·134 lines (121 loc) · 3.67 KB
/
binary_sensor_notification.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
blueprint:
name: "Binary Sensor Notification"
description: 'Send a notification or trigger a custom action depending on the state switch of a binary_sensor'
source_url: https://github.com/panhans/homeassistant/blob/main/blueprints/automation/panhans/binary_sensor_notification.yaml
domain: automation
input:
sensor_entity:
name: "Sensor"
description: "Sensor which triggers the notification."
selector:
entity:
domain: binary_sensor
from:
name: "From"
description: "State which triggers the notification"
default: 'on'
selector:
select:
options:
- 'on'
- 'off'
to:
name: "To"
description: "State which triggers the notification"
default: 'off'
selector:
select:
options:
- 'on'
- 'off'
debounce_duration:
name: "Debounce duration"
description: "Duration time the notification won't be sent again after sensor changed its state."
default: 10
selector:
number:
min: 0
max: 100
unit_of_measurement: "s"
mode: slider
step: 1
notify_device:
name: "Device to notify"
description: Device which gets a notification.
default: false
selector:
device:
integration: mobile_app
notify_group:
name: Notification Group
description: "The name of the notification group to call. ('notify' for all devices)"
default: ""
title:
name: "Title"
description: "Notification title"
message:
name: "Message"
description: "Message to be sent"
tag:
name: "Tag"
description: "If you want to do something in another automation"
default: "tag-{{ trigger.entity_id }}"
status_bar_icon:
name: "Status bar icon"
description: "Sets the status bar icon. (Android only)"
default: mdi:home-assistant
selector:
icon:
placeholder: mdi:home-assistant
custom_action:
name: "Custom Action"
description: "An action which can be processed if notification is triggered"
default: []
selector:
action: {}
variables:
to: !input to
message: !input message
title: !input title
sensor_entity: !input sensor_entity
debounce_duration: !input debounce_duration
group_target: !input notify_group
custom_action: !input custom_action
notify_device: !input notify_device
trigger:
- platform: state
entity_id: !input 'sensor_entity'
to: !input to
from: !input from
condition:
condition: template
value_template: >-
{{ iif(this.attributes.last_triggered == None, 9999, as_timestamp(now()) - as_timestamp(this.attributes.last_triggered, default=0) ) >= (debounce_duration | int) }}
action:
- choose:
- conditions: "{{ not group_target }}"
sequence:
- service: 'notify.mobile_app_{{ device_attr(notify_device, "name") | slugify }}'
data:
title: "{{ title }}"
message: "{{ message }}"
data:
ttl: 0
priority: high
notification_icon: !input 'status_bar_icon'
tag: !input tag
- conditions: "{{ group_target is defined }}"
sequence:
- service: notify.{{ group_target }}
data:
title: "{{ title }} | {{ states('sensor.time') }}"
message: "{{ message }}"
data:
ttl: 0
priority: high
notification_icon: !input 'status_bar_icon'
tag: !input tag
- choose:
- conditions:
- '{{ custom_action is defined }}'
sequence: !input 'custom_action'