Apollon77 / hap-controller-node

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

Pairing on shelly 1 with homekit firmware failed #54

Closed NebzHB closed 3 years ago

NebzHB commented 3 years ago

hi,

i have an error when i try to pair with the shelly 1 with the homekit firmware , here is my code :

        const client = new HttpClient(req.query.id, req.query.address, req.query.port);
        client.pairSetup(req.query.pin).then(() => {
            Logger.log('Appairage réussi de '+req.query.name+"("+req.query.id+")",LogType.INFO);
            //do something
        }).catch((e) => res.json({'result':'ko-pairSetup','msg':JSON.stringify(e)}));

the problem is i receive the ko-pairSetup message but the error is an empty object and i never receive the log in the Then

here is the mdns line : {"name":"shelly1-A4CF12F41DFD","address":"192.168.1.254","port":9000,"c#":1,"ff":0,"id":"40:73:BE:5D:8D:88","md":"Shelly1","pv":"1.1","s#":1,"sf":1,"ci":8}

and here is the homekit firmware : https://github.com/mongoose-os-apps/shelly-homekit

based on that homekit lib i guess : https://github.com/mongoose-os-libs/homekit-adk

Apollon77 commented 3 years ago

What is the error you got? Additionally ... please check out most recent examples because ideally you query the Setup method to use. For me the "default" one which is the secure one was never working with devices without a display ...

https://github.com/Apollon77/hap-controller-node/blob/main/examples/ip/pair-setup.js#L12

NebzHB commented 3 years ago

As said, there is no error ... the catch is entered but no error object in the parameter.

Ok i'll try with the new method and keep you in touch

Apollon77 commented 3 years ago

Sorry but "there needs to be" ... maybe better try to return "e.message" and ideally also "e.stack" ... and even better: try it with the example script directly on command line (to make sure that not your web framework around makes issues)!

NebzHB commented 3 years ago

ok that works with the last version and the pairMethod.

why don't you const client = new HttpClient(service); and manage the pairing method inside the logic ?

Apollon77 commented 3 years ago

because I wanted to have somethig which works thes ame in HTTP and BLE and thre are some differences ... And I also do not wanted to break the API which was used before ... So yes maybe a bit inconvenient and an option to adjust later, but service resulting from a Discovery clas instance and the Communication clients should be splitted

NebzHB commented 3 years ago

Nice thank you ! I had problem with Meross Plugs too, and thank to that modification, it works like a charm :)