home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.78k stars 30.88k forks source link

Double quote of mqtt commands #84703

Closed runningman84 closed 1 year ago

runningman84 commented 1 year ago

The problem

I have migrated my siren configuration to the new mqtt.siren format.

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

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

runningman84 commented 1 year ago

this seems to be a fix which prevent double quoting:

command_template: "{{ value }}"