-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmobile_app_notification.yaml
110 lines (108 loc) · 4.4 KB
/
mobile_app_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
blueprint:
name: Mobile App Notification
description: >-
This allows notification script creation for Mobile Apps, allows
for a input toggle (input_boolean) to control notification usage.
There is a ability to override the disable notification function by setting critical: True
The format of the script accepts data:
title: (message title) used to display on mobile devices and screens that support notification
message: (message) this is the TTS that is read or displayed on the device
critical: (True/False) This is used to override DND and input_boolean.
data: (supports all mobile app notification parameters https://companion.home-assistant.io/docs/notifications/notifications-basic)
domain: script
source_url: https://github.com/stboch/homeassistant-blueprints/blob/main/mobile_app_notification.yaml
input:
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app
input_device:
name: Input Boolean for device (This already needs to have been created)
description: Choose the input boolean that will be used to control if this device is in Do Not Disturb mode.
selector:
entity:
domain: input_boolean
variables:
mobile_device: !input notify_device
is_apple: '{{ is_device_attr( mobile_device , "manufacturer", "Apple")}}'
applecritical: |
{% set mobiledata= data |to_json %}
{{mobiledata[:-1]}}, "push": ["sound": ["name": "default", "critical": "1", "volume": "1.0"]]}
androidcritical: |
{% set mobiledata= data |to_json %}
{{mobiledata[:-1]}}, "ttl": 0, "priority": "high", "channel": "alarm_stream_max"}
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ is_apple }}'
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ critical }}'
sequence:
- alias: "Send iOS critical notification"
domain: mobile_app
type: notify
device_id: !input notify_device
title: '{{ title }}'
message: '{{ message }}'
data: '{{applecritical}}'
- conditions:
- condition: state
entity_id: !input input_device
state: 'on'
sequence:
- alias: "Send iOS notification"
domain: mobile_app
type: notify
device_id: !input notify_device
title: '{{ title }}'
message: '{{ message }}'
data: '{{ data }}'
- conditions:
- condition: not
conditions:
- condition: template
value_template: '{{ is_apple }}'
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ critical }}'
sequence:
- alias: "Send android critical notification"
domain: mobile_app
type: notify
device_id: !input notify_device
title: '{{ title }}'
message: '{{ message }}'
data: '{{androidcritical}}'
- alias: "Send android critical notification with TTS"
domain: mobile_app
type: notify
device_id: !input notify_device
title: '{{ message }}'
message: 'TTS'
data: '{{androidcritical}}'
- conditions:
- condition: state
entity_id: !input input_device
state: 'on'
sequence:
- alias: "Send android notification"
domain: mobile_app
type: notify
device_id: !input notify_device
title: '{{ title }}'
message: '{{ message }}'
data: '{{ data }}'
default:
- service: system_log.write
data:
level: error
message: Notify Device did not successfully notify Error in tree
mode: single