Online motion sensor not showing up in log

New to openHAB: In the process of migrating my ABB Free@Home smarthome setup and have been successful in installing binding, discovering things / channels / items linking (PaperUI) and also using VS Code for customising items list and sitemap.

I am in the process of entering the rules section, but struggle to understand the motion sensors. I have some motion detectors which are not linked directly to the lights in the ABB system, i.e. light triggered by event/logic in addition to manual switch.

So in order for me to continue the openHAB rules approach I would like to learn more about the sensor behaviour/state. The motion detectors are successfully discovered after installing the Free@Home binding, and are also displayed as online in PaperUI. However, no reference to these detectors are found in the openhab log (no general reference / state change reference).

Any tips/ideas? I would like to know the state/behaviour (ON/OFF vs OPEN/CLOSE) of the detectors and use them in combined rules to have timer/loop for ON/OFF for light if motion detector only is active and to override the motion detector using the wall switch.

  1. Have you linked the Channels on the Things to Items? The Channel entry in PaperUI will tell you what sort of Item you need to link it to. It it’s a Switch then ON/OFF If it’s a Contact then OPEN/CLOSED.

  1. Which log file are you looking in? events.log will show event state changes. Once a Channel is linked to an Item, you should see entries in events.log every time the Item changes state in response to motion detections.

Appreciate your help.

The channel and item is already linked. Here the item is defined as a Switch. However, uncertain if this is just manually setup in the binding, or if it is the «actual» type.

And yes, I am using the event log, but the event log does not reference any data for when the motion detector is actually triggered. Is there another way of checking item state?

Show your Item definition.

  1. PaperUI view of the Things / Channel / Item configuration

  2. VS Code item (items/links were autogenerated in PaperUI using “simple mode”, then regenerated in the VS Code items.list using the OpenHab extension)

Switch   BevFolerVaskerom_FhSwitchChannel   "Activate" <motion> {channel="freeathome:switch:ABBXXXXXXXXX_ch0001:fh_switch_channel"}

And the hidden frame for (1) and the XXXXXXXXX for (2) is the serial number of the device which is confirmed to actually be the motion detector. As mentioned, the detector is not physically linked directly to the lights (I have the Free@Home setup with bus cable, and I am currently using the detector in event/action configuration within the F@H programming). However, the options are somewhat limited within F@H programming, so i want to use OpenHab to extend my possibilities.

How did you unlink and delete the Items when you moved from simple mode to .items files? Sometimes there are problems where the Link sticks around even when you delete the Item through PaperUI first.

The Item looks correct and the Thing is showing as Online. The Channel is also showing that it thinks it is linked to an Item.

Run a test.

I’m assuming you do not have restoreOnStartup with persistence yet.

  1. Restart OH
  2. Watch openhab.log for OH to finish starting up and settle down
  3. Watch events.log
  4. Trigger the motion sensor. Do not trigger the sensor before this point.

You should see the Item changing from NULL to ON in events.log. If you do not then see the Item changing state then the problem is with the binding and I can be of no further help.

This Item should appear in the Control tab in PaperUI as well. Or you can create a sitemap or HABPanel to show your Item’s state.

I used the “create items from channels” in VS code and deleting the PaperUI generated links. It seems to have made the trick for dimmers, switches, thermostats etc (tested using sitemap and BasicUI), so I don’t believe that’s the issue.

The test makes no difference, triggering of detector will not show up as a state change for the detector itself in event log. However, as mentioned, the detector is not linked directly to the lights in the “mother system”, having a wall switch in addition. So what happens (eventlog) when the detector is triggered is that the SwitchID_dimmer_switch “change from OFF to ON” and SwitchID_dimmer_value “change from X to Y” (nothing about the DetectorID itself).

In order to be able to use the Detector in some rules, I will need the state (I guess), but then it seems as there are some issues with the binding.

Well, now I managed to do a workaround which is recognised both by the bridge and by the binding/openhab. So now I have 2 items (motion detector and wall switch working and logging state change). The motion detector is not wired/linked to any lights as is, and is logged with state ON/OFF based on actual motion. The wall switch is wired/linked to the lights, and is the actual actuator of the lights, and is also logged with state ON/OFF. So I have 2 items to include in my rules, however, in order for the motion detector to activate the lights it must “activate” the wall switch.

I want to achieve by a rule to turn on lights by motion, turn off lights after X minutes after last recognised movement (restart timer if new movement is recognized) and also to override motion timer if manually pressing the wall switch ON. Have been reading a lot on the forum, so uncertain if this is possible as the motion detector need to command the wall switch for the lights to go ON?

I have started the rule with the code shown at the bottom:

  • With this rule I get a error message as stated below, so the timer function does not work for shutting OFF the lights (
2019-02-23 15:45:49.930 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Motion Trigger': cannot invoke method public abstract boolean org.eclipse.smarthome.model.script.actions.Timer.hasTerminated() on null
var Timer motionTimer = null
var boolean override = false
var String whoCalled = "manual"

rule "Proxy Commanded"
when
    Item LightProxy received command
then
    // Forward ON commands always
    if(LightProxy.state == ON && BryterVaskerom_DimmerSwitch.state != ON) BryterVaskerom_DimmerSwitch.sendCommand(ON)

    // Only send off if not overridden
    else if(!override && BryterVaskerom_DimmerSwitch.state != OFF) BryterVaskerom_DimmerSwitch.sendCommand(OFF)
end

rule "Motion Trigger"
when
    Item BevFolerVaskerom_FhSwitchChannel changed from OFF to ON
then
    // Motion sensor is sending this command
    whoCalled = "motion"
   
    // Turn on the light
    LightProxy.sendCommand(ON)

    // Set/Reset timer for fifteen minutes to turn off the light
    if (motionTimer !== null || !motionTimer.hasTerminated) {
        motionTimer.reschedule(now.plusMinutes(15))
    }
    else {
        motionTimer = createTimer(now.plusMinutes(15)) [|
            LightProxy.sendCommand(OFF)
            motionTimer = null
        ]
        }
end

rule "Light received update"
when
    Item BryterVaskerom_DimmerSwitch received update
then
    // Called whenever the Light's state is updated, its purpose is to tell the difference between a Motion triggered 
    // event and a manual event and set the override accordingly.

    // Light was turned ON and whoCalled is "manual", light is overridden
    if(BryterVaskerom_DimmerSwitch.state == ON && whoCalled == "manual") override = true
 
    // Light was turned OFF, reset override
    else override = false

    // reset whoCalled back to manual
    whoCalled = "manual"

    // update the Proxy in case the light was changed at the switch, use postUpdate so rules don't trigger
    if(BryterVaskerom_DimmerSwitch.state != LightProxy.state) LightProxy.postUpdate(BryterVaskerom_DimmerSwitch.state)

end

See Design Pattern: Manual Trigger Detection for how to tell if the light was manually turned on. See Design Pattern: Motion Sensor Timer for how to implenent the motion sensor timer. Given the names of since of your variables I suspect you ashtray found these though.

As for the error, because the last line of your time’s lambda is to set the variable to null, there really is no reason to check for hasTerminated. The variable will be set to null before hasTerminated would return false.

I can’t say why the code as written is generating an error. But since there is no need to test due hasTerminated, we can avoid the error though.

And once you are only checking for null, you can use

motionTimer?.reschedule(now.plusMinutes(15))

The ? replaces the if{motionTimer !== null)

Really appreciate your help, and the quick and constructive response (noob when it comes both to openhab and programming although having a Java class 15 years ago…)

I changed my code for the motion/timer section based on your tips and links, but I still do not end up with a LightProxy OFF (i.e. lights off). I enter my motion rule successfully, LightProxy ON (lights actually on), but I do not get the LightProxy OFF (lights off) from the rule below:

rule "Motion Trigger"
when
    Item BevFolerVaskerom_FhSwitchChannel changed from OFF to ON
then
    // Motion sensor is sending this command
    whoCalled = "motion"
   
    // Turn on the light
    LightProxy.sendCommand(ON)

    // Set/Reset timer to turn off the light
    if (motionTimer === null) {
        motionTimer = createTimer(now.plusMinutes(1)) [|
            LightProxy.sendCommand(OFF)
            motionTimer = null
        ]
    }
    else {
        motionTimer.reschedule(now.plusMinutes(1))
    }
end

Add logging to see what parts of the rule are executing and the values of important variables and Item states. This should tell you whether the right parts of the rule are executing and why.

Again, appreciate the help.

I managed to succeed editing my rules to get the timer function working, thanks

Will have a look into the “Manual trigger detection”, although I suspect I will meet some challenges. My motion detectors need to “activate” the wall switch for the light to turn on, however, I am not able to activate my wall switch without motion being triggered first.

So i guess it will be difficult to segregate events here as I regardless will have Motiondetector activate --> Wall switch activate --> Lights on. If i press wall switch afterwards, the wall switch (the lights associated with it) will already be on, and I will have no event change to “rule” on.

There might be an update. If so you can use that event. If not then you are right, there won’t be any event to detect for the manual trigger.