-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdiscovery_zy-m100.yaml
289 lines (279 loc) · 9.38 KB
/
discovery_zy-m100.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
blueprint:
name: "Tasmota Discovery: ZY-M100 mmWave Presence Sensor"
source_url: 'https://github.com/tasmota/blueprints/blob/main/discovery_zy-m100.yaml'
description: |
Set up a ZY-M100 mmWave Human Presence sensor running Tasmota in Home Assistant. See device template page for additional information: [ZY-M100](https://templates.blakadder.com/ZY-M100.html).
**Configure Tasmota with template**
```
Template {"NAME":"ZY-M100","GPIO":[1,1,1,1,1,1,0,0,1,1,1,1,1,0],"FLAG":0,"BASE":54,"CMND":"SO97 1 | TuyaMCU 99,1 | TuyaMCU 75,104 | Rule3 1"}
```
**Add rule in Tasmota**
```
rule3
on tuyareceived#dptype4id1 do publish %topic%/presence %value% endon
on tuyareceived#dptype2id2 do publish %topic%/sensitivity %value% endon
on tuyareceived#dptype2id3 do publish %topic%/minrange %value% endon
on tuyareceived#dptype2id4 do publish %topic%/maxrange %value% endon
on tuyareceived#dptype4id6 do publish %topic%/selfcheck %value% endon
on tuyareceived#dptype2id9 do publish %topic%/distance %value% endon
on tuyareceived#dptype2id101 do publish %topic%/detection_latency %value% endon
on tuyareceived#dptype2id102 do publish %topic%/hold_time %value% endon
on tuyareceived#dptype1id106 do publish %topic%/button pressed endon
```
Review and teardown of the device on [blakadder.com](https://blakadder.com/zy-m100/).
<small>Built for Home Assistant 2022.11+</small>
domain: automation
input:
tasmota_device:
name: "Tasmota Device"
description: "Select the Tasmota device"
selector:
device:
integration: tasmota
manufacturer: "Tasmota"
topic:
name: Tasmota MQTT Topic
description: |
Found in the web UI "Information" menu under "MQTT Topic" or with `Topic` command
selector:
text:
mode: single
max_exceeded: silent
variables:
device_id: !input tasmota_device
topic: !input topic
connections: "{{ device_attr(device_id, 'connections') }}"
name: "{{ device_attr(device_id, 'name') if device_attr(device_id, 'name_by_user') == None else device_attr(device_id, 'name_by_user') }}"
macaddr: >-
{%- for i in device_attr(device_id, 'connections') -%}
{{ i[1].replace(":", "") }}
{% endfor %}
payload_presence: >-
{{
'{
"name":"' ~ name ~ ' Presence",
"device_class":"occupancy",
"state_topic":"' ~ topic ~ '/presence",
"payload_on":"1",
"payload_off":"0",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_presence",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_sensitivity: >-
{{
'{
"name":"' ~ name ~ ' Radar Sensitivity",
"icon":"hass:radar",
"min":"0",
"max":"9",
"step":"1",
"state_topic":"' ~ topic ~ '/sensitivity",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend2",
"command_template":"2,{{ value }}",
"mode":"slider",
"entity_category":"config",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_sensitivity",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_minrange: >-
{{
'{
"name":"' ~ name ~ ' Minimum Range",
"icon":"hass:magnify-minus-cursor",
"min":"0",
"max":"10",
"step":"0.10",
"unit_of_measurement":"m",
"state_topic":"' ~ topic ~ '/minrange",
"value_template":"{{ value | float * 0.01 }}",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend2",
"command_template":"3,{{ value | float * 100 }}",
"mode":"slider",
"entity_category":"config",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_minrange",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_maxrange: >-
{{
'{
"name":"' ~ name ~ ' Maximum Range",
"icon":"hass:magnify-plus-cursor",
"min":"0",
"max":"10",
"step":"0.10",
"unit_of_measurement":"m",
"state_topic":"' ~ topic ~ '/maxrange",
"value_template":"{{ value | float * 0.01 }}",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend2",
"command_template":"4,{{ value | float * 100 }}",
"entity_category":"config",
"mode":"slider",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_maxrange",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_selftest: >-
{{
'{
"name":"' ~ name ~ ' Self Test",
"icon":"hass:test-tube",
"state_topic":"' ~ topic ~ '/selfcheck",
"value_template":"{%- set val = { \'0\':\'Checking\', \'1\':\'Successful\', \'2\':\'Failure\', \'3\':\'Other\', \'4\':\'Communication Fault\', \'5\':\'Radar Fault\' } -%}{{ val[value] | default(\'Checking\', true) }}",
"entity_category":"diagnostic",
"enabled_by_default":"true",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_selfcheck",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_distance: >-
{{
'{
"name":"' ~ name ~ ' Target Distance",
"device_class":"distance",
"state_topic":"' ~ topic ~ '/distance",
"value_template":"{{ value | float / 100 | default(0, true) }}",
"unit_of_measurement":"m",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_distance",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_detectionlatency: >-
{{
'{
"name":"' ~ name ~ ' Detection Latency",
"icon":"hass:timer-settings",
"min":"0",
"max":"10",
"step":"0.10",
"unit_of_measurement":"s",
"state_topic":"' ~ topic ~ '/detection_latency",
"value_template":"{{ value | float * 0.1 }}",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend2",
"command_template":"101,{{ value | float * 10 }}",
"mode":"slider",
"entity_category":"config",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_detectionlatency",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_holdtime: >-
{{
'{
"name":"' ~ name ~ ' Hold Time",
"icon":"hass:account-tie-voice-off",
"min":"1",
"max":"1500",
"step":"1",
"unit_of_measurement":"s",
"state_topic":"' ~ topic ~ '/hold_time",
"value_template":"{{ value }}",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend2",
"command_template":"102,{{ value }}",
"mode":"box",
"entity_category":"config",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_holdtime",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_button: >-
{{
'{
"automation_type":"trigger",
"topic":"' ~ topic ~ '/button",
"payload":"pressed",
"type":"button_short_press",
"subtype":"reset_button",
"uniq_id":"' ~ macaddr ~ '_button",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
trigger_variables:
topic: !input topic
trigger:
- platform: homeassistant
event: start
- platform: mqtt
topic: '{{ "tele/" ~ topic ~ "/LWT" }}'
payload: "Online"
action:
- service: mqtt.publish
data:
topic: "homeassistant/binary_sensor/{{ macaddr }}/presence/config"
retain: true
payload: "{{ payload_presence }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/sensitivity/config"
retain: true
payload: "{{ payload_sensitivity }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/minrange/config"
retain: true
payload: "{{ payload_minrange }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/maxrange/config"
retain: true
payload: "{{ payload_maxrange }}"
- service: mqtt.publish
data:
topic: "homeassistant/sensor/{{ macaddr }}/distance/config"
retain: true
payload: "{{ payload_distance }}"
- service: mqtt.publish
data:
topic: "homeassistant/sensor/{{ macaddr }}/selftest/config"
retain: true
payload: "{{ payload_selftest }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/detectiondelay/config"
retain: true
payload: "{{ payload_detectionlatency }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/fadingtime/config"
retain: true
payload: "{{ payload_holdtime }}"
- service: mqtt.publish
data:
topic: "homeassistant/device_automation/{{ macaddr }}/button/config"
retain: true
payload: "{{ payload_button }}"
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: mqtt.publish
data:
topic: "cmnd/{{ topic }}/tuyasend8"
payload: ""