diff --git a/source/_docs/mqtt/service.markdown b/source/_docs/mqtt/service.markdown index d714c1c12b3..5ad15fa9dbf 100644 --- a/source/_docs/mqtt/service.markdown +++ b/source/_docs/mqtt/service.markdown @@ -20,38 +20,30 @@ The MQTT integration will register the service `mqtt.publish` which allows publi You need to include either payload or payload_template, but not both. -```json -{ - "topic": "home-assistant/light/1/command", - "payload": "on" -} +```yaml +topic: home-assistant/light/1/command +payload: on ``` {% raw %} -```json -{ - "topic": "home-assistant/light/1/state", - "payload_template": "{{ states('device_tracker.paulus') }}" -} +```yaml +topic: home-assistant/light/1/state +payload_template: {{ states('device_tracker.paulus') }} ``` {% endraw %} `payload` must be a string. If you want to send JSON then you need to format/escape it properly. Like: -```json -{ - "topic": "home-assistant/light/1/state", - "payload":"{\"Status\":\"off\", \"Data\":\"something\"}" -} +```yaml +topic: home-assistant/light/1/state +payload: "{\"Status\":\"off\", \"Data\":\"something\"}" ``` Example of how to use `qos` and `retain`: -```json -{ - "topic": "home-assistant/light/1/command", - "payload": "on", - "qos": 2, - "retain": true -} +```yaml +topic: home-assistant/light/1/command +payload: on +qos: 2 +retain: true ```