Lights using fibaro motionsensor

Hello all,
I’ve been trying for days now to get a rule working but it just won’t fire.
What i have now is coming from openhab wiki etc.

rule "Lamp bij binnenkomst"
    Item Motion_Living_Motion changed to 1
    logInfo("Verlichting", "Controleer lichtsterkte")
    //var Number Lichtsterkte = Motion_Living_Lux.state as DecimalType
    //logInfo("Verlichting", "Lichtsterkte = " + Lichtsterkte)
    if(Motion_Living_Lux.state < 200) {
        if(Dimmer_RGBWLiving_Red.state == OFF) {
            logInfo("Verlichting", "Verlichting aanzetten")
            sendCommand(Dimmer_RGBWLiving_Red, 35)
            sendCommand(Dimmer_RGBWLiving_Green, 100)
    } else {
        if(Dimmer_RGBWLiving_Red.state == ON) {
            logInfo("Verlichting", "Verlichting woonkamer is al aan")

I See the logInfo “Controleer Lichtsterkte” but the rest doesn’t show.
When i uncomment the var and loginfo i also see current lux in the log.
Any help would be really appreciated.
The items in my itemlist:

Number    Motion_Living_Motion        "Beweging Woonkamer [MAP(]"        <present>        (gGF,GF_Living)        { zwave="10:0:command=sensor_binary" }
Number    Motion_Living_Alarm            "Alarmstatus [MAP(]"                <fire>            (gGF,GF_Living)        { zwave="10:0:command=sensor_alarm" }
Number    Motion_Living_Lux            "Lichtsterkte Woonkamer: [%.2f Lux]"            <sun>            (gGF,GF_Living)        { zwave="10:0:command=sensor_multilevel,sensor_type=3" }
Number    Motion_living_Temperature    "Temperatuur Woonkamer: [%.2f &deg;C]"            <temperature>    (gGF,GF_Living)        { zwave="10:0:command=sensor_multilevel,sensor_type=1" }
Number    Motion_Living_Battery        "Batterij Bewegingsmelder Woonkamer [%d %%]"    <battery>        (gGF,GF_Living)        { zwave="10:0:command=battery" }

They all get updated on change

running Openhab 1.7.1

You should take a look for the information on using an endpoint=0:

The endpoint ID is only required/allowed when using the multi_instance
command class. In case a node consists of multiple instances or
endpoints, the instance number can be specified using this value. The
default value is not to use the multi_instance command class - the
number must be positive and must not be 0. An example of a
multi-endpoint device is the Fibaro FGS 221 double relay.


Yep, I’d definitely get rid of the endpoint ID.

My setup, that is working just fine is as follows:

Contact     S01D002_cMotion         { zwave="7:command=sensor_binary" }
Number      S01D002_nTemperature    { zwave="7:command=sensor_multilevel, sensor_type=1" }
Number      S01D002_nIlluminance    { zwave="7:command=sensor_multilevel, sensor_type=3" }
Number      S01D002_nBattery        { zwave="7:command=battery" }
Contact     S01D002_cAlarm          { zwave="7:command=sensor_alarm, alarm_type=0" }

In addition, I would suggest to use a typecast on the if statement, like this:

if ((Motion_Living_Lux.state as DecimalType) < 200) {

Thanks for the tips.
Oke, got rid of the endpoints, but still stuck at “controleer lichtsterkte”.
Furthermore i’ve added a typecast to the rule, but that didn’t help either.

Exactly what do you expect to see (“to be shown”)? I mean, depending on the state of your Dimmer_RGBWLiving_Ref item - given your if statements - there may actually be nothing to execute (and show).

If i understand the script correctly, then if the Dimmer_RGBWLiving_Red is off, and the lux is below 200 (which is always, just for testing) then i expect to see in the log “verlichting aanzetten” below the last line .
But if the status is on, then it would print “Verlichting woonkamer is al aan”

2015-10-14 22:02:26.621 [INFO ] [runtime.busevents             ] - Motion_Living_Motion state updated to 1
2015-10-14 22:02:26.647 [INFO ] [enhab.model.script.Verlichting] - Controleer lichtsterkte

Please correct me if I’m wrong, I’m new to openhab and rules.

Given that the Lux item is read from the device, I am not sure you can guarantee that this is below 200, can you?

Apart from that, I think you may have misplaced the “else” clause in your rule. As it is now there are two possibilites of “falling through” (i.e nothing will happen):

  1. If _Lux.state is less than 200 and _Red.state equals ON.
  2. If _Lux.state is equal to or more than 200 and _Red.state equals OFF.

If you want one of two things to happen (depending on the value of _Red.state) only when _Lux.state is less than 200, you need to write something like this:

if(Motion_Living_Lux.state < 200) {
    if(Dimmer_RGBWLiving_Red.state == OFF) {
        logInfo("Verlichting", "Verlichting aanzetten")
        sendCommand(Dimmer_RGBWLiving_Red, 35)
        sendCommand(Dimmer_RGBWLiving_Green, 100)
    else {
        logInfo("Verlichting", "Verlichting woonkamer is al aan")

I hope this helps.

1 Like

Correct me if I’m wrong but isn’t that the same rule that I already have and only the red.state == on removed?
Thought that it wouldn’t make a difference if i specified it (if it isn’t off then it’s on). If the lux is above 200 then nothing should happen. And if red.state is on then nothing should happen either.

The sensor is so located that it doesn’t reach the 200 lux (except when in summer the sun comes thru the window early in the morning), that’s the reason for the 200. If it works it wil go to something like 27 lux.

One other thing, now that I’ve removed the endpoint 0 the battery doesn’t get updated. It’s showing just - %.

Oke, It’s working now. Stupid from me, but I’m using a dimmer and that doesn’t have the status OFF, but instead it uses status 0 for off

Well, not exactly the same. In the original rule (that you show at the start of the thread) the else clause matches the following if statement:

 if(Motion_Living_Lux.state < 200) {

In that case, if, as you say, the lux is always below 200 you will only get some action if the _Red.state == OFF (or 0). Your test for _Red.state == ON (or 1) was in the else part of the code, meaning it would only be executed if the lux was equal to or greater than 200.

Anyway, good to hear that it is working now.

Your right, saw it later that there was a difference in the code. thanks for that!
To be complete, here is the working code (with English in the log :wink: )

rule "Lights on at motion"
    Item Motion_Living_Motion changed to 1
    logInfo("Lighting", "Check Lux")
    if((Motion_Living_Lux.state as DecimalType) < 200) {
        logInfo("Lighting", "Current Lux " + Motion_Living_Lux.state)
        if(Dimmer_RGBWLiving_Red.state == 0) {
            logInfo("Lighting", "Turn Lights On!")
            sendCommand(Dimmer_RGBWLiving_Red, 35)
            sendCommand(Dimmer_RGBWLiving_Green, 100)
        } else { 
            logInfo("Lighting", "Lights are already On!")

Thanks for all the help, now going to extend it to go auto off at a preset time.

@arjveld just out of curiosity…
This functionality is already build into the fibraro motion sensor, is there a specific reason that you want it as a rule in OH?
I wanted exactly the same, but used the buildin function. So that even if OH is down, this automatic switch of the light on & after a defined time off works well.

@marcel_verpaalen. I know that I can do that by association and give it a fixed time. The point is that I don’t always want the same lights to come on.
For example: between 16:00 and 1:00 I want the Red, Green and later some other to come on. But if I come out of bed in the middle of the night (between 1:00 and 6:00) I don"t want everything on. Then it’s enough to have one light on for 3 min.
This rule is basicly a startingpoint to expand.

Ah, yes I see, indeed that can only be done with some smart rule.
Challenge is only to get enough updates on the lux without draining the battery too fast. Or alternatively use the buildin funtion for the decision for brightness and the rule in oh for the smart other decisions.

did you succeed in adding a timer cause i’m currently trying to do the same.

kindest regards


I’ve succeded partially. I was able to create a timer for one item. When I’ve added a second timer the first timer also stopped working. At the moment the computer running openhab is down, so I can’t paste the rule here. When I have it up an running again I’ll post the rule here.

I have found the solution this weekend and will post the rule here this

Kindest regards

Hello @marcel_verpaalen

How do you have it configured? I have defined 30 as a Night and day offset and it is still active even with Lux values of 37. If I set this as a smart rule, it works well, but I want to use the sensonr’s built in.



Finally it is working. Seems like the sensor takes a while to “accept” the configurations.
Sorry for disturbing :smiley:

Hi @marcel_verpaalen @danielo515 Could you post your simple rules for the fibaro motion sensor (cateye)? I’ve got this as current setup…

What I would like to accomplish is that when motion is detected in my garage, the light goes on, when there is no more motion, the light goes out.

Switch light_Garage “Garage” (Lights,GV_Garage) { nikobus=“755C:4” }

Number Garage_Movement “Movement: [%s]” (SENSORS) { zwave=“3:0:command=sensor_binary” }
Number Garage_Alarm “Alarm: [%s]” (SENSORS) { zwave=“3:0:command=sensor_alarm” }
Number Garage_Lux “Lux: [%.2f Lux]” (SENSORS) { zwave=“3:0:command=sensor_multilevel,sensor_type=3” }
Number Garage_Bat “Battery: [%d %%]” (SENSORS) { zwave=“3:0:command=battery” }
Number Garage_Temp “Temperature: [%.1f °C]” (SENSORS){ zwave=“3:0:command=sensor_multilevel,sensor_type=1” }

rule "Garage licht aan"
Item Garage_Movement received update ON
sendCommand(light_Garage, ON)

rule "Garage licht uit"
Item Garage_Movement received update OFF
sendCommand(light_Garage, OFF)

thx in advance!