I’m working on a new addon and as a result am adding channels progressively so that I don’t have too much to handle at once.
The channels being always present, I’m adding them in the thing:thing-descriptions declaration for the thing.
However, any time I add a new channel, it does not show up in the UI until I delete and recreate the thing that I’m using to test.
After some memory refresh, I remembered about the update folder inside the OH-INF addon folder as described here: Thing Descriptions | openHAB
Sure enough, if I add update instructions, the new channel shows up.
But this is quite cumbersome, and most of all, unnecessary because my binding is still in its infancy, not yet released in the wild.
Would there be some sort of “secret command” to force OH to reread the XML thing definition and overwrite whatever definition it has internally? I don’t care about thing/item history at this point, I’m in the developing phase.
For the OpenMeteo binging, I did not use XML definitions but rather added channels via code and this worked immediately. I could do the same here, but for this much simpler addon, it did not feel right to have that more complex behavior.
The XML files are only used to create a thing-type, when a Thing is created all the channel information is saved as part of that Thing in the jsondb, which is why you need to recreate it. Not sure how textual Thing-definitions work, if you need to declare all channels in the .things-file or if they are auto-created based on thing-type. If so, you would only need to reload that file. Otherwise it would probably still be easier to add the new channels there instead of changing the update xml.
Thanks, but I’m not using textual definitions for things, I’m creating the thing and items via MainUI exclusively.
I would thus need to be able to force refresh the jsondb but how to do that is a mystery to me.
I don’t really understand why we need this update.xml and why can’t we just automatically update the thing. Is it some sort of performance optimization to speed up openhab’s load time?
I have been working on a binding, and found during the prototyping phase, it was easiest to have a script which would remove any existing things etc, and completely recreate/link them, via API. It also creates a MainUI page I use for testing alongside a emulator harness.
Here’s the script I used for my binding:
I found this the cleanest approach, to avoid confounding issues from legacy things in earlier development iterations.
Whilst it cleans out existing instances, tt also is handy for setting up a completely new OpenHAB ‘test’ environment, within seconds. The only manual step, is to create a API token after your openhab rebuild, and add it to the config file.