Fibaro motion sensor not turning on a light via rule

I’m running OpenHab 2.4 on a RPi 3 with a Zwave 2.5 snapshot (needed this because my motion sensor was not in the 2.4 version). I have a Fibaro FGMS-001 ZW5 v3.3 motion sensor and Linear LB60Z-1 lights. I am new to rules as my previous project was to monitor and store energy readings. I did put the Controller in the Motion Association group (as recommended in another post). I am getting output when triggered.

2019-01-21 13:43:28.750 [vent.ItemStateChangedEvent] - ZWaveNode007FGMS001MotionSensor_BinarySensor changed from OFF to ON
2019-01-21 13:48:50.555 [vent.ItemStateChangedEvent] - ZWaveNode007FGMS001MotionSensor_BinarySensor changed from ON to OFF

I had grand ideas initially with the rules, but am down to this:

rule "Motion activated lights on"

when Item ZWaveNode007FGMS001MotionSensor_BinarySensor received command ON

then ZWaveNode012LB60Z1DimmableLEDLightBulb_Dimmer.sendCommand(100)


When I open this file in Visual studio I get output errors:

[Error - 3:44:47 PM] Connection to server is erroring. Shutting down server.

[Error - 3:44:47 PM] Connection to server is erroring. Shutting down server.

But when I save the file anyway I get an okay?

2019-01-21 16:03:25.222 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘Motion.rules’

Any ideas?

It doesn’t receive a command ON. It gets an update. Rule of thumb in openHAB, updates come in from sensors and commands go out to actuators.

That’s about Visual Studio Code setup, it’s trying to find a connection to your live openHAB service (so it can ask about Item names etc.)
You need to look into VSC settings.

Thanks One solved completely and the other I need to do more work
part 1 - The update versus command fixed the problem. Now I’m going to try to turn it off and turn it to different settings based on the ambient light.
Part-2 - I understand the settings issue, but will need to work on figuring what I need to do

Again thanks

Same configurations as above. I now have the lights turning on and off and the VSC errors gone. I’m now trying to stop the lights from turning on if it is too bright. I have copied the rules from others in the forum, but it doesn’t seem to be picking up the reading from the Light sensor. I’m not getting errors.

rule “Motion activated light on”
when Item ZWaveNode007FGMS001MotionSensor_BinarySensor received update ON
if (ZWaveNode007_SensorLuminance.state < 400)

Also one add’l nit. I had to copy node9 sendCommand twice as it was ignoring the first one.

Any ideas would be appreciated

You forgot the braces :wink:

I don’t know if I should keep adding to this post as I stumble from one problem to the next, but here goes. I now have the lights working on motion detection except if it too bright. Using this

Rule “Motion activated light on”
when Item ZWaveNode007FGMS001MotionSensor_BinarySensor received update ON
var light = ZWaveNode007_SensorLuminance.state as Number
if( light < 7 ) {
else if( light > 7 ) {
logWarn(“event”, “too Bright”)

What I would like to add now that between the hours of 23 and 06 only one light goes on. All the examples are far more complex and I’m struggling with the proper DateTime format. Something like this (this doesn’t work)

TimeHour Now = now.TimeHour
logWarn("event", Now)
if( 6 < Now < 23 ) {

I could use a pointer

Hi Bob

I have a similar setup in my winter garden:

rule "Light Winter garden ON"
    Item PIR_Wintergarten changed to ON
   if (luminosity_Wintergarden.state < 2 && !(now.getHourOfDay < 1 && now.getHourOfDay > 5)) {
    sendCommand(Licht_WG, ON)

rule "Light Winter garden OFF"
    Item PIR_Wintergarten changed to OFF
    sendCommand(Licht_WG, OFF)

Just as an example …

Thanks. Being new I have a followup. I’m assuming && means “and” , but what does the ! mean?

! means not. || means or. && means and. Although I’m a little puzzled by the example. It would seem that the clause would always be false; how can the hour ever be less than 1 and greater than 5 at the same time? Seems like it is always false, and the ! makes it always true. So only the luminosity is being checked?

Thanks for the explanation. I don’t recall seeing that anywhere in the documentation. I will be a big help.

It’s not easy to find, but you can see a bit of documentation here:

Hello John,
Thanks for your comment.
I never checked if rule works as expected, tried today with more friendly times and it works.
So if HourOfDay is between 2 and 4 the lights will not go on (I tried of course when luminosity was 0).
If it is for instance 3 o’clock the result is true, the “!” sets it to false and the “&&” with luminosity leads to false …

I made this rule just for “learning by doing”, and to give my dog a few hours rest, if sleeping in the winter garden and moving around in the middle of night :wink:

At 3 o’clock, the statement below is false. Neither side is true. At 6 o’clock, it is also false as only the right side is true. At 00:30, it is also false since only the left side is true. There is no hour that is less than 1 and greater than 5.

If you want to turn on the light only before 01:00 or after 05:00 depending on luminosity (is that what you want?), I think you want this:

if (luminosity_Wintergarden.state < 2 && (now.getHourOfDay < 1 || now.getHourOfDay > 5))

With the OR, 6 o’clock will cause the time check to be TRUE and it will turn on depending on the luminosity. At 3 o’clock, the time check is FALSE, so it won’t turn regardless of the luminosity.

On the other hand, I could have missed something completely, and if it works for you, it must be doing what you want.

Thanks for your reply and explanation.
Not sure what I did yesterday that it worked, I tried today again and the lights went on …
Changed to your version and it is working now as expected!
Thanks from my dog :wink: she will have now a restful sleep between 1 and 5 …