Help with first rule

I am trying to modify one from the examples on github but not working. am sure i am missing something important.

The sensor is a fibaro motion sensor and the switch is a aeotec microswitch.

motion light rule:

var Number counter = 0
var Number lastCheck = 0

rule "WashroomLightOn"
        Item MainFloorWashroom changed from 0 to 1
        counter = counter + 1

                sendCommand(Smart6, ON)


rule "WashroomLightOff"
        Time cron "0 * * * * ?"
        if(lastCheck == counter) {
                counter = 0
                lastCheck = -1;
                sendCommand(Smart6, OFF)

        } else {
                lastCheck = counter

Check what is being reported in the openHAB event logs for your MainFloorWashroom item - and check your rule is looking for the right item values.

nothing is showing up in the log.

here are my items. i dont think i am using the right names.

//fibaro sensors

Group MainFloorWashroom “Main Floor Washroom”
Number Movement “Movement: [%s]” (MainFloorWashroom) { zwave=“5:0:command=sensor_binary” }
Number Alarm “Alarm: [%s]” (MainFloorWashroom) { zwave=“5:0:command=sensor_alarm” }
Number Lux “Lux: [%.2f Lux]” (MainFloorWashroom) { zwave="5:0:command=sensor_multilevel,sens$
Number Bat “Battery: [%d %%]” (MainFloorWashroom) { zwave=“5:0:command=battery” }
Number Temp “Temperature: [%.1f °C]” (MainFloorWashroom) { zwave="5:0:command=sensor_multilevel,sen$

//Aeotec Smart microswitch
Switch Smart6 “Smart6 outlet” (ALL,outlet) {zwave=“6:command=switch_binary”}

have also tried using Movement instead of MainFloorWashroom

You need to be checking the Movement item in your rule, not the group item.

And that item should probably be a Contact, rather than Number. A movement/door/window sensor is typically modeled as a Contact, which is either Open or Closed.

I would focus on getting your item configs correct first, and check you are seeing events on the openHAB event bus, before worrying too much about any rules.

I agree, I have changed the number to contact now and the 0 and 1 to CLOSED AND OPEN.

still not working.

thanks for your help, will keep working on this.

also just out of curiosity, why would the rules not work with numbers. when i enter the washroom, the number does change from 0 to 1.

It may well work with numbers, and if you would like to keep it that way (and it works) then feel free - it is just more standard/typical to use Contact items for these types of sensors.

the sensor stops reporting when I change the number to contact. Do i have to change anything else in my items when i make that change?

This is an item binding I have for a Fibaro motion sensor;

Contact PIR_Ensuite "Ensuite PIR" { zwave="22:command=SENSOR_BINARY"}

Notice there is no endpoint in the definition.