Item being switched off. At a loss!

Hi All,

My motion sensor keeps being switch off, at least once a day.

The ONLY rule which has control of this item FibaroEye1Motion_Armed is in the rule below:


rule "When Kodi Player changed to PLAY"
when
        Item myKodi_control changed
		logInfo("Kodi Changed", "Kodi 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

This is the only rule that can be causing this to the best of my knowledge as its the only rule which sends a command. The rest of the rules check for state of the item.

For whatever reason, it keeps setting the switch to off, which disables my motion sensor and subsequently my lights at night (highly annoying!)

A grep of my events log for OH2 shows no instances of ‘PLAY’ where by myKodi_control is being set to PLAY and therefore turning it off.

kris@openhab2:/etc/openhab2/rules$ cat /var/log/openhab2/events.log | grep PLAY

Any suggestions?? Losing my mind!

Further, is there a way for an item to have a default state of ON, even after restarts?

Thanks

You can’t have a logInfo in the when section. This definitely will give you an error in your openhab.log …
Put that line right after the then.

2 Likes

Yep, all good. I hadnt actually configure that as yet, but ive put a log right after the ‘then’ with a broadcast so I can see if this is indeed what triggers it.

Now the waiting game

Use a system-based trigger to initialize your item.

1 Like

Thanks marcel! that should ensure its on after reboots and so on. Hopefully that helps!