Aqara FP1 and P1 motion sensors

"Aqara P1 Motion Sensor" driver is now available for installation and update from Hubitat Package Manager – HubitatCommunity (HPM)

Currently, this driver supports the following Aqara sensors:

The latest development branch version can be downloaded and manually installed from :
https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Aqara%20P1%20Motion%20Sensor/Aqara_P1_Motion_Sensor.groovy

As most of Aqara devices, it is recommended to pair the sensor very close to HE hub.
After pairing, press shortly the button at the back of the sensor. The default values for Motion Retrigger Interval, Motion Sensitivity and LED enable/disable should be automatically picked up.

When changing the configuration parameters, press shortly agan the sensor button. If the parameters change is successful, you should see confirmation in the info logs :

Info logs

dev:26372022-06-24 21:20:34.366 infoAqara P1 Motion reset to inactive after 10 s.

dev:26372022-06-24 21:20:24.414 infoAqara P1 Detected motion

dev:26372022-06-24 21:20:24.351 infoAqara P1 illuminance is 22 Lux

dev:26372022-06-24 21:20:11.393 infoAqara P1 LED is Enabled (1)

dev:26372022-06-24 21:20:11.388 infoAqara P1 sensitivity is High (3)

dev:26372022-06-24 21:20:11.383 infoAqara P1 retrigger interval is 5 s.

dev:26372022-06-24 21:20:11.379 infoAqara P1 illuminance is 31 Lux

dev:26372022-06-24 21:20:11.369 infoAqara P1 temperature is 28 deg.C

dev:26372022-06-24 21:20:11.361 infoAqara P1 Battery level is 100% (3.079 Volts)

dev:26372022-06-24 21:20:07.343 infoAqara P1 Debug logging is false; Description text logging is true

dev:26372022-06-24 21:20:07.338 infoAqara P1 Updating Aqara P1 Motion Sensor model lumi.motion.ac02 manufacturer LUMI

dev:26372022-06-24 21:20:06.349 infoAqara P1 device lumi.motion.ac02 button was pressed

Check the device web page and verify that under the 'Current States' there are meaningful values populated for motion, battery, and illuminance. If nothing appears after pressing the button on the back of the device, you will need to try to pairing again the sensor to HE. In most cases, Aqara P1 and Aqara FP1 devices require pairing at least 2 times.

Summary

Revisions history

  • ver. 1.0.0 2022-06-24 - first test version
  • ver. 1.1.0 2022-06-30 - decodeAqaraStruct; added temperatureEvent; RTCGQ13LM; RTCZCGQ11LM (FP1) parsing
  • ver. 1.1.1 2022-07-01 - no any commands are sent immediately after pairing!
  • ver. 1.1.2 2022-07-04 - PowerSource presence polling; FP1 pars
  • ver. 1.1.3 2022-07-04 - FP1 approachDistance and monitoringMode parameters update
  • ver. 1.1.4 2022-07-08 - aqaraReadAttributes()
  • ver. 1.1.5 2022-07-09 - when going offline the battery level is set to 0 (zero); when back online, the last known battery level is restored; when switching offline, motion is reset to 'inactive'; added digital and physical events type
  • ver. 1.1.6 2022-07-12 - aqaraBlackMagic;
  • ver. 1.2.0 2022-07-29 - FP1 first successful initialization : attr. 0142 presence bug fix; debug logs improvements; monitoring_mode bug fix; LED is null bug fix ;motionRetriggerInterval bugfix for FP1; motion sensitivity bug fix for FP1; temperature exception bug; monitoring_mode bug fix; approachDistance bug fix; setMotion command for tests/tuning of automations; added motion active/inactive simulation for FP1
  • ver. 1.2.1 2022-08-10 - code / traces cleanup; change device name on initialize();
  • ver. 1.2.2 2022-08-21 - added motionRetriggerInterval for T1 model; filter illuminance parsing for RTCGQ13LM
  • ver. 1.2.3 2022-12-04 - (dev. branch ) added internalTemperature option (disabled by default); added homeKitCompatibility option to enable/disable battery 100% workaround for FP1 (HomeKit); battery 0% bug fix; pollPresence after hub reboot bug fix;
12 Likes

Great news, thanks Krassimir. Just installed it and will be testing my P1 sensors :+1:

1 Like

Looks good from here. Great Job @kkossev

2 Likes

Working as expected, was waiting eagerly for this. Thanks @kkossev

1 Like

I think that solved my overzealous motion detection, which might have had to do with events getting interpreted as motion

1 Like

Thank you all for the feedback.

"Aqara P1 Motion Sensor" ( model: lumi.motion.ac02 manufacturer: LUMI) driver is now available for installation and update from Hubitat Package Manager – HubitatCommunity (HPM)

5 Likes

That's very good news, thanks. One small issue I found: the led will not blink when motion is detected

Have you any plans to extend this driver for the Aqara high precision motion sensor (RTCGQ13LM) and the Aqara presence detector FP1 (RTCZCGQ11LM), both working but via z2m at present.

The led blinking functioned with new P1 which I bound to my Hubitat, but it seems to disable it by itself after some time. Besides that, I also noticed an temperature log when I was walking to my garage with the P1 in my hand and during that walk, the LED was disabled and sensitivity settings was also changed:
dev:6422022-06-25 14:23:20.999 infoSensor garage illuminance is 2226 Lux
dev:6422022-06-25 14:23:18.965 infoSensor garage LED is Disabled (0)
dev:6422022-06-25 14:23:18.961 infoSensor garage sensitivity is High (3)
dev:6422022-06-25 14:23:18.957 infoSensor garage retrigger interval is 30 s.
dev:6422022-06-25 14:23:18.949 infoSensor garage illuminance is 2276 Lux
dev:6422022-06-25 14:23:18.947 infoSensor garage temperature is 29 deg.C
dev:6422022-06-25 14:23:18.945 infoSensor garage Battery level is 100% (3.136 Volts)
dev:6422022-06-25 14:23:17.953 infoSensor garage Motion is active 83s

I don't know anymore which settings I activated before the walk (within minutes after Hubitat bounding), but the LED is enabled now and it will not blink.

Your settings seem to be reset to the default values... I will keep an eye if the same aver happens with my P1 sensor.
@SmartHomePrimer if I am not wrong, you mentioned somewhere a similar strange behavior (configuration lost) with Aqara P1 when paired to Aqara Home or to Zigbee2MQTT?

Currently, thise driver sends the configuration commands every time the Preferences 'Save' button is pressed. If the pair/reset button at the back of the sensor was not pressed at the same time, the commands are simply lost - neither confirmed nor rejected by the device, even if it was awake at this time. However, if the button was pressed at the same time the configuration is sent to the sensor, the device explicitly confirms the successful Write Attribute command.

When the device is first paired to HE, no configuration commands are sent to the sensor. However, if the sensitivity/retriggerTime/LEDstatus are once received from the device, or were manually configured in the Preference section - then these 3 parameters are also sent again to the sensor during the pairing process, if you pair it for second (or more) time. I have paired the sense many times, because I am switching between two HE hubs.

So I may expect a different behavior (temporary or permanently storing of the parameters) depending on whether the params are sent immediately after pairing to the Zigbee coordinator (HE hub) or at a later time.

I also noticed, that sending the configuration commands at the second (and all consequent) pairings to HE hub seems to decrease the chance of successful pairing. On my main hub where I have a lot of Zigbee devices and the channel is rather busy, I am unable to pair the Aqara P1 device if it is in another room. I need to keep it really close to the hub when pairing.

So I can suggest to pair one of your P1 sensor again to HE, and see if there is any difference in keeping the changed parameters when compared to other sensors that were paired only once?

The Info logs (the second line) show that the LED is actually disabled, so it should not blink. The question is if the previously enabled LED parameter was self-reset somehow and why.

The sensor reports also the chip internal temperature once every 54 minutes ... I am not very confident how accurate the temperature is.. The temperature resolution is 1 only deg.C. The first version of the HE driver doesn't expose this temperature reading, but I can add it in a future version, but we obligatory need an offset parameter here. My observation is that the reported temperature is 1-2 degrees higher than it should be.

I spent some time reading about RTCGQ13LM and I am a bit confused, seems like there are two operation modes in Zigbee2MQTT : one using the 'standard' Zigbee Coordinator firmware and an ''Aqara native mode which requires an update of the Zigbee stick firmware... Such an update is not possible with HE.

Can you try pairing RTCGQ13LM to HE, switch to this driver, make sure the Debug logs are turned on and send me in a PM the debug logs? I expect that this sensor will send a CheckIn / Heartbeat message approximately every 60 minutes (without being activated by any motion), please make sure such a debug log is included in the logs.

About FP1 (RTCZCGQ11LM) - it is a rather different type of sensor, with many and different configuration parameters, so for HE it will need a dedicated driver. I went this route with Tuya Human Presence sensors (mixing the complex devices with the 'ordinary' PIR sensors in one driver), but I plan to separate these devices in two different drivers... when the time permits in the future.

1 Like

I did have had an occurrence where I was certain I had configured High sensitivity, and later found it was on Medium. This was with z2m using a ConBee 2 (did not apply any firmware updates to the controller). Set it back and didn’t have a problem again.

I have had issues each time setting device specific options such as sensitivity after a certain period of time following the pairing. I would have to pair it again to change the settings. Not sure if this is resolved with the latest build of z2m, but it happens when I use an unsupported Aqara hub with it too. I’ve stopped using the sensor for the time being as it wasn’t working well for the location I chose. Nothing to do with the sensor itself.

Not certain which controller was mentioned would need the firmware update. There are several Zigbee controllers that can work with HA, including the Xiaomi Mijia and certain Aqara controllers. Maybe it’s an Aqara hub model they are talking about? :man_shrugging:t3: The sensor itself may also have some bugs in its firmware that have not been fully addressed.

Is there any change between the "older" driver code and this one on HPM? Should I delete it and use the one on HPM?

The code that is installed and updated from HPM is the stable ‘production’ version. A new update is pushed usually some days after the newer code available only from the development branch has been confirmed to be working OK,

Currently there is no difference in the code between the ‘main’ version (available from HPM) and the development branch version (available for manual update from the link I posted above), When I add any new functionality and in the future, it will be first added into the development branch, What’s in my TODO lists at the moment is to add temperature capability, signal strength (RSS and LQI), presence watchdog (fire a powerSource event ‘unknown’ if the device falls off the network no checkin packets are received for 3 hours) and also to add support for the ‘high precision motion sensor’ Aqara model RTCGQ13LM ,

2 Likes

So it's better to go with the HPM version so that any update will be shown automatically and I won't need to search manually for new updates

1 Like

To be clear - these are not the microwave "occupancy" sensors (FP1) which I am (desperately) hoping will come to the US..

No, I have a FP1 which still needs zigbee2mqtt to work with Hubitat but Krassimir has promised to look into a driver for it when he has time. As for waiting for it to arrive in the US, it is hard enough to get them from AliExpress at present, my first one arrived and the barcodes were removed from the device and box presumably so the seller could not be traced back to him by Aqara. Docs were Chinese only. I have a second one on order so will see if that has the same missing barcodes.

1 Like

It's the Zigbee coordinator USB stick firmware :

which I find strange as a requirement "....In order for this device to work" And these updates are dated November 2021, which is relatively soon.. My CC2531 stick was purchased before this date and I have not updated the firmware, but I just realize I have used Z2M and ZHA only with the older models Xiaomi RTCGQ11LM, not the newer T1 series.

There is something very interesting that I found while searching for info for the new Aqara motion sensors. The original documents are here and here, Although these notes mention Xiaomi, it may be true also for Aqara branded sensors... I have copied the text below:


Difficult pairing

To pair the sensor it needs to be reset first, by pressing the pin-hole button for 10 seconds.

Then after starting sensor search, press the button again until the LED blinks. Finally continuously press the button every 2 seconds until joining is confirmed.


Sticky Parents

Almost all Xiaomi end-devices stick to their parent after pairing. The parent is the device which repeats the signal, it can be a router or the coordinator.

Once a parent is cut from power or otherwise lost, the end-device won't automatically search for a new parent and appears to be offline.

→ Best practice for pairing is therefore to pair the device at the place where it's gonna be installed to force it to select a good parent. It's also advisable to power off all routers which aren't powered all the time, so that they aren't considered as parent when pairing.


1 Like

Those recommendations you found are common for all Xiaomi devices across the board, be they Aqara or Mijia branded. The only ones that act differently are the Aqara Opple devices. They are not developed by Shenzhen Green Rice Lianchuang Technology Co., Ltd, as most of the other devices are.

1 Like

I have updated the development branch version to 1.1.1 timestamp "2022/07/01 8:29 PM".
There are a lot of internal code changes, but the main visible addition to the Aqara P1 motion sensor functionalities is the temperature attribute. There is also an offset parameter for the temperature reading (my sensor shows 1-2 more degrees higher temperature if compared to other temp sensors in the same room). The temperature values are integer numbers (internal temperature sensor resolution is 1 degree) and the scale (C/F) is set automatically depending on the HE setting.

I don't know why (yet), but my Aqara P1 sensor requires to be paired two times. The first pairing process creates the device and assigns this driver, but nothing is received from the sensor. Pairing it for a second time (without deleting the device from HE) makes it work OK.

3 Likes