2025-05-29 18:59:39 +00:00
|
|
|
#
|
2025-05-21 13:53:46 +00:00
|
|
|
|
2025-05-29 18:59:39 +00:00
|
|
|
::: mkdocs-typer2
|
|
|
|
:module: amqtt.scripts.pub_script
|
|
|
|
:name: amqtt_pub
|
|
|
|
:pretty: true
|
2025-05-21 13:53:46 +00:00
|
|
|
|
2025-05-28 12:39:02 +00:00
|
|
|
## Default Configuration
|
2025-05-21 13:53:46 +00:00
|
|
|
|
2025-05-29 18:59:39 +00:00
|
|
|
Without the `-c` argument, the client will run with the following, default configuration:
|
2025-05-28 11:45:12 +00:00
|
|
|
|
|
|
|
```yaml
|
2025-06-09 18:32:55 +00:00
|
|
|
--8<-- "amqtt/scripts/default_client.yaml"
|
2025-05-28 11:45:12 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Using the `-c` argument allows for configuration with a YAML structured file; see [client configuration](client_config.md).
|
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2015-11-06 21:47:12 +00:00
|
|
|
Publish temperature information to localhost with QoS 1:
|
2025-05-22 01:59:12 +00:00
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
```bash
|
|
|
|
amqtt_pub --url mqtt://localhost -t sensors/temperature -m 32 -q 1
|
|
|
|
```
|
2015-11-06 21:47:12 +00:00
|
|
|
|
|
|
|
Publish timestamp and temperature information to a remote host on a non-standard port and QoS 0:
|
2025-05-22 01:59:12 +00:00
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
```bash
|
|
|
|
amqtt_pub --url mqtt://192.168.1.1:1885 -t sensors/temperature -m "1266193804 32"
|
|
|
|
```
|
2015-11-06 21:47:12 +00:00
|
|
|
|
|
|
|
Publish light switch status. Message is set to retained because there may be a long period of time between light switch events:
|
2025-05-22 01:59:12 +00:00
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
```bash
|
|
|
|
amqtt_pub --url mqtt://localhost -r -t switches/kitchen_lights/status -m "on"
|
|
|
|
```
|
2015-11-06 21:47:12 +00:00
|
|
|
|
|
|
|
Send the contents of a file in two ways:
|
2025-05-22 01:59:12 +00:00
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
```bash
|
|
|
|
amqtt_pub --url mqtt://localhost -t my/topic -f ./data
|
2015-11-06 21:47:12 +00:00
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
amqtt_pub --url mqtt://localhost -t my/topic -s < ./data
|
|
|
|
```
|
2015-11-06 21:47:12 +00:00
|
|
|
|
2018-12-05 14:39:31 +00:00
|
|
|
Publish temperature information to localhost with QoS 1 over mqtt encapsulated in a websocket connection and additional headers:
|
2025-05-22 01:59:12 +00:00
|
|
|
|
2025-05-21 13:53:46 +00:00
|
|
|
```bash
|
|
|
|
amqtt_pub --url wss://localhost -t sensors/temperature -m 32 -q 1 --extra-headers '{"Authorization": "Bearer <token>"}'
|
|
|
|
```
|