FREE Shipping on orders over $49 USA $99 INTERNATIONAL

Control: LED Strip Control Software

LED Strip Control


So ssh into your pi or whatever your server may be.
The first thing we are going to do is create the LED Strip items.
So type in sudo nano /etc/openhab2/items/home.items and press enter, you may need to type in admin password. 
Type in: 
//LED Strip Control
Group MKLEDStripControl1Group "Desk LED Strip" (All)
Color MKLEDStripControl1Color "Desk LED Strip" <colorpicker> (MKLEDStripControl1Group) [ "Lighting" ]
String MKLEDStripControl1String "Desk LED Strip" (MKLEDStripControl1Group) {mqtt=">[broker:MK-SmartHouse/lights/MK-LEDStripControl1:command:*:default]"}
Dimmer MKLEDStripControl1Speed "Desk LED Strip Speed" <time> (MKLEDStripControl1Group) {mqtt=">[broker:MK-SmartHouse/lights/MK-LEDStripControl1:command:*:default],<[broker:MK-SmartHouse/lights/MK-LEDStripControl1/state/speed:state:default]", autoupdate="false"}
String MKLEDStripControl1Effect "Desk LED Strip Effects" <rgb> (MKLEDStripControl1Group) {mqtt=">[broker:MK-SmartHouse/lights/MK-LEDStripControl1:command:*:default],<[broker:MK-SmartHouse/lights/MK-LEDStripControl1/state/effect:state:default]", autoupdate="false"}
And press enter. 
Now press control x then y and enter. 
Next up is the sitemap file so we can control the device. 
Type in sudo nano /etc/openhab2/sitemaps/home.sitemap and press enter. It will bring up the sitemap. If you are following along with my series then we have many different frames in our sitemap. I am going to put the device in the frame called MK-Room. So go to the frame and type in:
Colorpicker item=MKLEDStripControl1Color
Selection item=MKLEDStripControl1Effect mappings=["NONE"="NONE", "FADE"="FADE", "POLICE"="POLICE", "COLD"="COLD", "WARM"="WARM", "BREATH"="BREATH", "RAINBOW"="RAINBOW"]
Slider item=MKLEDStripControl1Speed
and press enter
Now press control x then y and enter. 
There is one more thing we have to do and that is make a rule where it will convert the color picker into MQTT the device can understand. 
In terminal type in sudo nano /etc/openhab2/rules/home.rules and press enter. At the top of the file type in
var HSBType hsbValue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues
These are the variables the rules will be manipulating. 
In the bottom of the file type in: 
rule "MKLEDStripControl1"
 Item MKLEDStripControl1Color changed
     hsbValue = MKLEDStripControl1Color.state as HSBType
     redValue =
     greenValue =
     blueValue =
     RGBvalues= redValue.toString + ";" + greenValue.toString + ";" + blueValue.toString + ";"
     sendCommand(MKLEDStripControl1String, RGBvalues)
     logInfo("MKLEDStripControl1Color", RGBvalues )
What these rules do is take the values from the colorpicker and send them through MQTT. 
Great! Now press control x then y and enter. 
sudo systemctl restart openhab2.service