mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-04-27 23:07:34 +00:00
1014 B
1014 B
layout | title | description | date | sidebar | comments | sharing | footer | logo |
---|---|---|---|---|---|---|---|---|
page | MQTT Publish service | Instructions on how to setup the MQTT Publish service within Home Assistant. | 2015-08-07 18:00 | true | false | true | true | mqtt.png |
The MQTT component will register the service mqtt.publish
which allows publishing messages to MQTT topics. There are two ways of specifying your payload. You can either use payload
to hard-code a payload or use payload_template
to specify a template that will be rendered to generate the payload.
{
"topic": "home-assistant/light/1/command",
"payload": "on"
}
{% raw %}
{
"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:
{
"topic": "home-assistant/light/1/state",
"payload":"{\"Status\":\"off\", \"Data\":\"something\"}"
}