Hi guys,
I’m new here. Been using OpenHAB for sometime now and it’s really a great piece of software. I have a RPi2 hosting the server and I’m using WeMos D1 Mini to switch respective devices in my house. I have an RGB LED strip light setup with a custom PCB to power it. I have a ColorPicker setup in OpenHAB and its all works 100%.
I have Kodi setup with OpenHAB and when I click play/pause/stop I can get one of my other lights to switch ON/OFF. The problem I’m having is getting the RGB LED lights to switch or dim a certain color when either play/pause/stop is selected.
I need help with the .rules file. Can someone assist me in editting my rules file? Below are my current configuration files.
RULES
import org.openhab.core.library.types.*
var HSBType hsbValue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues
rule "Set RGB 2 value"
when
Item fWIFI_RGB_2 changed
then
hsbValue = fWIFI_RGB_2.state as HSBType
redValue = hsbValue.red.intValue
greenValue = hsbValue.green.intValue
blueValue = hsbValue.blue.intValue
RGBvalues= redValue.toString + “;” + greenValue.toString + “;” + blueValue.toString
sendCommand( WIFI_RGB_2_RGB, RGBvalues )
logInfo( “fWIFI_RGB_2”, RGBvalues )
end
rule "Adjust living room lighting when XBMC starts/stops"
when
Item XbmcLiving_State changed
then
var String state = XbmcLiving_State.state.toString()
switch (state.lowerCase) {
case "play" : MQTTLED.sendCommand(OFF)
case "pause" : MQTTLED.sendCommand(ON)
case "stop" : MQTTLED.sendCommand(ON)
}
end
ITEMS
Switch MQTTLED “” { mqtt=">[mybroker:home/ds/sidelight:command:ON:0],>[mybroker:home/ds/sidelight:command:OFF:1]" }
Color fWIFI_RGB_2 “LED Lights” (WIFI_RGB_2)
String WIFI_RGB_2_RGB (WIFI_RGB_2) { mqtt=">[mybroker:/openHAB/RGB_2/Color:command:*:default]" }
String XbmcLiving_State “Living State [%s]” { xbmc="<[#living|Player.State]" }
String XbmcLiving_Title “Living Title [%s]” { xbmc="<[#living|Player.Title]" }
String XbmcLiving_ShowTitle “Living Show [%s]” { xbmc="<[#living|Player.ShowTitle]" }
Switch XbmcLiving_PlayPause “Living Play/Pause” { xbmc=">[#living|Player.PlayPause]", autoupdate=“false” }
Switch XbmcLiving_Stop “Living Stop” { xbmc=">[#living|Player.Stop]", autoupdate=“false” }
String XbmcLiving_Notify “Living Notify [%s]” { xbmc="<[#living|GUI.ShowNotification]", autoupdate=“false” }
Dimmer XbmcLiving_Volume “Living Volume [%.1f]” { xbmc="=[#living|Application.Volume]" }
SITEMAPS
sitemap default label=“Robb Home” icon=“house”
{
Frame label=“Downstairs” {
Switch item=MQTTLED label=“Side Light”
}
Frame label=“TV Rainbow” {
Colorpicker item=fWIFI_RGB_2 icon=“slider”
}
Frame label=“Kodi” {
Group label=“Controls” icon=“kodi” {
Text item=XbmcLiving_State label=“State [%s]” icon="state"
Text item=XbmcLiving_Title label=“Title [%s]” icon=“title” visibility=[XbmcLiving_State==Play, XbmcLiving_State==Pause]
Text item=XbmcLiving_ShowTitle label=“Show [%s]” icon=“show” visibility=[XbmcLiving_State==Play, XbmcLiving_State==Pause]
Switch item=XbmcLiving_PlayPause label=“Play” icon=“play” mappings=[ON=“Play”] visibility=[XbmcLiving_State==Pause]
Switch item=XbmcLiving_PlayPause label=“Pause” icon=“pause” mappings=[ON=“Pause”] visibility=[XbmcLiving_State==Play]
Switch item=XbmcLiving_Stop label=“Stop” icon=“stop” mappings=[ON=“Stop”] visibility=[XbmcLiving_State==Play, XbmcLiving_State==Pause]
Slider item=XbmcLiving_Volume label=“Volume” icon=“volume” step=10
}
}