Sending RGB via MQTT from OH1.8.3 -- not updating colorpicker selection

I have defined the item, sitemap and rule for this to work.
It switches the light on and off.
It send RGB 0,0,0 via MQTT, but does not do any colour updates.
What am I missing?

.rules

var HSBType Light_House_Master_Bed_North_valueHSB
var int     Light_House_Master_Bed_North_valueRed
var int     Light_House_Master_Bed_North_valueGreen
var int     Light_House_Master_Bed_North_valueBlue
var String  Light_House_Master_Bed_North_valueRGB


// ------------------------------------------------------------------------
// --------------- Rules being tested -------------------------------------
// ------------------------------------------------------------------------


// ----- 160822 MaxG: colour light -----
rule "Set Light_House_Master_Bed_North value"
   when
     Item Light_House_Master_Bed_North changed
   then
     Light_House_Master_Bed_North_valueHSB   = Light_House_Master_Bed_North.state as HSBType 
     
     Light_House_Master_Bed_North_valueRed   = Light_House_Master_Bed_North_valueHSB.red.intValue
     Light_House_Master_Bed_North_valueGreen = Light_House_Master_Bed_North_valueHSB.green.intValue
     Light_House_Master_Bed_North_valueBlue  = Light_House_Master_Bed_North_valueHSB.blue.intValue
     
     logInfo("MasterBedNorth.rule", "valueRed..: " + Light_House_Master_Bed_North_valueRed.toString)
     logInfo("MasterBedNorth.rule", "valueGreen: " + Light_House_Master_Bed_North_valueGreen.toString)
     logInfo("MasterBedNorth.rule", "valueBlue.: " + Light_House_Master_Bed_North_valueBlue.toString)
     logInfo("MasterBedNorth.rule", "valueHSB..: " + Light_House_Master_Bed_North_valueHSB.toString)
     
     postUpdate(Light_House_Master_Bed_North_R, Light_House_Master_Bed_North_valueRed)
     postUpdate(Light_House_Master_Bed_North_G, Light_House_Master_Bed_North_valueGreen)
     postUpdate(Light_House_Master_Bed_North_B, Light_House_Master_Bed_North_valueBlue)
     
     Light_House_Master_Bed_North_valueRGB = "Values: "
       + Light_House_Master_Bed_North_valueRed.toString + "; "
       + Light_House_Master_Bed_North_valueGreen.toString + "; "
       + Light_House_Master_Bed_North_valueBlue.toString
     logInfo("MasterBedNorth.rule", Light_House_Master_Bed_North_valueRGB)
end

.items

Group gLight_House_Master_Bed_North    "Nightstand Max"    <switch>    (gHouse_Master, gHouse_Lights)
Color  Light_House_Master_Bed_North    "Nightstand Max"    <slider>    (gLight_House_Master_Bed_North)
Dimmer Light_House_Master_Bed_North_R    "Red [%d %%]"        <switch>    (gLight_House_Master_Bed_North)    {mqtt=">[mymosquitto:ArgyleCourt/House/Master/Light_House_Master_Bed_North/Red:state:*:default]"}
Dimmer Light_House_Master_Bed_North_G   "Green [%d %%]"        <switch>    (gLight_House_Master_Bed_North)    {mqtt=">[mymosquitto:ArgyleCourt/House/Master/Light_House_Master_Bed_North/Green:state:*:default]"}
Dimmer Light_House_Master_Bed_North_B   "Blue [%d %%]"        <switch>    (gLight_House_Master_Bed_North)    {mqtt=">[mymosquitto:ArgyleCourt/House/Master/Light_House_Master_Bed_North/Blue:state:*:default]"}

Sitemap

        Colorpicker item=Light_House_Master_Bed_North    icon="slider"

event log:

2016-08-23 09:22:47 - Light_House_Master_Bed_North received command ON
2016-08-23 09:22:51 - Light_House_Master_Bed_North received command 226.91943127962085,82.74509803921569,100
2016-08-23 09:23:00 - Light_House_Master_Bed_North received command OFF
2016-08-23 09:23:03 - Light_House_Master_Bed_North_R state updated to 0
2016-08-23 09:23:03 - Light_House_Master_Bed_North_G state updated to 0
2016-08-23 09:23:03 - Light_House_Master_Bed_North_B state updated to 0

openHAB log

2016-08-23 09:23:02.014 [INFO ] [del.script.MasterBedNorth.rule] - valueRed..: 0
2016-08-23 09:23:02.247 [INFO ] [del.script.MasterBedNorth.rule] - valueGreen: 0
2016-08-23 09:23:02.504 [INFO ] [del.script.MasterBedNorth.rule] - valueBlue.: 0
2016-08-23 09:23:02.731 [INFO ] [del.script.MasterBedNorth.rule] - valueHSB..: 226.91943127962085,82.74509803921569,0
2016-08-23 09:23:04.620 [INFO ] [del.script.MasterBedNorth.rule] - Values: 0; 0; 0

try this:

Light_House_Master_Bed_North_valueHSB   = Light_House_Master_Bed_North.state

var Light_House_Master_Bed_North_valueRed =Light_House_Master_Bed_North_valueHSB.getRed()
var Light_House_Master_Bed_North_valueGreen = Light_House_Master_Bed_North_valueHSB.getGreen()
var Light_House_Master_Bed_North_valueBlue = Light_House_Master_Bed_North_valueHSB.getBlue()
1 Like

If you want to react to an item receiving a command, use received command instead of changed. Then, in the body of the rule, you can use the receivedCommand variable to identify what the command was that was received.

1 Like

Thanks Watou! This did the trick…
I thought I had this before, but something else must have been wrong for it not to work at that time.
Now I am happy! :slight_smile:

1 Like