Adapters and persistence

Hi all,

I’ve been trying to create my own adapter for http://shelly.cloud products. So far so good, I got bulbs and switches working however, when I restart my gateway instance the devices appear greyed out and I need to remove and add again the devices.

I believe this has something to do with the persistence layer of the adapters. Is there any documentation or examples I can look at of what should be the canonical approach for persistence?

Thanks

There’s more or less two ways to do persistence:

Run a discovery when the adapter is initialized or store paired devices in the “database”.

I think the hue adapter does the latter (for bridges, not the individual bulbs, due to how the API works) for example, but how exactly that’d work really depends on the language you’re writing the adapter in.

Thanks, that is to some extent what I understood while reading the hue and the homekit adapter. I’ll give it a try to the database approach.

You can also write out your own file to the filesystem. See this adapter for an example.