-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdiscovery_error-binary-sensor-tuya.yaml
61 lines (54 loc) · 1.85 KB
/
discovery_error-binary-sensor-tuya.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
blueprint:
name: 'Tasmota: Error Binary Sensor for TuyaMCU'
description: |
Set up an error sensor for a Tasmota Tuya device.
Requires some rules configured in Tasmota. See the device template page for rules:
- [GD-30W Aroma Diffuser](https://templates.blakadder.com/GD-30W.html)
- [Wood Grain 550ML Aroma Diffuser](https://templates.blakadder.com/oil_diffuser_550ml.html)
domain: automation
input:
name:
name: Sensor name
description: Name of the sensor to be created.
selector:
text:
topic:
name: Tasmota MQTT Topic
description: "Found in Information tab of the webUI."
selector:
text:
mac_address:
name: Tasmota MAC Address
description: "Found in Information tab of the webUI."
mode: single
max_exceeded: silent
variables:
topic: !input topic
name: !input name
mac_address: !input mac_address
macaddr: '{{- mac_address.split(":") | join -}}'
payload: >-
{{ '{"name":"' ~ name ~ '","state_topic":"stat/' ~ topic ~ '/error","value_template":"{{ \'ON\' if value != \'0X00\' else \'OFF\' }}","device_class":"problem","avty_t":"tele/' ~ topic ~ '/LWT","pl_avail":"Online","pl_not_avail":"Offline","uniq_id":"' ~ macaddr ~ '_error","device":{"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 }}/error/config"
retain: true
payload: "{{ payload }}"
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: mqtt.publish
data:
topic: "cmnd/{{ topic }}/tuyasend8"
payload: ""