ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
135 stars 7 forks source link

Aqara Motion Sensor P1 "Duration" #93

Closed andyblac closed 1 year ago

andyblac commented 1 year ago

In the advance settings page for the sensor in EVE, when you change the "Duration" it seems to be sending Phoscon-GW: request 102148: PUT /sensors/6/config {"delay":10}, when it fact it should be sending Phoscon-GW: request 102148: PUT /sensors/6/config {"duration":10}.

here is the API output for the sensor

    "6": {
        "config": {
            "battery": 100,
            "duration": 5,
            "ledindication": false,
            "on": true,
            "reachable": true,
            "sensitivity": 2
        },
        "ep": 1,
        "etag": "86398046b996663d551437bb06029f7e",
        "lastannounced": null,
        "lastseen": "2023-01-21T12:38Z",
        "manufacturername": "LUMI",
        "modelid": "lumi.motion.ac02",
        "name": "Office Motion Sensor",
        "state": {
            "lastupdated": "2023-01-21T12:38:48.413",
            "presence": false
        },
        "swversion": "0.0.0_0006",
        "type": "ZHAPresence",
        "uniqueid": "54:ef:44:10:00:50:b5:14-01-0406"
    }

if i send the command via cur curl -X PUT 127.0.0.1:4530/api/54E7A86369/sensors/6/config -d '{"duration": 5}'

pi@homebridge:~ $ curl -X PUT 127.0.0.1:4530/api/54E7A86369/sensors/6/config -d '{"duration": 5}'
[{"success":{"/sensors/6/config/duration":5}}]
ebaauw commented 1 year ago

That's a bug alright, thanks for reporting.

andyblac commented 1 year ago

thanks for that fix, but there still seems to be an issue.

[21/01/2023, 14:53:08] [deCONZ] Kitchen Motion Sensor: Duration changed from 20s to 5s
[21/01/2023, 14:53:12] [deCONZ] Kitchen Motion Sensor: set Duration from 5s to 20s
andyblac commented 1 year ago

just so you know, i am doing the following

1: open the setting to be ready to change 2: press the button on sensor 3: change the duration slider from 20 to 5 4: close the setting screen

ebaauw commented 1 year ago

Hm, it seems that deCONZ reports config/duration as 20. I need to see the debug messages to be sure. Please run Homebridge in DEBUG mode and set the Log Level for the motion sensor to 2.

I don’t know this sensor, but if it indeed uses an Occupancy Sensing cluster, I would expect config/delay linked to PIR Occupied to Unoccupied Delay instead of config/duration managed by deCONZ.

andyblac commented 1 year ago

is this what you need, tried to change fro 20s to 5s

[21/01/2023, 18:05:30] [deCONZ] Office Motion Sensor: Duration: changed to 5s (from 20s)
[21/01/2023, 18:05:30] [deCONZ] Phoscon-GW: request 34: PUT /sensors/6/config {"duration":0}
[21/01/2023, 18:05:30] [deCONZ] Phoscon-GW: request 34: 200 OK
[21/01/2023, 18:05:30] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":0,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[21/01/2023, 18:05:32] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":20,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[21/01/2023, 18:05:32] [deCONZ] Office Motion Sensor: Duration: set to 20s (from 5s)

from 20s to 10s

[21/01/2023, 18:08:55] [deCONZ] Office Motion Sensor: Duration: changed to 10s (from 20s)
[21/01/2023, 18:08:55] [deCONZ] Phoscon-GW: request 73: PUT /sensors/6/config {"duration":10}
[21/01/2023, 18:08:55] [deCONZ] Phoscon-GW: request 73: 200 OK
[21/01/2023, 18:08:55] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":10,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[21/01/2023, 18:08:57] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":20,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[21/01/2023, 18:08:57] [deCONZ] Office Motion Sensor: Duration: set to 20s (from 10s)
ebaauw commented 1 year ago

Looks like deCONZ accepts the update of config/duration, but changes it back to the old value two seconds later. Does the duration stick when you change it through curl?

andyblac commented 1 year ago

yes works via curl, it strange sometimes it works using EVE UI, but only for 10, 20 etc, never for 5, is that because it tries to send '0' and not '5' ?

[22/01/2023, 10:07:28] [deCONZ] Office Motion Sensor: Duration: changed to 30s (from 20s)
[22/01/2023, 10:07:28] [deCONZ] Phoscon-GW: request 9677: PUT /sensors/6/config {"duration":30}
[22/01/2023, 10:07:28] [deCONZ] Phoscon-GW: request 9677: 200 OK
[22/01/2023, 10:07:28] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":30,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[22/01/2023, 10:07:29] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":30,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[22/01/2023, 10:11:20] [deCONZ] Office Motion Sensor: Duration: changed to 5s (from 30s)
[22/01/2023, 10:11:20] [deCONZ] Phoscon-GW: request 9720: PUT /sensors/6/config {"duration":0}
[22/01/2023, 10:11:20] [deCONZ] Phoscon-GW: request 9720: 200 OK
[22/01/2023, 10:11:20] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":0,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[22/01/2023, 10:11:22] [deCONZ] Office Motion Sensor: /sensors/6: changed: {"config":{"battery":100,"duration":30,"ledindication":false,"on":true,"reachable":true,"sensitivity":2}}
[22/01/2023, 10:11:22] [deCONZ] Office Motion Sensor: Duration: set to 30s (from 5s)
ebaauw commented 1 year ago

The list of possible duration values is hard-coded by Eve. As it doesn’t include 0, I map 5 to 0.

Did you try and set 0 using curl?

andyblac commented 1 year ago

gets success response, but seems to do nothing.

pi@homebridge:~ $ curl -X PUT 127.0.0.1:4530/api/54E7A86369/sensors/6/config -d '{"duration": 0}'
[{"success":{"/sensors/6/config/duration":0}}]
pi@homebridge:~ $ curl 127.0.0.1:4530/api/54E7A86369/sensors/6 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   448  100   448    0     0  49777      0 --:--:-- --:--:-- --:--:-- 56000
{
  "config": {
    "battery": 100,
    "duration": 30,
    "ledindication": false,
    "on": true,
    "reachable": true,
    "sensitivity": 2
  },
  "ep": 1,
  "etag": "b69f28539514f0e1659c5f5faa019a2e",
  "lastannounced": null,
  "lastseen": "2023-01-22T18:07Z",
  "manufacturername": "LUMI",
  "modelid": "lumi.motion.ac02",
  "name": "Office Motion Sensor",
  "state": {
    "lastupdated": "2023-01-22T18:07:00.345",
    "presence": true
  },
  "swversion": "0.0.0_0006",
  "type": "ZHAPresence",
  "uniqueid": "54:ef:44:10:00:50:b5:14-01-0406"
}
ebaauw commented 1 year ago

Look like a deCONZ issue.