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 