Home Assistant with Aqara contact sensor "bounces"

I have new Aqara contact sensor and M2 hub. Hub is configured in Home Assistant (HA). The sensor is connected a sliding glass door, and the magnet is on the frame. There is only two automation in HA:

  1. Turn on IKEA light when door opens.
  2. Turn off IKEA light when door closes.

Open the door, the light comes on (good). A second later, the light goes off. Several more seconds later, the light goes on again. And one minute after that, the light goes back off.

Close the door and the opposite set of steps happens.

As I said, the Aqara items are new. The battery on the sensor shows at 100% in Home Assistant. The M2 hub is connected by Ethernet cable, so this isn’t some kind of Wi-Fi interference. The contact sensor and the hub are about ten feet from each other, line-of-sight.

This is 100% repeatable. Note that the last transition happens after 1 minute every time. When I test this in Node Red and ran a debug node on it, the last two transitions happened at the same second in the minute (25 seconds after the top of the minute), regardless of when the door was opened or closed. And as I said, there are no other automation in Home Assistant.

Is the Aqara contact sensor the problem? Is not, what?

Can you share the Node Red flow ?

I have the same thing with my Aqara senses, I figured the rapid bouncing was just due to the physical nature of them and also having no debounce buffer. You should try using the ‘ for duration’ in your trigger.

For:
  Seconds: 1

I don’t have the M2 hub, but I have 6 connected with the ZHA integration. For me they’ve always worked perfectly without the issues you describe.

Here, the door has been opened for just over 3 minutes and the light turns ON/OFF perfectly fine every single time based on the state of the contact sensor.

Here’s the NR flow I used if you wanna test with on your end.

[{"id":"6d1d348f349a6e0c","type":"server-state-changed","z":"1962590eeaae6c55","name":"Entry Light ON/OFF","server":"d9a8f2ed.08cfe","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.entry_door","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":260,"wires":[["8e98e922fd4c72e6"],["0bbceb7a4e080e50"]]},{"id":"8e98e922fd4c72e6","type":"api-call-service","z":"1962590eeaae6c55","name":"light on","server":"d9a8f2ed.08cfe","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.entry","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":180,"wires":[["d39c3fb853555520"]]},{"id":"0bbceb7a4e080e50","type":"api-call-service","z":"1962590eeaae6c55","name":"light off","server":"d9a8f2ed.08cfe","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.entry","data":"","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":320,"wires":[["d39c3fb853555520"]]},{"id":"d39c3fb853555520","type":"debug","z":"1962590eeaae6c55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":860,"y":260,"wires":[]},{"id":"d9a8f2ed.08cfe","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

Good luck with it :+1:

Thanks for the suggestion.

Someone suggested (elsewhere) that the magnet might be too close. I managed to peel the magnet from its double-stick tape (the tape remained stuck to the door trim though), and positioned the magnet about 2mm further away. That seems to have done it.

Is it just me or is it a bit ironic that home assistant, a program to make your life easier at home, is so darn difficult to get stuff running? Perhaps Home Assistant needs an assistant.

I think it is just you.
And “issue” you had has nothing to do with HA.

I’ve figured out that the magnet was too close to the sensor (who’da thunk?). Also wondering if part of the issue is that the sensor and magnet are sliding past one another as opposed to pulling away directly.

Would have been nice for the sensor to have been engineering to not be so sensitive to the magnet being “too close,” but since it is working now (moved the magnet about two millimeters away), we’re good.

I have 4 on sliding windows, 1 on a sliding door and 1 on an entry door and they’ve never missed a beat. Glad you got yours working :+1: