How to ignore some events

  • Platform information:
    • Hardware: Raspberry Pi
    • OS: Openhabian
    • Java Runtime Environment: openjdk version “1.8.0_152”
    • openHAB version: Openhab 2
  • Issue of the topic: With my garage door setup I use a reed switch to determine if the door is open or closed. Each time the garage door moves, it produces 3 events:

2019-02-22 09:23:02.287 [vent.ItemStateChangedEvent] - garageState1 changed from OPEN to CLOSED

2019-02-22 09:23:02.641 [vent.ItemStateChangedEvent] - garageState1 changed from CLOSED to OPEN

2019-02-22 09:23:02.652 [vent.ItemStateChangedEvent] - garageState1 changed from OPEN to CLOSED

I believe this is due to the switch passing over the magnet.

Is there any way to ignore the first 2 events and only report the last one?

My rule sends notification with the change in state:

rule “Main Garage Open”
when
Item garageState1 changed from CLOSED to OPEN
then
Echo_MusicBox_TTS.sendCommand(‘Main Garage Door Open’)
end

Wired reed switches are so inexpensive it might be worth replacing them with one that exhibits a better behavior. I do not see this same behavior with my reed sensors.

There is no easy way to do this. What you would have to do is create a Timer on the first event, return from the Rule when the timer exists, and in the body of the timer check the state of the sensor and report that when the timer goes off.

Thanks… I was thinking along the same lines. I’ll see if I can get different switches.

I use these for my garage doors.

Great… I’ll check them out. Thanks

gpio pin or mqtt ,resistor added or not ,if gpio pin debounce: ?
reed switch he needs 4.7k resistor or 10k ,and to be sure a debounce:10

{ gpio="pin:27 force:yes debounce:10" }

I am using mqtt. There is a resistor in line. Not sure of the ohm, built this a few years ago.