mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-15 05:16:49 +00:00
Add example for MQTT publish service
This commit is contained in:
parent
243a1efa74
commit
b2bff736fc
@ -413,7 +413,9 @@ Returns a list of states that have changed while the service was being executed.
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
Sample `curl` command:
|
Sample `curl` commands:
|
||||||
|
|
||||||
|
Turn the light on:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
|
$ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
|
||||||
@ -422,6 +424,16 @@ $ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
|
|||||||
http://localhost:8123/api/services/switch/turn_on
|
http://localhost:8123/api/services/switch/turn_on
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Send a MQTT message:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ curl -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "x-ha-access:YOUR_PASSWORD" \
|
||||||
|
-d '{"payload": "OFF", "topic": "home/fridge", "retain": "True"}' \
|
||||||
|
http://localhost:8123/api/services/mqtt/publish
|
||||||
|
```
|
||||||
|
|
||||||
<p class='note'>
|
<p class='note'>
|
||||||
The result will include any states that changed while the service was being executed, even if their change was the result of something else happening in the system.
|
The result will include any states that changed while the service was being executed, even if their change was the result of something else happening in the system.
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user