-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathTasmota_EZ-Buttons.yaml
293 lines (257 loc) · 11.3 KB
/
Tasmota_EZ-Buttons.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
blueprint:
name: Tasmota EZ-Button for Update and Restart All 2023-08-07
author: SirGoodenough
description: >
## 🧿 This will create 3 buttons to help you. 🧿
#### 1:
Press a button to restart ALL Tasmota Devices (Also to use during
Home Assistant Restart to get all current State and Sensor readings)
#### 2:
Press a button to update a couple of Tasmota devices to test that the
new version will not break something,
(Think of these units as your canary's in the coal mine.)
#### 3:
Press a button to update ALL Tasmota devices to the latest version.
## 🧿 There are 5 Requirements to allow this to work. 🧿
#### A: ✔️
You need the Home Assistant Tasmota Integration to be functional on your system
and HA needs to be able to see and interact with the devices.
This Blueprint does not do that for you.
#### B: ✔️
This script makes the assumption that the default GroupTopic of 'Tasmotas'
is available on all your Tasmota Devices.
If you have devices that have been upgraded from pre V7 or so,
they may be missing this GroupTiopic.
If this is the case you will have to add the GroupTopic 'Tasmotas' to your device.
'https://tasmota.github.io/docs/Commands/#control'
#### C: ✔️
Your Home Assistant Instance needs to be or be communicating with an MQTT Broker.
But this is easy because in order to have A: running, MQTT is a requirement for A:.
#### D: ✔️
Tasmota Devices firmware default MQTT topic is set to: ```%prefix%/%topic%/```
If you did not change the topic in your Tasmota Devices then leave it as the
default here as well. The other option available to you is to flip them
as I do in my Home Assistant personally.
#### E: ✔️
Your Tasmota devices need to be updated to the same 'breaking change' generation
as the Released version of Tasmota for this to be able to update.
Again this is easy because in order to have A: running,
Tasmota V9.2 minimum is a requirement for A:.
Tasmota has had breaking changes in it's history. Therefore you should never
stray from the upgrade path listed in the Tasmota Docs when upgrading.
To upgrade your Tasmota firmware, you need to follow the path,
or risk bad things happening:
v1.0.11 🔀 v3.9.22 🔀 v4.2.0 🔀 v5.14.0 🔀 v6.7.1 🔀 v7.2.0 🔀 v8.5.1 🔀 v9.1 🔀 Current release.
That means you currently need to manually update your firmware to v9.1 minimum
for these buttons to work going forward.
[Community link for this blueprint](https://community.home-assistant.io/t/script-blueprint-that-generates-3-ez-buttons-to-manage-your-tasmota-cluster/376934)
## 🗿Notice👮🏿♂️:
* Copies of the original Blueprint that were converted via the 'Take Control'
feature or other means are officially not supported by me.
* I may or may not be able to support you when you have a problem after you make changes
to my code, as some of the code is no longer mine.
* I & my license also require attribution as a link back to the original
should you use this code in your own creation.
* [Here is a link to my license & the original github post](https://github.com/SirGoodenough/HA_Blueprints?tab=License-1-ov-file)
expected to be followed & referenced as attribution should you use this code elsewhere.
source_url: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/Tasmota_EZ-Buttons.yaml
domain: script
homeassistant:
min_version: 2023.8.0
input:
ez_update:
name: EZ Update Button Tasmota
description: >
This is the name of the button you want
to use for updating ALL your Tasmota instances.
It will use the built-in groupTopics in Tasmota to send the update command
to all devices.
Note: in the tasmota console, the default setting for:
'OTAUrl' is the current release location for the latest Tasmota Binary.
With devices that were upgraded from old firmware versions, you may have to
go to the Tasmota Console upgrade section and type this into the Ota Url field:
'http://ota.tasmota.com/tasmota/release/tasmota.bin.gz'.
If you have a downloaded copy of a firmware file, you can change this value
to that path instead (Advanced Users).
'https://tasmota.github.io/docs/Upgrading/'
Leaving it Blank will cause errors.
default: "EZ Update Button Tasmota"
selector:
text:
topic_format:
name: Tasmota Topic Format
description: >
The format of your Tasmota devides has a default that most people use:
'%prefix%/%topic%/'. I personally however use something else. Everytime I modify this I have
found myself manually editing the code to work with my system so I have changed it to
be able to set it in the inputs. The default is set to the normal Tasmota default,
default: '%prefix%/%topic%/'
selector:
select:
options:
- '%prefix%/%topic%/'
- '%topic%/%prefix%/'
custom_value: false
multiple: false
ez_canary:
name: EZ Canary Button Tasmota
description: >
This is the name of the button you want
to use for the test new version select sample. I suggest use 5 or less
Tasmota devices for this list.
Leave this as 'not_selected' if you do not plan on using this feature.
Leaving this Blank will cause errors. Will be converted to lower-case-chase
default: "not_selected"
selector:
text:
ez_canary_grouptopic:
name: The GroupTopic name for the EZ Canary Button
description: >
This is the name you assigned to the GroupTopics in the devices
you chose as the first ones to recieve a firmware update.
This needs to be set-up by you in the Tasmota Console of the devices themselves.
Leave this blank if you are not using this feature. The button will be created,
but it won't do anything. Use lower_case_chase formatting on
this item and only numbers and letters. REQUIRED or this button will not be created.
Leaving this Blank will cause errors. Will be converted to lower-case-chase
default: "firsts"
selector:
text:
ez_restart:
name: EZ Restart Button Tasmota
description: >
This is the name of the button you want
to use for restarting all Tasmota devices.
Use this if you are having wierd problems and want to
restart them with a fresh boot.
I also suggest you add a 'Button Press' service for this button
to execute a minute or so after Home Assistant restarts.
It will update all the devices and pull fresh sensor and
state readings into HA so things are working right away when you start.
Leaving this Blank will cause errors. Will be converted to lower-case-chase
default: "EZ Restart Button Tasmota"
selector:
text:
variables:
ez_update_v1: !input ez_update
ez_canary_v1: !input ez_canary
ez_restart_v1: !input ez_restart
ez_canary_grouptopic_var: !input ez_canary_grouptopic
ez_update_var: "{{ ez_update_v1 | lower | regex_replace('[ -]','_') | regex_replace('[^a-z0-9_]','') }}"
ez_canary_var: "{{ ez_canary_v1 | lower | regex_replace('[ -]','_') | regex_replace('[^a-z0-9_]','') }}"
ez_restart_var: "{{ ez_restart_v1 | lower | regex_replace('[ -]','_') | regex_replace('[^a-z0-9_]','') }}"
ez_canary_grouptopic_v1: "{{ ez_canary_grouptopic_var | lower | regex_replace('[ -]','_') | regex_replace('[^a-z0-9_]','') }}"
canary_topic: >
{% if topic_format == '%prefix%/%topic%/'%}
cmnd/{{ ez_canary_grouptopic_var }}/upgrade
{% else %}
{{ ez_canary_grouptopic_var }}/cmnd/upgrade
{% endif %}
restart_topic: >
{% if topic_format == '%prefix%/%topic%/'%}
cmnd/tasmotas/restart
{% else %}
tasmotas/cmnd/restart
{% endif %}
upgrade_topic: >
{% if topic_format == '%prefix%/%topic%/'%}
cmnd/tasmotas/upgrade
{% else %}
tasmotas/cmnd/upgrade
{% endif %}
dv_name: 'Tasmota EZ Buttons'
dv_id: '9NS7GaU5U9533erK'
ha_topic: 'homeassistant/button/{{ dv_id }}_'
# Device Parameters for MQTT Discovery
avty_t: 'homeassistant/status'
ids: '{{ dv_id }}'
mf: 'SirGoodenough'
mdl: 'Home Assistant EZ Buttons for Tasmota'
sa: 'home'
sw: '2023-08-07'
hw: 'https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/Tasmota_EZ-Buttons.yaml'
cu: 'https://community.home-assistant.io/t/script-blueprint-that-generates-3-ez-buttons-to-manage-your-tasmota-cluster/376934'
sequence:
- choose:
- alias: 'Don''t make this button unless these conditions are met:'
conditions:
- and:
- alias: If a different name for the canary is chosen, configure the button.
condition: template
value_template: '{{ ez_canary_var != "not_selected" }}'
- alias: Make sure grouptopic was not converted so it matches Tasmota GroupTopic
condition: template
value_template: '{{ ez_canary_grouptopic_var == ez_canary_grouptopic_v1 }}'
sequence:
- alias: Make the button 4 canary update
service: mqtt.publish
data:
"topic": "{{ ha_topic }}{{ ez_canary_var }}/config"
"retain": true
"payload": >
{ "name": "{{ ez_canary_var }}",
"avty_t": "{{ avty_t }}",
"uniq_id": "{{ dv_id }}_{{ ez_canary_var }}",
"dev_cla":"update",
"dev": {
"ids": "{{ ids }}",
"name": "{{ dv_name }}",
"mf": "{{ mf }}",
"mdl": "{{ mdl }}",
"sa": "{{ sa }}",
"sw": "{{ sw }}",
"hw": "{{ hw }}",
"cu": "{{ cu }}"
},
"cmd_t": "{{ canary_topic }}",
"payload_press": "1"
}
- alias: Make the button 4 restart
service: mqtt.publish
data:
"topic": "{{ ha_topic }}{{ ez_restart_var }}/config"
"retain": true
"payload": >
{ "name": "{{ ez_restart_var }}",
"avty_t": "{{ avty_t }}",
"uniq_id": "{{ dv_id }}_{{ ez_restart_var }}",
"dev_cla":"restart",
"dev": {
"ids": "{{ ids }}",
"name": "{{ dv_name }}",
"mf": "{{ mf }}",
"mdl": "{{ mdl }}",
"sa": "{{ sa }}",
"sw": "{{ sw }}",
"hw": "{{ hw }}",
"cu": "{{ cu }}"
},
"cmd_t": "{{ restart_topic }}",
"payload_press": "1"
}
- alias: Make the button 4 all update
service: mqtt.publish
data:
"topic": "{{ ha_topic }}{{ ez_update_var }}/config"
"retain": true
"payload": >
{ "name": "{{ ez_update_var }}",
"avty_t": "{{ avty_t }}",
"uniq_id": "{{ dv_id }}_{{ ez_update_var }}",
"dev_cla":"update",
"dev": {
"ids": "{{ ids }}",
"name": "{{ dv_name }}",
"mf": "{{ mf }}",
"mdl": "{{ mdl }}",
"sa": "{{ sa }}",
"sw": "{{ sw }}",
"hw": "{{ hw }}",
"cu": "{{ cu }}"
},
"cmd_t": "{{ upgrade_topic }}",
"payload_press": "1"
}
mode: single
max_exceeded: silent
icon: mdi-radiobox-marked