Apollon77 / hap-controller-node

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

SyntaxError for get-characteristics.js example #188

Closed absalom-muc closed 1 year ago

absalom-muc commented 1 year ago

Thanks a lot for your great work. I'm a beginner in the area of HAP and NodeJS, nevertheless I was able with your examples to pair my Aqara FP2 and to run get-accessories.js in a short time.

But with your example get-characteristics (added only the pairingData and aid.iid) I see an error message:

DEBUG=hap-controller node get-characteristics.js
Found device: Presence-Sensor-FP2-A7FF
Presence-Sensor-FP2-A7FF: {
  name: 'SyntaxError',
  message: "Expected ',' instead of ':'",
  at: 89,
  text: '{"characteristics":[{"aid":1,"iid":2674,"type":"6B","format":"float","value":25},"perms":["pr","ev"],"ev":false,"unit":"lux","minValue":0,"maxValue":100000,"minStep":1]}'
}

I assume the 'SyntaxError' is created by my device, do you know what went wrong? I would expect some more debug output, not sure if I need something else than 'DEBUG=hap-controller'? (sorry, NodeJs starter) Also with subscribe-characteristics I have some trouble (subscription is successful, but no values visible), but this might be a differernt working zone.

Thank you.

edit: With DEBUG=hap* node get-characteristics.js 0 --debug --logs I see the detailed output:

Found device: Presence-Sensor-FP2-A7FF
  hap-controller:http-client 192.168.178.116:55418 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: 2a43a7d6946db9851e7c67065a631fb9c4ec0dad5a017c75ad7f8529bfb63220 +1ms
  hap-controller:http-connection 192.168.178.116:55418 POST /pair-verify 06010103202a43a7d6946db9851e7c67065a631fb9c4ec0dad5a017c75ad7f8529bfb63220 (application/pairing+tlv8) +0ms
  hap-controller:http-connection 192.168.178.116:55418 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: ba054cf0df4873b195b38f77d87a75a7855e30751c0013444dc7ec5952071043 +1ms
  hap-controller:tlv Read 101 bytes for tag 5: ade361d756d74366e267f92d725db0dcde3346bf53d2fa6db0e6bcf3c56504078fc8a33e9a3f8d4717078a6799c23d892c7570a6cc67acdaecbd96c76aa34b9658485b07b591ee79f3e9c6e9d556c54a34411af584f8cd1431a10bf100dbe8fe5b4a401a4b +1ms
  hap-controller:tlv Read 17 bytes for tag 1: 36413a38393a38353a37393a45453a4646 +31ms
  hap-controller:tlv Read 64 bytes for tag 10: e0df5f162e5af9cd7ada36111d28fcf8311d9a981011ce08f9a466883dcbe57efe0e10cb75fb04ee345a9190038b0f9dba5af66fd2b69c5ec883c791e6d6aa04 +1ms
  hap-controller:tlv Add 36 bytes for tag 1: 65316437616466302d393139342d343138382d393337392d633434653362333838386464 +19ms
  hap-controller:tlv Add 64 bytes for tag 10: fbd18a4bd3ac56d0040a8b1b87b6838f9a78642c03340f8752221ee464f0890f239f1f429ef13d7ab34e854427feadb2cefd5e0657dde0fff3b88283a30b790e +1ms
  hap-controller:tlv Add 1 bytes for tag 6: 03 +3ms
  hap-controller:tlv Add 120 bytes for tag 5: 969a3f6a6878043f62470f2bc0ef88dcc08c65fadbc362af3c047146fb316ea2650125fbc9a990f7ad58f3e1094bb2b492c8d4baaf2dcf21defd3b75a2fced2c984b0b8a9c3c2e5064fd47447953209b897562f863738808f4aa4f373392b63ce63ee770254b018e5150afa152b51a3b41c5a628f1992d4b +1ms
  hap-controller:http-connection 192.168.178.116:55418 POST /pair-verify 0601030578969a3f6a6878043f62470f2bc0ef88dcc08c65fadbc362af3c047146fb316ea2650125fbc9a990f7ad58f3e1094bb2b492c8d4baaf2dcf21defd3b75a2fced2c984b0b8a9c3c2e5064fd47447953209b897562f863738808f4aa4f373392b63ce63ee770254b018e5150afa152b51a3b41c5a628f1992d4b (application/pairing+tlv8) +64ms
  hap-controller:http-connection 192.168.178.116:55418 Response 200 with 3 byte data +166ms
  hap-controller:tlv Read 1 bytes for tag 6: 04 +168ms
  hap-controller:http-client 192.168.178.116:55418 Finished Pair-Verify process ... +2s
  hap-controller:http-client 192.168.178.116:55418 New persistent connection client initialized +3ms
  hap-controller:http-connection 192.168.178.116:55418 GET /characteristics?id=1.2674&meta=1&perms=1&type=1&ev=1 +6ms
  hap-controller:http-connection 192.168.178.116:55418 Response 200 with 169 byte data +27ms
Presence-Sensor-FP2-A7FF: {
  name: 'SyntaxError',
  message: "Expected ',' instead of ':'",
  at: 89,
  text: '{"characteristics":[{"aid":1,"iid":2674,"type":"6B","format":"float","value":57},"perms":["pr","ev"],"ev":false,"unit":"lux","minValue":0,"maxValue":100000,"minStep":1]}'
}
absalom-muc commented 1 year ago

Closed, since I'm looking for a HAP-MQTT bridge and 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.

Apollon77 commented 1 year ago

In fact the reson is that the JSON is simply wrong as seen in your post ...