MakeHaus MQTT and Node-RED
MakeHaus MQTT and Node-RED
This article assumes that you are basically familiar with Node-RED and that you already have Node-RED installed and running. If this is not the case, we recommend the documentation on nodered.org.
Make sure you have MQTT enabled and a broker specified on the Tiles Hub before using Node-RED flows with it. For more details, see the MakeHaus MQTT Reference.
Example: Control the color of an RGB-LED
For this example you will need at least one motor fader tile and one RGB LED button tile (8 buttons) in one Tile Chain which is connected to a Tiles Hub.
With this flow you have the possibility to adjust color and brightness of the first RGB LED with the help of three controls (motorized faders). The special feature is that you don't have to create a mix of the primary colors red, green and blue yourself, but can use the HSL system. This means that the first fader (far left) adjusts the hue, the second fader adjusts the saturation and the third fader adjusts the lightness. If you are not familiar with this principle, the w3schools page Colors HSL may be helpful.
In addition, the adjacent button LEDs (2, 3 and 4) indicate the red, green and blue components, respectively, from which the color of the first RGB LED was mixed.
Download and installation
Download the flow JSON file and copy & paste or import it into your Node-RED. You should get this result:
You will need to make some adjustments for the flow to work in your setup:
- In all MQTT nodes ("Fader" and "Button Color") you have to enter the address of your MQTT broker. If you want, you can use the default setting
test.mosquitto.org:1883, but we strongly recommend using a broker on the local network for latency reasons.
In the four MQTT nodes "(...) Button Color" you have to enter the UID of your Tile Chain in the topic so that the Tiles Hub knows which widgets it has to control. How to find out the Tile Chain ID can be found in the article The Tiles Hub. Just replace the string "TILE_CHAIN_ID" which is highlighted in the screenshot below with your Chain ID.
Note: There is no need to enter the Tile Chain ID into the "Fader" nodes, because in this example we catch all Tile Chains with the "+" wildcard. Nevertheless, you may of course specify a Tile Chain ID in these nodes - whatever your setup requires.
Let's give it a go!
Once you have (correctly) configured and deployed the flow, it is time to test it. For a start, try setting the 2nd fader (saturation) to maximum, setting the 3rd fader (lightness) to the middle position and then slowly moving the 1st fader (hue) over the entire distance.
Feel free to play around with this flow. If you have other MQTT hardware, try to integrate it and let it communicate with MakeHaus!
More examples will follow!