Closed flatsiedatsie closed 4 years ago
Yes, it's the exact same issue. The adapter needs to fully repopulate the thing description. Specifically, if the @type
array isn't the same, the preference will be wiped out. You can use the handle_device_saved
callback in your adapter to get the previous thing description before sending it back to the gateway via handle_device_added
.
I see. Is there any already made code that gets the data from the gateway and repopulates the dictionary?
No, but it's straightforward. Check out what you get in that callback.
Thanks.
So, now essentially add-ons are storing/managing the selected capability preference? And not the UI? I guess this is done to handle situations in which the capability changes during the lifetime of the device?
// if the @type array isn't the same
But I take it the order doesn't matter.
No, the gateway/UI is still managing the selected capability. The adapter is not allowed to specify that. This just gives adapters a way to rebuild their thing descriptions when it's not necessarily possible otherwise, e.g. for the MySensors devices or battery-powered Zigbee/Z-Wave devices, which don't report all their properties immediately.
The problem is not the order of the @type
array. The problem is when the capability that the user previously selected is no longer in the array.
Turns out there was a bug in my code, as per usual. It was causing recreation of the things dictionary from the persistence file to fail.
For now I will stick with using the persistence file as the point of truth instead of the handle_device_saved
method. Unless you think that's a bad idea.
A strange situation occured today. Both Zigbee and MySensors devices become unresponsive.
I rebooted the Gateway. Then, it seems that for the MySensors devices the selected 'centered' capabilities were not being remembered. It's as if the devices are completely new to the system, since some properties also don't show up until they their data is received or the first time. For example, a temperature property won't show until the first temperature reading is received.
After selecting the central capability, and waiting a little while, the devices seem ok again. But after a reset of the system, the situation re-occurs.
Could it be related to this issue? https://github.com/mozilla-iot/gateway/issues/2376
Are there changes to the gateway that require the MySensors add-on to be updated? Could it be that the Gateway is fetching the properties from the add-on after a reboot, but the add-on hasn't populated the thing dictionary yet?