This is an MQTT LED simulator written in Ruby. To launch it, simply use the following call:
./led.rb MQTT_SERVER CHANNEL
Where MQTT_SERVER is the IP address of the MQTT server and CHANNEL is the channel to subscribe to.
An example call would be: ./led.rb "192.168.12.1" "led/1"
If the dependencies are not installed already, make sure you have bundler installed. Then call bundler install
inside the directory. This will automatically pull all the dependencies from rubygem.
The LED color can be set via the following endpoint: /rgb/set
It needs to be appended to the channel, which was defined when launching the simulator.
led/1/rgb/set green
led/1/rgb/set yellow
led/1/rgb/set #ffffff
led/1/rgb/set #000000
The LED can also be turned on and off via the endpoint: /set
This also needs to be appended to the channel when launching the simulator.
led/1/set on
led/1/set off
Whenever the status of the LED has changed, it will publish its current state and color on the following channels: the default channel & /rgb/status.
led/1 on
led/1/rgb/status green