Last active
November 3, 2019 21:06
-
-
Save mec-kon/e4c0c31d593cc22c0699b9fac8d17851 to your computer and use it in GitHub Desktop.
openhab mqtt configuration files to control a led strip from openhab using my led-strip-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Group gLedStrips "LED Strips" (Home) | |
Color LedStripColor_1 "LED Strip" <colorpicker> (LivingDining, gLedStrips) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the device to which the message is to be sent | |
val mqtt_topic = "home/test" | |
var HSBType hsbValue | |
var int colorRed | |
var int colorGreen | |
var int colorBlue | |
var String RGBvalues | |
// mqtt:broker:mosquitto-broker is the Thing UID of the broker that should be used | |
val mqttActions = getActions("mqtt","mqtt:broker:mosquitto-broker") | |
rule "LEDStripControl_1" | |
when | |
Item LedStripColor_1 changed | |
then | |
hsbValue = LedStripColor_1.state as HSBType | |
colorRed = ((hsbValue.red.intValue * 255) / 100) | |
colorGreen = ((hsbValue.green.intValue * 255) / 100) | |
colorBlue = ((hsbValue.blue.intValue * 255) / 100) | |
RGBvalues = "{\"color_array\":[{\"color_red\":" + colorRed.toString + ",\"color_green\":" + colorGreen.toString + ",\"color_blue\":" + colorBlue.toString + "}],\"time\":0,\$ | |
mqttActions.publishMQTT(mqtt_topic, RGBvalues) | |
logInfo(mqtt_topic, RGBvalues ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sitemap wg label="Demo" { | |
Frame { | |
Group item=LivingDining | |
} | |
Frame { | |
Text label="Light" icon="light" { | |
Default item=LedStripColor_1 | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment