Skip to content

Add DDF for Aqara P1 presence sensor RTCGQ14LM - #6069

Merged
manup merged 3 commits into
dresden-elektronik:masterfrom
SwoopX:p1
May 24, 2022
Merged

Add DDF for Aqara P1 presence sensor RTCGQ14LM#6069
manup merged 3 commits into
dresden-elektronik:masterfrom
SwoopX:p1

Conversation

@SwoopX

@SwoopX SwoopX commented May 22, 2022

Copy link
Copy Markdown
Collaborator

This PR adds DDF support for the P1 presence sensor, depends on #6070 and vice versa.

It is remarkable that presence detection is derived purely from the fact that an attribute report from attribute 0x0112 is received. The value of that attribute, however, contains illumination data, so that it is a combined report and does not come seperated from each other.

It supports indication of presence through its internal LED via config/ledindication. It also allows to set a period from 1 - 200 seconds (device internal) when a new presence event is detected, using config/duration. Lastly, it exposes config/sensitivity, which Xiaomi itself describes with the distance from which detection is triggered (values 1 - 3, where 1 is low).

Due to the above described device approach to send presence events, a workaround has been used to ensure presence is automatically set to false after the number of seconds set through config/duration. In future, this should be solved by availability of timers.

Apart from the device implementation, this PR also contains an important amendment when setting values on a device: the initial state of a state change is set from StateWaitSync to StateCallFunction to speed up setting the target value while omitting reading the current state at the negligible cost of an unnecessary write.

This PR also contains the resource item implementation for config/triggerdistance required by the FP1 presence sensor.

@SwoopX SwoopX added this to the v2.16.1 milestone May 22, 2022
@SwoopX SwoopX linked an issue May 22, 2022 that may be closed by this pull request
@manup

manup commented May 23, 2022

Copy link
Copy Markdown
Member

Do I understand this right, the sensor knows the distance to the triggering object?

@SwoopX

SwoopX commented May 23, 2022

Copy link
Copy Markdown
Collaborator Author

@manup You're a little ahead of the PR description, haven't had the time yet.

Opened Pandorra's Box 🙂 Well, I wouldn't call it knowing the distance, but it apparently can distinguish between different ranges. Not sure how this is technically done precisely, maybe by adjusting measurement angles... However, they also describe it on their website, so nothing in terms of slow or hectic movement/number of movements (that's what I would understand on sensitivity).

The FP1 presence sensor interestingly handles both, true sensitivity and distance. We probably want to expose it cooked? Here, I did it uncooked, but for the FP1, it is by setting near, medium and far.

@manup

manup commented May 23, 2022

Copy link
Copy Markdown
Member

Ah, since this is only a PIR I don't think it has anything to do with distance, at most sampling sensitivity (imho). I'd prefer to use config/sensitivity to be consistent.

We probably want to expose it cooked? Here, I did it uncooked, but for the FP1, it is by setting near, medium and far.

Yeah it's time we get this streamlined, normalized values here are much needed, the near, medium and far are nicer and clearer, but historically config/sensitivity is a number :) perhaps it's better to create a RFC issue to discuss with the other clients/devs for a proper approach how to streamline this without breaking anything?

For docs, nice comparison between the former version and this p1: https://www.aqara.com/en/product/motion-sensor-p1

The FP1 is super interesting with the radar, we haven't managed to get one yet :/

@manup
manup merged commit b310485 into dresden-elektronik:master May 24, 2022
@SwoopX
SwoopX deleted the p1 branch May 29, 2022 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aqara Motion Sensor P1

2 participants