Here is my Node Red flow to “fake rearm” the modified motion sensors within HA. I am sure there are better ways of doing this, but this works well for me. The flow can handle an arbitrary number of motion sensors, below has two as example. The flow can handle an arbitrary rearm delay, the example uses 10s; however, nothing outside the range of about 6s and 90s makes sense. You’ll need to modify to point to your own MQTT server.
[
{
"id": "1988cfb9.49c74",
"type": "tab",
"label": "Fix Aqara Motion Sensors Occupancy Reset",
"disabled": false,
"info": "This flow resets occupied state of Aqara mini motion sensors to false after a set of seconds after it goes true. This goes hand-in-hand with the \"famous\" hardware mode of the Aqara sensors that allows them to retrigger after 5 seconds rather than 90 (but the HA software still assumes 90 seconds, hence the need for this).\n\nMAJOR CAUTION: ensure there is NO CHANCE of an infinite loop in flows like this -- first iteration of this took down HA and generated millions of MQTT updates. Specifically, you MUST ensure that the flow has no chance to process it's own output. This flow sets a flag and kills output if flag is thusly set. There may be other methods to achieve same result, TBD."
},
{
"id": "25e97774.b16c38",
"type": "mqtt in",
"z": "1988cfb9.49c74",
"name": "motion-01 in",
"topic": "zigbee2mqtt/aqara-motion-01",
"qos": "0",
"datatype": "json",
"broker": "224853ed.7c89fc",
"x": 90,
"y": 40,
"wires": [
[
"3f4a6e85.e15e52"
]
]
},
{
"id": "3f4a6e85.e15e52",
"type": "function",
"z": "1988cfb9.49c74",
"name": "Occupancy FALSE when Occupancy TRUE",
"func": "if( msg.payload.occupancy == true && msg.payload.occupancy_reset_by_flow != true ) {\n msg.payload.occupancy = false;\n msg.payload.occupancy_reset_by_flow = true;\n} else {\n msg = null;\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 410,
"y": 100,
"wires": [
[
"a732b7ee.e4df98"
]
]
},
{
"id": "4abd3efb.dc3cb",
"type": "debug",
"z": "1988cfb9.49c74",
"d": true,
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 510,
"y": 220,
"wires": []
},
{
"id": "a732b7ee.e4df98",
"type": "delay",
"z": "1988cfb9.49c74",
"name": "",
"pauseType": "delay",
"timeout": "10",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 300,
"y": 160,
"wires": [
[
"4abd3efb.dc3cb",
"36bdf49d.6985ac"
]
]
},
{
"id": "36bdf49d.6985ac",
"type": "mqtt out",
"z": "1988cfb9.49c74",
"name": "",
"topic": "",
"qos": "",
"retain": "",
"broker": "224853ed.7c89fc",
"x": 530,
"y": 160,
"wires": []
},
{
"id": "f98c657a.f56468",
"type": "mqtt in",
"z": "1988cfb9.49c74",
"name": "motion-02 in",
"topic": "zigbee2mqtt/aqara-motion-02",
"qos": "0",
"datatype": "json",
"broker": "224853ed.7c89fc",
"x": 90,
"y": 100,
"wires": [
[
"3f4a6e85.e15e52"
]
]
},
{
"id": "224853ed.7c89fc",
"type": "mqtt-broker",
"name": "HA MQTT",
"broker": "192.168.0.18",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]