You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it's really not possible to extend the encoder: you need to copy-paste the method body, and then add your extra stuff you want to store in the state before you dump it to json.
I think each operation should be split into two, so it's possible to add/change the data that will be persisted (and handle that extra data on the way in), but also more easily switch the encoding method (for instance, to be able to use a non-JSON encoder).
In my case, I wanted to store/restore the associated accessories that were added to a bridge dynamically, and needed to rewrite the entire class - there was not even a simple way to use the existing AccessoryEncoder class.
It would be nice to allow accessories to expose their state and provide notifications on when this state changes so it can be persisted. I see that Accessory class implements getstate method, but I do not see it being used anywhere (directly or indirectly - can find any pickling or similar).
My use case is TV accessory providing "ConfiguredName" characteristics which is a way to assign custom names to your TV and input sources, and they are supposed to be persisted across restarts.
Currently, it's really not possible to extend the encoder: you need to copy-paste the method body, and then add your extra stuff you want to store in the state before you dump it to json.
I think each operation should be split into two, so it's possible to add/change the data that will be persisted (and handle that extra data on the way in), but also more easily switch the encoding method (for instance, to be able to use a non-JSON encoder).
I'm not sure if those are the best names, but hopefully get the idea.
The text was updated successfully, but these errors were encountered: