[SOLVED] This rule worked quite well but seems to have broken

Hi All

I’m on 2.4 Stable of OH2 and this used to work well (on 2.4 Snapshot), but what occurs is the lights are not dimming any more when you press play.

I can see the log turning the motion sensor on and off to prevent the lights going on/off during the movie but the dimming is failing.

Any thoughts as to why or how I can troubleshoot? I checked the items states and they are showing as OK.


var Number percent = 0
var Timer fade_timer = null


rule "When Kodi Player changed to PLAY"
when
        Item myKodi_control changed
then
if (myKodi_control.state == PLAY){
    FibaroEye1Motion_Armed.sendCommand(OFF)   // Disable the motion sensor from turning on
    //Slowly Dim the Lights if they are on
    if (LivingRoomSw1.state == ON) {
        if (fade_timer === null) {
           percent = LivingRoomDim1.state as Number
           fade_timer = createTimer(now.plusMillis(100), [ |
                if (percent > 0) {
                    percent = percent - 2
                    if (percent < 0) percent = 0
                    LivingRoomDim1.sendCommand(percent)
                    fade_timer.reschedule(now.plusMillis(100))
                } else {
                    fade_timer = null
                }
            ])
        }
    }
}
else {
     FibaroEye1Motion_Armed.sendCommand(ON) // Enable the motion sensor for any other state of myKodi_control
}
end

You could insert some logInfo() to find out what happens - does the rule trigger, what values are you handling?

Completely random guess, the dimmer value has become a dimensionless number type.

1 Like

I had a logInfo after the

    FibaroEye1Motion_Armed.sendCommand(OFF)

And I saw it turn the Motion sensor off…

Where else would you suggest rossko57? Thank you!

The timer is only 100ms.
Try a longer one 250ms and decrement by 5
Visually there shouldn’t be much difference

1 Like

The timer worked fine though Vincent previously, this rule hasn’t changed :frowning:

Just try, why not.
And add a logInfo in the timer loop

1 Like

Like so?


rule "When Kodi Player changed to PLAY"
when
        Item myKodi_control changed
then
if (myKodi_control.state == PLAY){
    FibaroEye1Motion_Armed.sendCommand(OFF)   // Disable the motion sensor from turning on
    //Slowly Dim the Lights if they are on
    if (LivingRoomSw1.state == ON) {
      logInfo("TEST","TEST")
        if (fade_timer === null) {
           percent = LivingRoomDim1.state as Number
           fade_timer = createTimer(now.plusMillis(250), [ |
                logInfo(Timer, "Timer Loop")
                  if (percent > 0) {
                    percent = percent - 5
                    if (percent < 0) percent = 0
                    LivingRoomDim1.sendCommand(percent)
                    fade_timer.reschedule(now.plusMillis(100))
                } else {
                    fade_timer = null
                }
            ])
        }
    }
}
else {
     FibaroEye1Motion_Armed.sendCommand(ON) // Enable the motion sensor for any other state of myKodi_control
}
end


We only know what you tell us. We can’t see your logs.

Obviously an important thing would be if commands are sent to to LivingRoomDim1, does that happen?
If not, then the value of percent is likely not what you expect. Find out.

I rebooted OpenHab and things started to work as expected. I’ve no idea :confused: