Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage of ZCL attribute datatypes by the network data store #989

Closed
hsudbrock opened this issue Feb 21, 2020 · 3 comments · Fixed by #1001
Closed

Storage of ZCL attribute datatypes by the network data store #989

hsudbrock opened this issue Feb 21, 2020 · 3 comments · Fixed by #1001

Comments

@hsudbrock
Copy link
Contributor

Currently, implementors of ZigBeeNetworkDataStore need to store information about ZCL attributes like the datatype or whether the attribute is mandatory. When reading a node from the data store, new instances of ZclAttribute are populated with that data, and those new instances are then used instead of the attributes defined in ZclCluster.initialize{Server|Client}Attributes.

I wonder if this should really be done that way. The method ZclCluster.initialize{Server|Client}Attributes provides the values defined in the ZCL spec, and I do not see why it should be possible that implementors of ZigBeeNetworkDataStore should be able to provide different values for those attribute properties.

Why do I even care about this? If there is, at some point in time, wrong attribute information in the autocoder XML files, this wrong information will make it into the data written by a network data store. If the autocoder XML files are fixed, this fix will never make it into the ZclAttribute instances that are created from network data store information that was written before that fix.

One concrete example is #534, which fixed wrong datatypes in the thermostat cluster XML files. I have one system here which reads a thermostat node that was persisted before #534 was merged, and in consequence this node still contains wrong attribute datatypes.

Chris, do you think it is sensible to not create new instances of ZclAttribute from a ZclAttributeDao here in ZclCluster.setDao, but rather to update the attributes created by initialize{Server|Client}Attributes during object creation with the infos from the ZclAttributeDao (excluding information defined by the ZCL spec like datatype, mandatory, etc.)?

@hsudbrock hsudbrock added the bug label Feb 21, 2020
@cdjackson
Copy link
Member

In general, I don't mind this approach and can certainly see some benefit. However, there are a couple of things that we should keep in mind.

  1. Custom attributes. Unless we can be sure that any custom attributes are added to the cluster before the data store updates it, then you will loose them. Since the ZclCluster is instantiated as part of the deserialisation from the data store, I don't think we can account for an manufacturer specific attribute?
  2. Attribute "attributes" would be lost. By this I mean the time of last update, and the last value, or if it is even supported (see also If device reports UNSUPPORTED_ATTRIBUTE then mark it unsupported #931).

I'm not completely sure we can overcome these two issues (at least the first) if you are only updating existing attributes.

See also #236 which is I think directly linked to what you are reporting (ie changes to the XML definition do not flow through if the device was already persisted into the store) and probably should not have been closed (I will reopen it).

@hsudbrock
Copy link
Contributor Author

I agree, #236 is directly linked to this one.

I think that your second issue it not a problem: I think we can overcome it by still taking the attribute "attributes" from the ZclAttributeDao(like last update, last value) and only ignoring those attribute properties that come from the ZCL spec (like data type, mandatory).

I agree that we need to think about the first issue, the custom attributes. Couldn't we check via the ZclAttributeDao#manufacturerCode whether it is a custom attribute - and in this case use the info from the ZclAttributeDao instead of the info from the initialize{Server|Client}Attributes.

However, I just saw that this field (manufacturerCode) is currently only contained in ZclAttribute but not contained in the ZclAttributeDao, and I believe that this is another issue that needs to be fixed before we could tackle this issue here.

@cdjackson
Copy link
Member

cdjackson commented Feb 21, 2020 via email

@cdjackson cdjackson added enhancement and removed bug labels Mar 2, 2020
hsudbrock added a commit to hsudbrock/com.zsmartsystems.zigbee that referenced this issue Mar 13, 2020
hsudbrock added a commit to hsudbrock/com.zsmartsystems.zigbee that referenced this issue Mar 13, 2020
manufacturer-specific attributes

This resolves zsmartsystems#989 and zsmartsystems#236.

Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/com.zsmartsystems.zigbee that referenced this issue Mar 13, 2020
manufacturer-specific attributes

This resolves zsmartsystems#989 and zsmartsystems#236.

Signed-off-by: Henning Sudbrock <[email protected]>
cdjackson pushed a commit that referenced this issue Mar 14, 2020
…rer-specific attributes (#1001)

* Fix typo in JavaDoc

* Only restore dynamic attribute state from the node database, except for
manufacturer-specific attributes

This resolves #989 and #236.

Signed-off-by: Henning Sudbrock <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants