Skip to content

Commit b2bff73

Browse files
committed
Add example for MQTT publish service
1 parent 243a1ef commit b2bff73

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

source/developers/rest_api.markdown

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,9 @@ Returns a list of states that have changed while the service was being executed.
413413
]
414414
```
415415

416-
Sample `curl` command:
416+
Sample `curl` commands:
417+
418+
Turn the light on:
417419

418420
```bash
419421
$ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
@@ -422,6 +424,16 @@ $ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
422424
http://localhost:8123/api/services/switch/turn_on
423425
```
424426

427+
Send a MQTT message:
428+
429+
```bash
430+
$ curl -X POST \
431+
-H "Content-Type: application/json" \
432+
-H "x-ha-access:YOUR_PASSWORD" \
433+
-d '{"payload": "OFF", "topic": "home/fridge", "retain": "True"}' \
434+
http://localhost:8123/api/services/mqtt/publish
435+
```
436+
425437
<p class='note'>
426438
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.
427439
</p>

0 commit comments

Comments
 (0)