-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkabum500.yaml
348 lines (331 loc) · 11 KB
/
kabum500.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
vacuum:
- platform: template
vacuums:
kabum500:
friendly_name: KaBuM! Smart 500
unique_id: kabum500
value_template: "{{ states('sensor.kabum500_state') }}"
battery_level_template: "{{ states('sensor.kabum500_battery') }}"
fan_speed_template: "{{ states('input_select.kabum500_suction') }}"
start:
service: script.kabum500_start
pause:
service: switch.turn_off
entity_id: switch.kabum500_power_go
stop:
service: input_select.select_option
data:
entity_id: input_select.kabum500_mode
option: "Em Espera"
return_to_base:
service: input_select.select_option
data:
entity_id: input_select.kabum500_mode
option: "Retornar"
locate:
service: script.kabum500_locate
set_fan_speed:
service: input_select.select_option
data_template:
entity_id: input_select.kabum500_suction
option: "{{ fan_speed }}"
fan_speeds:
- "Mínimo"
- "Médio"
- "Máximo"
attribute_templates:
status: "{{ states('sensor.kabum500_state_ptbr') }}"
mqtt:
sensor:
- unique_id: kabum500_state
name: "KaBuM500 State"
state_topic: tele/kabum500/RESULT
value_template: >
{% if value_json['TuyaReceived'].DpType4Id28 is defined %}
{% set value = value_json.TuyaReceived['28'].DpIdData %}
{% if value == "00" %} idle
{% elif value == "01" %} cleaning
{% elif value == "02" %} error
{% elif value == "03" %} idle
{% elif value == "04" %} idle
{% elif value == "05" %} docked
{% elif value == "06" %} docked
{% elif value == "07" %} paused
{% elif value == "08" %} cleaning
{% elif value == "09" %} cleaning
{% elif value == "0A" %} returning
{% endif %}
{% else %}
{{ states('sensor.kabum500_state') }}
{% endif %}
- unique_id: kabum500_state_ptbr
name: "KaBuM500 State ptbr"
state_topic: tele/kabum500/RESULT
value_template: >
{% if value_json['TuyaReceived'].DpType4Id28 is defined %}
{% set value = value_json.TuyaReceived['28'].DpIdData %}
{% if value == "00" %} Em Espera
{% elif value == "01" %} Trabalhando
{% elif value == "02" %} Erro
{% elif value == "03" %} Dormindo
{% elif value == "04" %} Trabalho Finalizado
{% elif value == "05" %} Recarregando
{% elif value == "06" %} Recarga Completa
{% elif value == "07" %} Pausado
{% elif value == "08" %} Aspirando
{% elif value == "09" %} Passando Pano
{% elif value == "0A" %} Retornando
{% endif %}
{% else %}
{{ states('sensor.kabum500_state_ptbr') }}
{% endif %}
- unique_id: kabum500_suction_speed
name: "KaBuM500 Suction Speed"
state_topic: tele/kabum500/RESULT
value_template: >
{% if value_json['TuyaReceived'].DpType4Id30 is defined %}
{% set value = value_json.TuyaReceived['30'].DpIdData %}
{% if value == "00" %} Mínimo
{% elif value == "01" %} Médio
{% elif value == "02" %} Máximo
{% endif %}
{% else %}
{{ states('sensor.kabum500_suction_speed') }}
{% endif %}
- unique_id: kabum500_battery
name: "KaBuM500 Battery"
state_topic: tele/kabum500/RESULT
device_class: battery
value_template: >
{% if value_json['TuyaReceived'].DpType2Id14 is defined %}
{{ int(value_json['TuyaReceived'].DpType2Id14) }}
{% else %}
{{ states('sensor.kabum500_battery') }}
{% endif %}
- unique_id: kabum500_area
name: "KaBuM500 Area"
state_topic: tele/kabum500/RESULT
value_template: >
{% if value_json['TuyaReceived'].DpType2Id32 is defined %}
{{ int(value_json['TuyaReceived'].DpType2Id32) }}
{% else %}
{{ states('sensor.kabum500_area') }}
{% endif %}
- unique_id: kabum500_time
name: "KaBuM500 Time"
state_topic: tele/kabum500/RESULT
value_template: >
{% if value_json['TuyaReceived'].DpType2Id33 is defined %}
{{ int(value_json['TuyaReceived'].DpType2Id33) }}
{% else %}
{{ states('sensor.kabum500_time') }}
{% endif %}
- unique_id: kabum500_error
name: "KaBuM500 Error"
state_topic: tele/kabum500/RESULT
value_template: >
{% if value_json['TuyaReceived'].DpType5Id11 is defined %}
{% set value = value_json.TuyaReceived['11'].DpIdData %}
{% if value == "00" %} Sem erro
{% elif value == "04" %} ??? 04
{% elif value == "10" %} Robô fora do chão
{% elif value == "20" %} ??? 20
{% elif value == "0200" %} ??? 0200
{% elif value == "8000" %} Mova o robô para uma área aberta
{% elif value == "0800" %} Motor enroscado
{% else %}
{% set value = "Erro desconhecido: " ~ value %}
{{ value }}
{% endif %}
{% elif states('sensor.kabum500_error') == "unknown" %}
Sem erro
{% else %}
{{ states('sensor.kabum500_error') }}
{% endif %}
switch:
- unique_id: kabum500_sleep_wake
name: "KaBuM500 Sleep"
icon: mdi:robot-vacuum
state_topic: tele/kabum500/RESULT
command_topic: cmnd/kabum500/TuyaSend1
value_template: >
{% if value_json['TuyaReceived'].DpType1Id1 is defined %}
{% if value_json['TuyaReceived'].DpType1Id1 == 0 %} OFF
{% else %} ON
{% endif %}
{% else %}
{{ states('switch.kabum500_sleep_wake') }}
{% endif %}
payload_on: "1,1"
payload_off: "1,0"
state_on: "ON"
state_off: "OFF"
qos: 1
retain: false
- unique_id: kabum500_power_go
name: "KaBuM500 Power go"
icon: mdi:robot-vacuum
state_topic: tele/kabum500/RESULT
command_topic: cmnd/KaBuM500/TuyaSend1
value_template: >
{% if value_json['TuyaReceived'].DpType1Id25 is defined %}
{% if value_json['TuyaReceived'].DpType1Id25 == 0 %} OFF
{% else %} ON
{% endif %}
{% else %}
{{ states('switch.kabum500_power_go') }}
{% endif %}
payload_on: "25,1"
payload_off: "25,0"
state_on: "ON" # Start
state_off: "OFF" # Pause
qos: 1
retain: false
- unique_id: kabum500_mute
name: "KaBuM500 Mute"
icon: mdi:robot-vacuum
state_topic: tele/kabum500/RESULT
command_topic: cmnd/KaBuM500/TuyaSend1
value_template: >
{% if value_json['TuyaReceived'].DpType1Id31 is defined %}
{% if value_json['TuyaReceived'].DpType1Id31 == 0 %} OFF
{% else %} ON
{% endif %}
{% else %}
{{ states('switch.kabum500_mute') }}
{% endif %}
payload_on: "25,1"
payload_off: "25,0"
state_on: "ON" # Start
state_off: "OFF" # Pause
qos: 1
retain: false
input_select:
kabum500_mode:
name: KaBuM500 Modes
initial: "Em Espera"
options:
- "Em Espera"
- "Inteligente"
- "Espiral"
- "Single"
- "Cantos"
- "Retornar"
kabum500_user_mode:
name: KaBuM500 User Modes
initial: "Inteligente"
options:
- "Inteligente"
- "Espiral"
- "Single"
- "Cantos"
kabum500_suction:
name: KaBuM500 suction
initial: "Médio"
options:
- "Mínimo"
- "Médio"
- "Máximo"
script:
kabum500_start:
sequence:
- service: input_select.select_option
data:
entity_id: input_select.kabum500_mode
option: "Inteligente"
- service: switch.turn_on
entity_id: switch.kabum500_power_go
#Working Mode
kabum500_send_working_mode:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload_template: >
{% if is_state("input_select.kabum500_mode", "Em Espera") %} 27,0
{% elif is_state("input_select.kabum500_mode", "Inteligente") %} 27,1
{% elif is_state("input_select.kabum500_mode", "Espiral") %} 27,2
{% elif is_state("input_select.kabum500_mode", "Single") %} 27,3
{% elif is_state("input_select.kabum500_mode", "Cantos") %} 27,4
{% elif is_state("input_select.kabum500_mode", "Retornar") %} 27,5
{% endif %}
#Suction Power
kabum500_send_suction:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload_template: >
{% if is_state("input_select.kabum500_suction", "Mínimo") %} 30,0
{% elif is_state("input_select.kabum500_suction", "Médio") %} 30,1
{% elif is_state("input_select.kabum500_suction", "Máximo") %} 30,2
{% endif %}
#Front
kabum500_dpid26_direction_front:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload: 26,0
#Back
kabum500_dpid26_direction_back:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload: 26,1
#Turn Left
kabum500_dpid26_direction_left:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload: 26,2
#Turn Right
kabum500_dpid26_direction_right:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload: 26,3
#Stop
kabum500_dpid26_direction_stop:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend4
payload: 26,4
#Pause
kabum500_dpid26_direction_pause:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend1
payload: 25,0
#Resume
kabum500_dpid26_direction_resume:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend1
payload: 25,1
#Locate
kabum500_locate:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/kabum500/TuyaSend1
payload: 29,1
automation:
- alias: "KaBuM500 Send Working Mode"
trigger:
- platform: state
entity_id: input_select.kabum500_mode
action:
service: script.kabum500_send_working_mode
- alias: "KaBuM500 Send Suction"
trigger:
- platform: state
entity_id: input_select.kabum500_suction
action:
service: script.kabum500_send_suction