Motion Sensor Binding - On/Off Toggle to Trigger Lights

Hey all,

I am setting up a large scale OpenHAB network for an industrial building and seem to have hit a snag with the motion sensors. The client would like this to work in such a way that as soon as a motion sensor detects motion in a room the lights automatically turn on and when motion isn’t detected for a period of time the lights turn off. Simple enough of a request. However, the issue that I am having is that once I bind the motion sensor as an item/thing in OpenHAB it does not toggle on/off for motion detection. OpenHAB sees the item and knows that it is there, but it does not toggle on/off relative to motion detected in a room. I think I am missing something here.

I have the motion sensors connected to an SNMP relay which is bound to OpenHAB itself. I am able to bind the motion sensors in OpenHAB via the OID of the SNMP relay and the DIN slot that said motion sensor is connected to. Example below.

SNMP Relay “Thing”: Thing snmp:target:DenkoviSNMP_Device1 “SNMP Denkovi Relay 1” [hostname=“x.x.x.x”, port=“xxx”, community=“public”, protocol=“v2c”] {
Channels:
Type switch : motionChannel “Motion 1” [ oid=“.1.3.6.1.4.1.42505.8.2.1.1.3.0”, onValue=“1”, offValue=“0” ]
Type switch : motionChannel “Motion 2” [ oid=“.1.3.6.1.4.1.42505.8.2.1.1.3.1”, onValue=“1”, offValue=“0” ]

Motion Sensor “Items”: Switch MOTION_1 “Motion 1” (M1) [“Motion”] { channel=“snmp:target:DenkoviSNMP_Device1:.1.3.6.1.4.1.42505.8.2.1.1.3.0:binary-switch-value” }
Switch MOTION_2 “Motion 2” (M2) [“Motion”] { channel=“snmp:target:DenkoviSNMP_Device1:.1.3.6.1.4.1.42505.8.2.1.1.3.1:binary-switch-value” }

Do I have this misconfigured? Am I missing something? Any help would be greatly appreciated. I just need to get these motion sensors to toggle motion within OpenHAB and then activate lights upon detecting motion.

Thank you!

Also, please use code fences.

```
code goes here
```

This is going to be the thing that kills @whowhatwhyhow 's use case. If you have to poll you’ll never have a situation where as soon as the motion is detected the light turn on. You will have up to the polling period before the lights turn on. And SNMP isn’t really meant to be polled at the subsecond polling period IIRC.

But isn’t a that what a trap is? @whowhatwhyhow, have you read and set up your trap port as described in the docs? You either need to run openHAB as root or you need to set to a high port and then configure your devices to publish traps to the openHAB host and port.

Based on the docs for the add-on, there is no such thing as a motionChannel type. It needs to be “switch”.

I’d also add that this can get complicated fast in a home (can’t imagine an industrial setting). I have 3 motion detectors in the kitchen as a group (one is not enough to cover all the entrances-200 sq. ft.). If my spouse is quietly chopping vegetables the lights might go OFF, so I have a “mode” that overrides OFF during typical dinner hours. In the business situation if someone is working quietly the computer the lights might go OFF? Also, if the lights are OFF for a slide presentation the lights might not stay OFF (at home I have a mode to keep the lights off). Also, at home I have a light sensor (who wants lights to go on if it is bright and sunny?) TBH with industrial LEDs over 100+ lumens per watt, it might not be worth it. The spouse acceptance factor is one thing, but employees? Also at home the switches still work normally.

rule "Turn Kitchen Lights OFF"
when Item KitchenMotion changed to OFF  // Group of three
then
    val mode = Downstairs_Mode.state.toString // Dinner, Night, Party
    val mode2 = Nook_Puzzle.state.toString // Not much movement (blocks off to 1 hr)
    Thread::sleep(350)
    val status = Kitchen_6_Pack_3.state.toString
    if (status == 'ON' && mode != 'Party' && mode2 != 'Puzzle') {
        Kitchen_6_Pack_3.sendCommand (OFF)
        // logInfo("rules", "6-pack OFF")          
    }
end

The ON checks for TOD and light

rule "Turn Kitchen Lights ON"
when Item KitchenMotion changed to ON
then
    var Number hourofday = now.getHour()  // not ON for refrigerator raids
    var lumins = Nook_luminence_hour_average.state as Number
    Thread::sleep(300)
    val status = Kitchen_6_Pack_3.state.toString
    if (lumins < 1000 && hourofday < 23 && hourofday > 5 && status != 'ON') {
        Kitchen_6_Pack_3.sendCommand (ON)
        // logInfo("events", "6pack ON")
    }
end

Adding to the above SNMP V2C which appears to be the supported version is UDP based and the traps are fire and forget no guarantee of them getting to openHAB.

I had a quick look at their website (no specifics in your post) and there also appears to be an HTTP based interface on some boards and it calls out support for that in openHAB.

Also from a motion sensor for industrial use cases adding infra red based sensors is a more favourable alterntive.

You may have no choice but to interface to those devices so i would suggest to look to the HTTP interface.

I will add that for both SNMP and HTTP i would stress test the performance because high polling rates in both SNMP & HTTP) could overwhelm little processors like these very easily.

No, I have not set up the SNMP trap at all. Admittedly I do not know much about how an SNMP trap works and was of the mindset “I will get to that after I get these motion sensors working”. From the sound of things, though, I may just have to abandon SNMP all together for these motion sensors.

The deeper I get into this the more I am coming to the conclusion that this system may not work in the way that the client would like. It is going to get very complicated very quickly, but a best effort must be made. I am debating on attempting to use Zwave motion sensors to make things more simple from a connection perspective.

Infra red sensors is actually a really great idea. Thank you for suggesting that.

As for the Denkovi http interface I actually use that very frequently to monitor/troubleshoot connections on the DIN slots/relays. Its not a bad idea to try and set up polling off of HTTP instead of SNMP.

Thank you to everyone that replied here. All of these responses helped to push me in directions I had not considered before and also filled in knowledge gaps. I am still very new to OpenHAB so I am learning each day.

I’ve made some config changes to my items and things files and appear to have made some progress in the correct direction(motion sensors actually show up as “Motion Sensor” now!). However, I am still having difficulty getting the motion toggling to work. I’m definitely missing something here.