WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Migrate `@context` of existing Thing Descriptions on first boot #3052

Open benfrancis opened 1 year ago

benfrancis commented 1 year ago

https://github.com/WebThingsIO/gateway/pull/3034 added logic to standardise the @context member used in Thing Descriptions.

We should also migrate existing Thing Descriptions in the database to the new default context so that they don't have to be modified at runtime every time they are read.

I had written some code to do this, but it turned out to be redundant. Those Thing Descriptions already get updated on startup as a side effect of the updateFromDescription() method being called for every existing device when handling deviceAdded messages from adapters. I don't think this is necessarily desirable, so I plan to revisit this in a follow-up and figure out what's going on there.

See https://github.com/WebThingsIO/virtual-things-adapter/issues/66 for an example of an add-on which calls handleDeviceAdded() on startup.