-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmoonraker_awtrix_app.yaml
236 lines (233 loc) · 7.44 KB
/
moonraker_awtrix_app.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
blueprint:
name: "AWTRIX 3D Print Status - Moonraker"
description: "This blueprint will show the status of your 3d print, with help of the Moonraker HA intergration"
source_url: https://github.com/RDG88/Homeassistant_Blueprints/blob/main/moonraker_awtrix_app.yaml
domain: automation
input:
awtrix:
name: AWTRIX Light
description: Select the Awtrix light
selector:
device:
integration: mqtt
manufacturer: Blueforcer
model: AWTRIX Light
multiple: false
awtrix_app_name:
name: AWTRIX Application name
description: This is the custom app name that will be added to AWTRIX, should be unique
selector:
text: {}
default: 3d_print
3dprint_progress_sensor:
name: 3D Print Progress Sensor
description: 3D Print progress sensor
selector:
entity:
multiple: false
3dprint_current_state_sensor:
name: 3D Print Current Print State Sensor
description: 3D Print Current Print State sensor
selector:
entity:
multiple: false
3dprint_icon:
name: Icon
description: Enter the Icon Name or ID of the icon that you like to show.
selector:
text:
default: "51841"
push_icon:
name: Icon Mode
description:
"Please select the pushIcon setting for the icon\n\n - `0` Icon
doesn't move\n\n - `1` Icon moves with text and will not appear again\n\n
\ - `2` Icon moves with text but appears again when the text starts to scroll
again\n"
selector:
select:
options:
- label: Icon doesn't move (default)
value: "0"
- label: Icon moves with text and will not appear again
value: "1"
- label:
Icon moves with text but appears again when the text starts to
scroll again
value: "2"
multiple: false
custom_value: false
txt_color_printing:
name: Text Color Printing State
description: Select the Text color
selector:
color_rgb:
default: [255, 255, 255]
txt_color_error:
name: Text Color Error State
description: Select the Text color
selector:
color_rgb:
default: [255, 0, 0]
txt_color_paused:
name: Text Color Paused State
description: Select the Text color
selector:
color_rgb:
default: [255, 255, 0]
txt_color_canceled:
name: Text Color Canceled State
description: Select the Text color
selector:
color_rgb:
default: [255, 165, 0]
txt_color_complete:
name: Text Color Complete State
description: Select the Text color
selector:
color_rgb:
default: [66, 245, 75]
stack_notification:
name: Stack notification
description: Should the notifications be stacked?
selector:
boolean:
default: false
duration:
name: Duration (in seconds)
description: Sets how long the app or notification should be displayed.
default: "10"
repeat:
name: Repeat
description: Sets how many times the text should be scrolled through the matrix before the app/notifcation ends.
default: "4"
variables:
device_id: !input awtrix
awtrix: "{{ iif( device_attr(device_id, 'name_by_user') != none, device_attr(device_id,'name_by_user'), device_attr(device_id, 'name') ) }}"
app: !input awtrix_app_name
message_topic: "{{awtrix ~ '/custom/' ~ app }}"
icon: !input 3dprint_icon
notify_topic: "{{awtrix ~ '/notify'}}"
sensor_progress: !input 3dprint_progress_sensor
sensor_current_state: !input 3dprint_current_state_sensor
txt_color_printing: !input txt_color_printing
txt_color_error: !input txt_color_error
txt_color_paused: !input txt_color_paused
txt_color_canceled: !input txt_color_canceled
txt_color_complete: !input txt_color_complete
stack_notification: !input stack_notification
push_icon: !input push_icon
duration: !input duration
repeat: !input repeat
trigger:
- platform: state
entity_id:
- !input 3dprint_progress_sensor
- platform: state
entity_id:
- !input 3dprint_current_state_sensor
condition:
- condition: not
conditions:
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: unavailable
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: unknown
action:
- if:
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: printing
then:
- service: mqtt.publish
data:
topic: "{{ message_topic }}"
payload: |-
{
"text": "{{ states(sensor_progress) }}%",
"icon": "{{ icon }}",
"progress": "{{ states(sensor_progress) }}",
"pushIcon": {{ push_icon }},
"color": {{ txt_color_printing }},
"duration": {{ duration }},
"repeat": {{ repeat }}
}
else:
- service: mqtt.publish
data:
topic: "{{ message_topic }}"
- if:
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: error
then:
- service: mqtt.publish
data:
topic: "{{ notify_topic }}"
payload: |-
{
"text": "{{ states(sensor_current_state) }}",
"icon": "{{ icon }}",
"color": {{ txt_color_error }},
"stack": {{ iif(stack_notification, "true", "false") }},
"pushIcon": {{ push_icon }},
"duration": {{ duration }},
"repeat": {{ repeat }}
}
- if:
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: cancelled
then:
- service: mqtt.publish
data:
topic: "{{ notify_topic }}"
payload: |-
{
"text": "{{ states(sensor_current_state) }}",
"icon": "{{ icon }}",
"stack": {{ iif(stack_notification, "true", "false") }},
"color": {{ txt_color_canceled }},
"pushIcon": {{ push_icon }},
"duration": {{ duration }},
"repeat": {{ repeat }}
}
- if:
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: paused
then:
- service: mqtt.publish
data:
topic: "{{ notify_topic }}"
payload: |-
{
"text": "{{ states(sensor_current_state) }}",
"icon": "{{ icon }}",
"stack": {{ iif(stack_notification, "true", "false") }},
"color": {{ txt_color_paused }},
"pushIcon": {{ push_icon }},
"duration": {{ duration }},
"repeat": {{ repeat }}
}
- if:
- condition: state
entity_id: !input 3dprint_current_state_sensor
state: complete
then:
- service: mqtt.publish
data:
topic: "{{ notify_topic }}"
payload: |-
{
"text": "{{ states(sensor_current_state) }}",
"icon": "{{ icon }}",
"stack": {{ iif(stack_notification, "true", "false") }},
"color": {{ txt_color_complete }},
"pushIcon": {{ push_icon }},
"duration": {{ duration }},
"repeat": {{ repeat }}
}
mode: restart