Search code examples
xbmcopenhab

Openhab rules issue


I was wondering if anyone can help to figure out why my openhab rule does not identify the change in state of my xbmc player when playing a movie.

The openhab server correctly identifies the change in state enter image description here

But my rules do not trigger:

rules:
val Functions$Function1 dimLiving = [ int dimlevel | 
    //var boolean scene = (Scene_Living.state == 11); 

     // Only dim lights when a certain scene is selected
    //if(scene) {
       // sendCommand(Lamp_Living_Small, dimlevel)
       //s sendCommand(Lamp_Living_Floor, dimlevel)
        sendCommand(Lounge_Light_Dimm, dimlevel)
   // }
]

rule "Lights on when paused"
when
        Item htpc_state changed from Play to Pause
then

        brightnessBeforePause = Lounge_Light_Dimm.state as DecimalType
        if ( brightnessBeforePause < 50){
              logInfo("Light", "Play to pause 2") 
              dimLiving.apply(50)     
        }

end

rule "Lights off when pause end"
when
        Item htpc_state changed from Pause to Play
then
        if (Lounge_Light_Dimm.state == 50){     
                 logInfo("Light", "Pause to play 1") 
                 dimLiving.apply(brightnessBeforePause)       
        }
end

I want to diim the Philips hue lights when the movie starts to play.

Everything is configured ok in the openhab.cfg


Solution

  • Did you define brightnessBeforePause? First line (after the imports, be sure to include those) should be

    var Number brightnessBeforePause
    

    And what is Lounge_Light_Dimm set to? If it's Undefined or Uninitialized both rules won't work. Try setting the lamp to a certain dim level before testing these rules.