Apollon77 / hap-controller-node

Node.js library to implement a HAP (HomeKit) controller
Mozilla Public License 2.0
54 stars 16 forks source link

subscribe-characteristics.js triggers no event #190

Closed absalom-muc closed 1 year ago

absalom-muc commented 1 year ago

When using your example subscribe-characteristics.js I see no error message but unfortunatelly also no event:

DEBUG=hap* node subscribe-characteristics.js 0 --debug --logs

Found device: Presence-Sensor-FP2-A7FF
  hap-controller:http-client 192.168.178.116:57520 Start Pair-Verify process ... +0ms
  hap-controller:tlv Add 1 bytes for tag 6: 01 +0ms
  hap-controller:tlv Add 32 bytes for tag 3: 243a48fb28424974a9e86625c3241bf8166712e2085de83cc4dcbbd3c0c2af0e +1ms
  hap-controller:http-connection 192.168.178.116:57520 POST /pair-verify 0601010320243a48fb28424974a9e86625c3241bf8166712e2085de83cc4dcbbd3c0c2af0e (application/pairing+tlv8) +0ms
  hap-controller:http-connection 192.168.178.116:57520 Response 200 with 140 byte data +2s
  hap-controller:tlv Read 1 bytes for tag 6: 02 +2s
  hap-controller:tlv Read 32 bytes for tag 3: 97f79bb3c31a995ce1991b9184dc3c20aa717f09dece2275ba9463b1358ad24d +0ms
  hap-controller:tlv Read 101 bytes for tag 5: 27aa984e5d38baf8c9a03aa0a47717b594347061affb94c8bbbfa6c6731e2cf23d2585b380037c819bf19224733d56b08593f422265a786a35d220fcedcc931c957c5d0065961912c8b6082cc1bc2d5c4c15b4bddc907f5421fc84ccfcc88d251b20de610a +1ms
  hap-controller:tlv Read 17 bytes for tag 1: 36413a38393a38353a37393a45453a4646 +36ms
  hap-controller:tlv Read 64 bytes for tag 10: a605949fb70d3e51b16611eb7be12256f96af306afb49f972688b54b4bac3806fd250c582a9db1c38d1084fe391ac0d6670b9a6d888b6dd0919769ffcec9d901 +1ms
  hap-controller:tlv Add 36 bytes for tag 1: 65316437616466302d393139342d343138382d393337392d633434653362333838386464 +22ms
  hap-controller:tlv Add 64 bytes for tag 10: d76fedc3ffe557c83ac05612fb826363a3b6c78079d44f2aeb20b0574627149929d87b626d5d2975273883beb102e58fd88ce4171f8283e4c5d987e10e4d9004 +1ms
  hap-controller:tlv Add 1 bytes for tag 6: 03 +3ms
  hap-controller:tlv Add 120 bytes for tag 5: 8779cead27deb08aa22eb15c3ba27d5784654072b1978e3c36478d6b1f33b2f48502abc23daa25c0bbafcca5db594a8301469d625799357d34b7d3cddb82725f7eeedfbe3cc51c7b81a34776fcd0c7f34781652fa6207564e2614ff3842f64db2b6b16f7dbf36810630f915b0f1b209880ee55c7b9f80fc4 +1ms
  hap-controller:http-connection 192.168.178.116:57520 POST /pair-verify 06010305788779cead27deb08aa22eb15c3ba27d5784654072b1978e3c36478d6b1f33b2f48502abc23daa25c0bbafcca5db594a8301469d625799357d34b7d3cddb82725f7eeedfbe3cc51c7b81a34776fcd0c7f34781652fa6207564e2614ff3842f64db2b6b16f7dbf36810630f915b0f1b209880ee55c7b9f80fc4 (application/pairing+tlv8) +72ms
  hap-controller:http-connection 192.168.178.116:57520 Response 200 with 3 byte data +69ms
  hap-controller:tlv Read 1 bytes for tag 6: 04 +71ms
  hap-controller:http-client 192.168.178.116:57520 Finished Pair-Verify process ... +2s
  hap-controller:http-connection 192.168.178.116:57520 PUT /characteristics 7b22636861726163746572697374696373223a5b7b22616964223a312c22696964223a323637342c226576223a747275657d5d7d +8ms
  hap-controller:http-connection 192.168.178.116:57520 Response 204 with 0 byte data +27ms
Presence-Sensor-FP2-A7FF: Subscribed!
Disconnected: [
  "1.2674"
]

The disconnect message occurs few minutes after the subscription message. Any idea what goes wrong? Thank you.

absalom-muc commented 1 year ago

I made another test: After setup of the subscription I read back the according characteristics with const resp = await connection.get('/characteristics?id=1.2674&ev=1'); response is "characteristics":[{"aid":1,"iid":2674,"value":1621},"ev":true] So it seems that enabling the event was successful, but I still can't see an event.

Apollon77 commented 1 year ago

Try to read all attribute infos and check if the attribute you plan to subscribe also is subscribable. (Ev feature). In general i know that it is working.

The log show that in fact the device do not send any data. You can try to log the response returned by the subscribe command and see if in that body there is anything interesting but 204 normally means no errors.

absalom-muc commented 1 year ago

Thanks for your feedback @Apollon77 According to the attribute it is subscribable.

            {
              "iid": 2674,
              "type": "0000006B-0000-1000-8000-0026BB765291",
              "format": "float",
              "value": 0,
              "perms": [
                "pr",
                "ev"
              ],
              "ev": false,
              "enc": false,
              "unit": "lux",
              "minValue": 0,
              "maxValue": 100000,
              "minStep": 1
            }

However, since I'm looking for a HAP-MQTT bridge I decided to continue with ioBroker instead of reinventing the wheel. With ioBroker it is no problem to see the subscription and to bridge it to MQTT. Thank you again for your support.