My old config looks like this
switch:
- platform: "mqtt"
name: Siren
state_topic: "zigbee2mqtt/MYSIREN/set"
availability_topic: "zigbee2mqtt/bridge/state"
payload_off: '{"warning": {"duration": 0, "mode": "stop", "strobe": false}}'
payload_on: '{"warning": {"duration": 1800, "mode": "emergency", "strobe": true}}'
command_topic: "zigbee2mqtt/MYSIREN/set"
I have tried to convert it:
mqtt:
siren:
- name: MYSIREN
payload_off: '{"warning": {"duration": 0, "mode": "stop", "strobe": false}}'
payload_on: '{"warning": {"duration": 30, "mode": "emergency", "strobe": true, "strobe_level": 10, "strobe_duty_cycle": 5}}'
command_topic: "zigbee2mqtt/MYSIREN/siren/set"
But nothing happens if I try to use the siren.turn_on service. In zigbee2mqtt I can also set the duration, mode and so on dynamically. Is this also possible in homeassistant?
The model of the device is SZ-SRN12N.
complex1
(Frank)
December 28, 2022, 3:12pm
2
I use next commands in my automation to trigger and reset the Sirene.
action:
# Trigger or Reset the Sirene
- service: mqtt.publish
data:
topic: zigbee2mqtt/Sirene/set
payload: >-
{{
'{"warning": {"duration":10, "mode":"stop", "strobe":true}}'
if trigger.platform == "reset" else
'{"warning": {"duration":120, "mode":"emergency", "strobe":false}}'
}}
Your solution sounds like a valid approach nevertheless I think the current behavior might be a bug:
opened 03:11PM - 28 Dec 22 UTC
### The problem
I have migrated my siren configuration to the new mqtt.siren fo… rmat.
Unfortunately I found out that homeassistant is double quoting my json which cannot be read by zigbee2mqtt:
```
mqtt:
siren:
- name: MY Alarmsystem
availability_topic: "zigbee2mqtt/corridor/downstairs/siren/availability"
availability_template: "{{ value_json.state }}"
payload_off: '{"warning": {"duration": 0, "mode": "stop", "strobe": false}}'
payload_on: '{"warning": {"duration": 30, "mode": "emergency", "strobe": true, "strobe_level": 10, "strobe_duty_cycle": 5}}'
command_topic: "zigbee2mqtt/corridor/downstairs/siren/set"
```
Homeassistant sends messages like this:
```
{"state":"{\"warning\": {\"duration\": 0, \"mode\": \"stop\", \"strobe\": false}}"}
```
instead of
```
{"warning": {"duration": 0, "mode": "stop", "strobe": false}}
```
### What version of Home Assistant Core has the issue?
2022.12.8
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant Container
### Integration causing the issue
mqtt
### Link to integration documentation on our website
_No response_
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
siren:
- name: MY Alarmsystem
availability_topic: "zigbee2mqtt/corridor/downstairs/siren/availability"
availability_template: "{{ value_json.state }}"
payload_off: '{"warning": {"duration": 0, "mode": "stop", "strobe": false}}'
payload_on: '{"warning": {"duration": 30, "mode": "emergency", "strobe": true, "strobe_level": 10, "strobe_duty_cycle": 5}}'
command_topic: "zigbee2mqtt/corridor/downstairs/siren/set"
```
### Anything in the logs that might be useful for us?
_No response_
### Additional information
_No response_
1 Like
sigalou
(Sigalou)
August 21, 2023, 4:14pm
4
@runningman84 @complex1
Hi
I am having the same problem as you
I have an SZ-SRN12N siren and I cannot get it to work on the automatic link (MQTT) between Zigbee2MQTT and Home Assistant
I do not know how to do.
Did you get there?