Xiaomi Doorsensor

Hello,

I’m not new to openhab, I have been using it for a while now. But I want to start making rules. First ones work oke, but this one is a little more complicated.
I want to switch on a light in the laundry when the door opens and switch it off when the door is closed. Like the light in the fridge:)

I tried the following code using visual studio code:

rule “Washok Licht aan/uit”
when
Channel “WashokDoorSensor_OpenStatus” triggered START
then
sendCommand(FF_Switch_Washok_Switch, ON)
end

But nothing happens. Does someone could help me out?

thanx a lot:)

Use code fence please.

Why do you use channel to trigger. Doesn´t your door sensor have an item?

I believe this is what it could be like:

rule "Washok Licht aan/uit"
when
      Item <door sensor item> changed 
then
	if(<door sensor item>.state == ON) {
          FF_Switch_Washok_Switch.sendCommand(ON)
     logInfo("info", "door sensor is open")
    }

else
          FF_Switch_Washok_Switch.sendCommand(OFF)
end

Notice if the door sensor reports ON/OFF or OPEN/CLOSED. If it reports OPEN/CLOSE, then you´ll need to change the arguments. (normally a door sensor will report OPEN/CLOSE).

Thnx, it works. Only changed the items and status OPEN instead of ON.:grin: