itavero / homebridge-z2m

Expose your Zigbee devices to HomeKit with ease, by integrating 🐝 Zigbee2MQTT with 🏠 Homebridge.
https://z2m.dev
Apache License 2.0
310 stars 49 forks source link

Support for Homebridge 2.0 #904

Open rionshin opened 1 month ago

rionshin commented 1 month ago

Problem description

homebridge will be releasing version 2.0 which will have breaking changes to existing plugins

Suggested solution

Make it HB 2.0 compatible . @itavero What is the plan for supporting Homebridge 2.0 - will the plugin be impacted and will it be easy to make it compatible with 2.0.

Alternative solutions

No response

Additional context / information

https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2

itavero commented 1 month ago

Did you already check if there are incompatibilities? Looking at the deprecated APIs, there may be a few (but to be honest, I haven't actively developed on the plugin recently, so I'm not sure).

Overall, I think the needed changes seem limited.. The only thing is that I do not yet know when I'll have time to go over them and test it.

rionshin commented 1 month ago

Did you already check if there are incompatibilities? Looking at the deprecated APIs, there may be a few (but to be honest, I haven't actively developed on the plugin recently, so I'm not sure).

Overall, I think the needed changes seem limited.. The only thing is that I do not yet know when I'll have time to go over them and test it.

@itavero i can fork it and check and let you know my findings.

rionshin commented 1 month ago

@itavero - I review the code , you already using the correct classes and no where in the code i can find the old syntax that is obsoleted. So in some moment you can update package.json that "engines" is 2.0 ready.

Instead of const Units = Characteristic.Units; you will need to use const Units = api.hap.Units; (z2m is using api.hap.Units ) Instead of const Formats = Characteristic.Formats; you will need to use const Formats = api.hap.Formats; (z2m is using api.hap.Format) Instead of const Perms = Characteristic.Perms; you will need to use const Perms = api.hap.Perms; (z2m is using api.hap.Perms ) Characteristic.getValue() has been removed in favour of Characteristic.value (Characteristic.value is used) Accessory.getServiceByUUIDAndSubType() has been removed: Instead of accessory.getServiceByUUIDAndSubType(Service, 'some-name'); you can simply use accessory.getService('some-name'); - (can't find it in code) accessory.updateReachability() has been removed - reachability in general is no longer supported - can't be found in code

itavero commented 1 month ago

@rionshin Thanks for checking. I also just did a check and tried to actually run the plugin.. Did find some things already that need fixing, which I'm working on in #920