homebridge-mqttbroker
This Homebridge plugin is a lightweight MQTT broker that runs on the Raspberry Pi. It runs in the background, but is essential for all microcontrollers that want to access Homebridge via MQTT.
The package used is Mosca, which opens a server on port 1883.
Installation
The easiest way to use this plugin on your homebridge is the installation via Homebridge Config UI X.
You can find a config sample JSON at the root directory.
Testing
There is a compiled Subscriber and Publisher in the dist directory, which can be used to test the module.
Broker
First of all you have to start the broker. Just run the following command:
node dist/broker.js
The default port is 1883. You can specify the port in the .env file.
Subscriber
Run the following command to start the subscriber:
node dist/subscriber.js --ip <IP ADDRESS OF YOUR BROKER> --topic <YOUR TOPIC>
The default IP address is 127.0.0.1
and the default topic is myTopic
. The subscriber is in operation until the process is stopped.
Publisher
Run the following command to publish a message:
node dist/publisher.js --ip <IP ADDRESS OF YOUR BROKER> --topic <YOUR TOPIC> --message "<YOUR MESSAGE>"