com.zsmartsystems.zigbee: NetworkManager updateNode notifies listeners in a wrong way

I am currently debugging why openHAB as a client of this library starts a discovery for a node twice.

I dug down the code and stumbled across the updateNode() method of the ZigbeeNetworkManager:

https://github.com/zsmartsystems/com.zsmartsystems.zigbee/blob/36f8412da5f6e2f812cd42a7f0b02768772de427/com.zsmartsystems.zigbee/src/main/java/com/zsmartsystems/zigbee/ZigBeeNetworkManager.java#L1369-L1421

The decision of whether to inform the listeners about an added or updated node is taken in line 1398. However this decision is based on the fact that the discovery for that particular node has been finished or not.

So whenever a node gets changed and its discovery has not been completed yet (this is a potentially long running thread in the background), this will result in a call to listener.nodeAdded() instead of listener.nodeUpdated().

IMHO the decision about updated vs added should only be because of changed properties in the node itself.

In the case of openHAB, there a multiple discoveries started because it acts as a nodeAdded() listener and whenever a new node occurs, it starts to read out its zigbee features. if the above decision would be corrected and nodeUpdated() would be called instead of nodeAdded(), this issue would be resolved.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

Ok, but this sort of issue in OH could easily be resolved in OH with a simple flag.

In any case, as I said above I’m looking at adding the nodeDiscovered callback so that should resolve this.