WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Zigbee & Z-Wave Things missing properties #3126

Closed benfrancis closed 7 months ago

benfrancis commented 8 months ago

Testing with WebThings Gateway 1.2.0-alpha.1, I can confirm that Zigbee and Z-Wave smart plugs of models that are previously known to work with 1.1 are missing properties in their Thing Descriptions.

STR:

Expected:

Actual:

benfrancis commented 7 months ago

Trying to debug this, I cloned and built the master branch of the zigbee-adapter repo into the add-ons folder and managed to pair and use a Zigbee smart plug without any issues. When I swap the add-on out for the 0.21.1 packaged and released version it stops working.

If I manually build the released 0.21.1 tag it keeps working.

I've not figured out what's going on yet. I have noticed the version of the gateway-addon package listed as a devDependency in the Zigbee add-on is older (1.0.0) than the one shipped with the gateway (1.2.0-alpha.1), but it should ideally be backwards compatible.

benfrancis commented 7 months ago

Notably, if I npm prune --production on the 0.21.1 checkout after building (one of the steps carried out by the packaging script) to remove the devDependencies, it seems to stop working.

This suggests to me that during development the adapter is using its own gateway-addon 1.0.0 module, but once packaged it's traversing up the tree and using the gateway's central gateway-addon 1.2.0-alpha.1 module, and not working properly with that version.

This is further supported by the fact that the Z-wave add-on also lists gateway-addon 1.0.0 as a devDependency (and is broken), but the virtual-things-adapter doesn't (and is working fine). I guess that's why we tell people never to add it as a dependency for an add-on!

Next steps:

benfrancis commented 7 months ago

Update: I've tried upgrading the gateway-addon dependency of the zigbee-adapter to the same version used in gateway 1.2.0-alpha.1, but so far that alone doesn't seem to fix the problem https://github.com/WebThingsIO/zigbee-adapter/pull/333

More debugging required.

benfrancis commented 7 months ago

I think I've figured out what's going on, at least for the Zigbee add-on, and I should have realised earlier.

The Zigbee adapter is deleting all properties from Thing Descriptions that don't have a truthy visible member.

I forgot we removed support for the visible member on master but re-introduced it on the 1.1 branch (for this reason). See https://github.com/WebThingsIO/gateway/issues/3038 for a full explanation.

Ideally we should fix this in individual add-ons rather than keeping this deprecated feature around for another release, but unfortunately it doesn't like the deprecation warning we added actually gets printed to the console so add-on developers may not have noticed it.

This may require some research to find out how many add-ons use the visible feature.