-
Notifications
You must be signed in to change notification settings - Fork 2
MQTT Setup
Here are the fields available when setting up your MQTT connection:
| Field | Description |
|---|---|
| broker | The URL and port to use for communicating with your MQTT device, defaults to mqtt://127.0.0.1:1883/
|
| username | Username used to authenticate the MQTT connection |
| password | Password used to authenticate the MQTT connection |
| options | See Options below |
| onConnect | See OnConnect below |
| minPublishIntervalMs | When defined, multiple messages published to the same topic will be separated by at least this number of milliseconds |
You may instead set the following environment variables for broker, username, and password so you don't need to define them for every accessory.
-
EASYMQTT_BROKER- expects a fully formed url,protocol://host:port/where port is optional EASYMQTT_USERNAMEEASYMQTT_PASSWORD
Note that if you set broker/username/password in the JSON config, it will override the environment variables.
You are able to pass in any arbitrary MQTT options via mqtt.options in the config. This can be a combination of client options and publish options. Just make sure the value provided is valid JSON. For example:
"options": "{ \"protocolVersion\": \"4\", \"clientId\": \"my-client-id\", \"retain\": true }"
Accessories can be configured to publish any number of arbitrary messages to the MQTT server on connect. This can be useful to invoke accessories to give updates on their current status.
Each entry should have a topic and a message:
"onConnect": [
{
"topic": "some/arbitrary/topic",
"message": "connected",
},
{
"topic": "another/arbitrary/topic",
"message": "{ \"value\": \"can also be json\" }",
}
]