forked from tasmota/blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscovery-tuya_siren.yaml
82 lines (75 loc) · 4.68 KB
/
discovery-tuya_siren.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
blueprint:
name: 'Tasmota Discovery: Siren'
description: |
Set up a Tasmota TuyaMCU siren with an alarm duration timer, power sensor and selected chime sensor.
Requires some rules configured in Tasmota. See your device template page for rules:
- [NEO Coolcam Siren NAS-AB02W](https://templates.blakadder.com/neo_coolcam_NAS-AB02W.html)
domain: automation
input:
name:
name: Device name
description: Name of the device to be used in sensor name creation.
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."
source_url: https://github.com/tasmota/blueprints/blob/main/discovery-tuya_siren.yaml
mode: single
max_exceeded: silent
variables:
topic: !input topic
name: !input name
mac_address: !input mac_address
macaddr: '{{- mac_address.split(":") | join -}}'
payload_alarmduration: >-
{{ '{"name":"' ~ name ~ ' Alarm Duration","state_topic":"' ~ topic ~ '/alarmduration","command_topic":"cmnd/' ~ topic ~ '/var1","availability_topic":"tele/' ~ topic ~'/LWT","min":1,"max":60,"icon":"mdi:timer-sand","payload_available":"Online","payload_not_available":"Offline","unique_id":"' ~ macaddr ~ '_alarmduration","device":{"cns":[["mac","' ~ macaddr ~ '"]]}}' }}
payload_alarmvolume: >-
{{ '{"name":"' ~ name ~ ' Alarm Volume","state_topic":"' ~ topic ~ '/alarmvolume","value_template":"{% if value== \'0\' %}high{% elif value== \'1\' %}medium{% elif value== \'2\' %}low{% endif %}","command_topic":"cmnd/' ~ topic ~ '/event","options":["high","medium","low"],"icon":"mdi:volume-vibrate","availability_topic":"tele/' ~ topic ~ '/LWT","payload_available":"Online","payload_not_available":"Offline","uniq_id":"' ~ macaddr ~ '_alarmvolume","device":{"cns":[["mac","' ~ macaddr ~ '"]]}}' }}
payload_battery: >-
{{ '{"name":"' ~ name ~ ' Power Status","state_topic":"' ~ topic ~ '/battery","value_template":"{% if value == \'1\' %}high{% elif value == \'2\' %}medium{% elif value == \'3\' %}low{% elif value == \'4\' %}USB{% endif %}","icon":"mdi:power-plug-outline","availability_topic":"tele/' ~ topic ~ '/LWT","payload_available":"Online","payload_not_available":"Offline","uniq_id":"' ~ macaddr ~ '_battery","device":{"cns":[["mac","' ~ macaddr ~ '"]]}}' }}
payload_chime: >-
{{ '{"name":"' ~ name ~ ' Active Chime","state_topic":"' ~ topic ~ '/chime","value_template":"{% if value== \'0\' %}Doorbell{% elif value== \'1\' %}Fur Elise{% elif value== \'2\' %}Big Ben{% elif value== \'3\' %}Ring Ring{% elif value== \'4\' %}Lone Ranger{% elif value== \'5\' %}Turkish March{% elif value== \'6\' %}High Pitched{% elif value== \'7\' %}Red Alert{% elif value== \'8\' %}Crickets{% elif value== \'9\' %}Beep{% elif value== \'10\' %}Dog Bark{% elif value== \'11\' %}Police Siren{% elif value== \'12\' %}Grandfather Clock{% elif value== \'13\' %}Phone Ring{% elif value== \'14\' %}Fire Truck{% elif value== \'15\' %}Clock Chime{% elif value== \'16\' %}Alarm Clock{% elif value== \'17\' %}School Bell{% endif %}","command_topic":"cmnd/' ~ topic ~ '/event","options":["Doorbell","Elise","Big Ben","Ring Ring","Lone Ranger","Turkish March","High Pitched","Red Alert","Crickets","Beep","Dog Bark","Police Siren","Grandfather Clock","Phone Ring","Fire Truck","Clock Chime","Alarm Clock","School Bell"],"icon":"mdi:music-note","avty_t":"tele/' ~ topic ~ '/LWT","payload_available":"Online","payload_not_available":"Offline","uniq_id":"' ~ macaddr ~ '_chime","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/number/{{ macaddr }}/alarmduration/config"
retain: true
payload: "{{ payload_alarmduration }}"
- service: mqtt.publish
data:
topic: "homeassistant/select/{{ macaddr }}/alarmvolume/config"
retain: true
payload: "{{ payload_alarmvolume }}"
- service: mqtt.publish
data:
topic: "homeassistant/sensor/{{ macaddr }}/battery/config"
retain: true
payload: "{{ payload_battery }}"
- service: mqtt.publish
data:
topic: "homeassistant/select/{{ macaddr }}/chime/config"
retain: true
payload: "{{ payload_chime }}"
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: mqtt.publish
data:
topic: "cmnd/{{ topic }}/tuyasend8"
payload: ""