-
Notifications
You must be signed in to change notification settings - Fork 1
/
vacuum_black.yaml
315 lines (299 loc) · 10.7 KB
/
vacuum_black.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
vacuum:
- platform: template
vacuums:
black_vacuum:
friendly_name: Black Vacuum
unique_id: black_vacuum
value_template: >
{% if states("sensor.blackvacuum_dpid28_state") == "StandBy" %} idle
{% elif states("sensor.blackvacuum_dpid28_state") == "Working" %} cleaning
{% elif states("sensor.blackvacuum_dpid28_state") == "Fault" %} error
{% elif states("sensor.blackvacuum_dpid28_state") == "Sleep" %} idle
{% elif states("sensor.blackvacuum_dpid28_state") == "Work Completed" %} idle
{% elif states("sensor.blackvacuum_dpid28_state") == "Charging" %} docked
{% elif states("sensor.blackvacuum_dpid28_state") == "Charge Completed" %} docked
{% elif states("sensor.blackvacuum_dpid28_state") == "Pause" %} paused
{% elif states("sensor.blackvacuum_dpid28_state") == "Cleanning" %} cleaning
{% elif states("sensor.blackvacuum_dpid28_state") == "Mopping" %} cleaning
{% elif states("sensor.blackvacuum_dpid28_state") == "Docking" %} returning
{% endif %}
battery_level_template: "{{ states('sensor.blackvacuum_dpid14_battery')|int }}"
fan_speed_template: "{{ states('sensor.blackvacuum_dpid30_suction_speed') }}"
start:
service: input_select.select_option
data:
entity_id: input_select.blackvacuum_dpid27_mode
option: "Smart"
pause:
service: switch.turn_off
entity_id: switch.blackvacuum_dpid25_power_go
stop:
service: script.blackvacuum_dpid26_direction_stop
return_to_base:
service: input_select.select_option
data:
entity_id: input_select.blackvacuum_dpid27_mode
option: "Go Charge"
clean_spot:
service: input_select.select_option
data:
entity_id: input_select.blackvacuum_dpid27_mode
option: "Smart"
locate:
service: script.blackvacuum_dpid29_locate
set_fan_speed:
service: input_select.select_option
data_template:
entity_id: input_select.blackvacuum_dpid30_suction
option: "{{ fan_speed }}"
fan_speeds:
- "Min"
- "Medium"
- "Max"
attribute_templates:
status: "{{ states('sensor.blackvacuum_dpid28_state') }}"
sensor:
- platform: mqtt
name: "BlackVacuum DpId28 state"
state_topic: tele/BlackVacuum/RESULT
value_template: >
{% if value_json.TuyaReceived['28'].DpIdData == "00" %} StandBy
{% elif value_json.TuyaReceived['28'].DpIdData == "01" %} Working
{% elif value_json.TuyaReceived['28'].DpIdData == "02" %} Fault
{% elif value_json.TuyaReceived['28'].DpIdData == "03" %} Sleep
{% elif value_json.TuyaReceived['28'].DpIdData == "04" %} Work Completed
{% elif value_json.TuyaReceived['28'].DpIdData == "05" %} Charging
{% elif value_json.TuyaReceived['28'].DpIdData == "06" %} Charge Completed
{% elif value_json.TuyaReceived['28'].DpIdData == "07" %} Pause
{% elif value_json.TuyaReceived['28'].DpIdData == "08" %} Cleanning
{% elif value_json.TuyaReceived['28'].DpIdData == "09" %} Mopping
{% elif value_json.TuyaReceived['28'].DpIdData == "0A" %} Docking
{% endif %}
- platform: mqtt
name: "BlackVacuum DpId30 suction_speed"
state_topic: tele/BlackVacuum/RESULT
value_template: >
{% if value_json.TuyaReceived['30'].DpIdData == "00" %} Min
{% elif value_json.TuyaReceived['30'].DpIdData == "01" %} Medium
{% elif value_json.TuyaReceived['30'].DpIdData == "02" %} Max
{% endif %}
- platform: mqtt
name: "BlackVacuum DpId14 battery"
state_topic: tele/BlackVacuum/RESULT
device_class: battery
value_template: >
{% if value_json.TuyaReceived is defined and value_json['TuyaReceived'].DpType2Id14 is defined %}
{{ value_json['TuyaReceived'].DpType2Id14 }}
{% else %}
{{ states('sensor.blackvacuum_dpid14_battery') }}
{% endif %}
- platform: mqtt
name: "BlackVacuum DpId32 clean_area"
state_topic: tele/BlackVacuum/RESULT
value_template: >
{% if value_json.TuyaReceived is defined and value_json['TuyaReceived'].DpType2Id32 is defined %}
{{ value_json['TuyaReceived'].DpType2Id32 }}
{% else %}
{{ states('sensor.blackvacuum_dpid32_clean_area') }}
{% endif %}
- platform: mqtt
name: "BlackVacuum DpId33 clean_time"
state_topic: tele/BlackVacuum/RESULT
value_template: >
{% if value_json.TuyaReceived is defined and value_json['TuyaReceived'].DpType2Id33 is defined %}
{{ value_json['TuyaReceived'].DpType2Id33 }}
{% else %}
{{ states('sensor.blackvacuum_dpid33_clean_time') }}
{% endif %}
- platform: mqtt
name: "BlackVacuum DpId11 fault"
state_topic: tele/BlackVacuum/RESULT
value_template: "{{ value_json.TuyaReceived['11'].DpIdData }}"
switch:
- platform: mqtt
unique_id: blackvacuum_dpid1_switch
name: "BlackVacuum DpId1 switch" # Sleep / WakeUp
icon: mdi:robot-vacuum
state_topic: "stat/BlackVacuum/POWER"
command_topic: "cmnd/BlackVacuum/TuyaSend1"
value_template: >
{% if value_json['TuyaReceived'].DpType1Id1 == 0 %}
OFF
{% elif value_json['TuyaReceived'].DpType1Id1 == 1 %}
ON
{% endif %}
payload_on: "1,1"
payload_off: "1,0"
state_on: "ON"
state_off: "OFF"
qos: 1
retain: false
- platform: mqtt
unique_id: blackvacuum_dpid25_power_go
name: "BlackVacuum DpId25 power_go"
icon: mdi:robot-vacuum
state_topic: "tele/BlackVacuum/RESULT"
command_topic: "cmnd/BlackVacuum/TuyaSend1"
value_template: >
{% if value_json['TuyaReceived'].DpType1Id25 == 0 %}
OFF
{% elif value_json['TuyaReceived'].DpType1Id25 == 1 %}
ON
{% endif %}
payload_on: "25,1"
payload_off: "25,0"
state_on: "ON" # Start
state_off: "OFF" # Pause
qos: 1
retain: false
- platform: mqtt
unique_id: blackvacuum_dpid31_voice_switch
name: "BlackVacuum DpId31 voice_switch"
icon: mdi:volume-source
state_topic: "tele/BlackVacuum/RESULT"
command_topic: "cmnd/BlackVacuum/TuyaSend1"
value_template: >
{% if value_json['TuyaReceived'].DpType1Id31 == 0 %}
OFF
{% elif value_json['TuyaReceived'].DpType1Id31 == 1 %}
ON
{% endif %}
payload_on: "31,1"
payload_off: "31,0"
state_on: "ON"
state_off: "OFF"
qos: 1
retain: false
input_select:
blackvacuum_dpid27_mode:
name: BlackVacuum DpId27 Modes
initial: "Standby"
options:
- "Standby"
- "Smart"
- "Spiral"
- "Single"
- "Wall Follow"
- "Go Charge"
blackvacuum_dpid30_suction:
name: BlackVacuum DpId30 suction
initial: "Medium"
options:
- "Min"
- "Medium"
- "Max"
script:
#Working Mode
blackvacuum_dpid27:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload_template: >
{% if is_state("input_select.blackvacuum_dpid27_mode", "Standby") %} 27,0
{% elif is_state("input_select.blackvacuum_dpid27_mode", "Smart") %} 27,1
{% elif is_state("input_select.blackvacuum_dpid27_mode", "Spiral") %} 27,2
{% elif is_state("input_select.blackvacuum_dpid27_mode", "Single") %} 27,3
{% elif is_state("input_select.blackvacuum_dpid27_mode", "Wall Follow") %} 27,4
{% elif is_state("input_select.blackvacuum_dpid27_mode", "Go Charge") %} 27,5
{%- endif -%}
#Suction Power
blackvacuum_dpid30:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload_template: >
{% if is_state("input_select.blackvacuum_dpid30_suction", "Min") %} 30,0
{% elif is_state("input_select.blackvacuum_dpid30_suction", "Medium") %} 30,1
{% elif is_state("input_select.blackvacuum_dpid30_suction", "Max") %} 30,2
{%- endif -%}
#Front
blackvacuum_dpid26_direction_front:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload: 26,0
#Back
blackvacuum_dpid26_direction_back:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload: 26,1
#Turn Left
blackvacuum_dpid26_direction_left:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload: 26,2
#Turn Right
blackvacuum_dpid26_direction_right:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload: 26,3
#Stop
blackvacuum_dpid26_direction_stop:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend4
payload: 26,4
#Pause
blackvacuum_dpid26_direction_pause:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 25,0
#Resume
blackvacuum_dpid26_direction_resume:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 25,1
#Locate
blackvacuum_dpid29_locate:
sequence:
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 29,1
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 29,0
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 29,1
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 29,0
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 29,1
- service: mqtt.publish
data_template:
topic: cmnd/BlackVacuum/TuyaSend1
payload: 29,0
automation:
- alias: 'BlackVacuum DpId27 Working Mode'
trigger:
- platform: state
entity_id: input_select.blackvacuum_dpid27_mode
action:
service: script.blackvacuum_dpid27
- alias: 'BlackVacuum DpId30 Suction'
trigger:
- platform: state
entity_id: input_select.blackvacuum_dpid30_suction
action:
service: script.blackvacuum_dpid30