-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal to suggest file syntax for things and items to users #4509
Comments
This issue has been mentioned on openHAB Community. There might be relevant details there: |
But why? If you want to use discovery, why would you chose file based config? If the proposed syntax can't be autogenerated from the model I would vote against that feature - there is a high risk of forgetting the correct adjustments when the model is updated. |
Discovery is useful to get values of thing parameters you cannot guess (like for example the node id for a Matter node).
As you know this is very complex (to not say impossible) to implement, this "requirement" looks to me like an argument just to make no progress in this direction while at the same time the file syntax for things and items is very stable over the recent years and a specific generation would be relatively easy to implement. Rejecting the change just because it is not technically absolutely the perfect solution is a pity while at the same time it could be so helpful for a massive number of users. But Ok I will not insist more. |
That's being said, I will check if I can build the model to generate the test result. |
Personally, I'd rather see a convergence between the syntax shown in MainUI and the text configs. This feels like a work around for the fact that both have very different formatting and syntax. If what you saw in the code tab in MainUI was the same as what you would use in a .things file (or whatever that becomes) this wouldn't be needed. Moving between managed and file based configs would be very straight forward. |
@lolodomo great suggestion! I welcome this!
Another surprising case I've found is that some things use undocumented properties, even as the representation property! This leads to inboxes with things that aren't matched with the corresponding file based thing configuration. Making these properties visible to users of file based configuration is crucial, preferably through corrected documentation.
A similar feature (UI only) was PRed by me a week ago; openhab/openhab-webui#2920 |
This is a different story. You know how this story ended the last time so I doubt there will be someone else motivated to make a new try before 5.0 is released. |
This is similar to what I have in mind for inbox but we need an API that the UI will call to retrieve the generated code from the server. This is what I propose. |
I updated my initial proposal to simplify the UI part. The UI part is I assume trivial to implement by @openhab/webui-maintainers when you see what they are able to do. Probably just few minutes of work for them. Here is the update: New REST endpoints:
In Main UI, several options are possible but here is what I imagine as the easiest:
|
Funny thing is very early versions in the UI had a feature I tried to make where you could retrofit a managed Thing into a .things file entry: I abandoned the idea because it was buggy and unreliable, and couldn't work with client-side code only for inbox entries (you had to add it is a real Thing first) so wasn't worth the maintenance burden. Great place to again plug my pipe dream to have a YAML-based declarative object management system à la Kubernetes which would let you organize your configuration by functional domain (i.e. multi-object YAML files and/or folders) rather than by object types. I think it could be a perfect major feature to accompany a major release 🙂 (but again, probably a pipe dream) |
Please guys, you have #3666 to discuss YAML in case you want to reopen the discussion and find someone to implement it. We are not discussing here what should be the new file format but how we can help users by generating the file code and show it to them as suggestion. Of course, this would be the current file syntax but if one day the file syntax is changed to a new format this will become this new file format. |
Your proposal for the UI sounds good and should be straightforward to implement 👍 |
I can include a file format parameter in the API and implement the file generator in a service so that adding a new file format in the future (YAML for example) could simply consist in implementing a new class (service). |
I made very good progress and already made a POC with things and items. It is finally possible to build the DSL model from a Thing or Item object and then just request the saving of the built model to retrieve the original syntax we are looking for. I will create a WIP PR very soon after Christmas to show how it is simply done and also to show that any new format could be added later just by implementing an additional service. The API provides a "format" parameter to select the output format which is currently "DSL" by default. I find all this just so amazing that I regret not having done it earlier. This would be a great feature for OH5 in the sense that it would help so many users. |
This issue has been mentioned on openHAB Community. There might be relevant details there: |
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
@florian-h05 @jimtng : the core PR is almost finished, I am doing last improvements. For UI integration, I saw @jimtng proposal to copy the generated syntax into clipboard instead of displaying it in UI. Why not, that is not a bad idea. Is there a size limit for the clipboard? In addition to an entry for individual item, thing and inbox entry, I would like an input for exporting all items and an input for a exporting all things. It could be added at the same place where we can import items file. |
Closed by error. I also saw the idea to generate items for all channels of a thing. This is something that I can add, the biggest difficulty is to find a name for items and names that do not yet exist. I could use same pattern as Main UI. What is Main UI pattern for mew item to link to a channel? |
FWIW: You can count me as a big fan of this feature, @lolodomo! |
@kaikreuzer: fantastic news, I should have my core PR ready for review at the end of the coming weekend. |
One tiny detail: Would it be possible to align the response accordingly? The same for things where there is no space around the parameter equality sign in the docs |
All this is already done in the current PR except space kept inside [ ] at beginning and end. I could very easily do it but the easy way will also apply to config parameters lists and I have a preference with the space at beginning and end of the list in this case. I will show how it currently looks like |
But ok, I will remove first and last spaces in [ ... ] |
Related to openhab#4509 Signed-off-by: Laurent Garnier <[email protected]>
Related to openhab#4509 Added REST APIs: - GET /inbox/{thingUID}/filesyntax to generate file syntax for the thing associated to the discovery result - GET /items/filesyntax to generate file syntax for all items - GET /items/{itemname}/filesyntax to generate file syntax for an item - GET /things/filesyntax to generate file syntax for all things - GET /things/{thingUID}/filesyntax to generate file syntax for a thing All these APIs have a parameter named "format" to request a particular output format. Of course, a syntax generator should be available for this format. Only "DSL" format is provided by this PR as this is currently our unique supported format for items and things in config files. So this parameter is set to "DSL" by default. In the future, new formats could be added and they will be automatically supported by these APIs. The API GET /things/filesyntax has another parameter named "preferPresentationAsTree" allowing to choose between a flat display or a display as a tree. Its default value is true for a display of things as tree. Signed-off-by: Laurent Garnier <[email protected]>
Note that this enhancement could also become THE solution for users to migrate very easily, at least for items and things, from one config file format to another, the day we decide to introduce a new format. The new format should just provide a syntax generator, this is just a class of less than 175 specific lines of code for items (same for things) in the case of DSL format. Then from Main UI, users could simply request the generation of syntax in this new format for all their existing items/things. |
I would like to add a new feature that would be, I believe, very useful for users (at least those interested by having their things/items defined in config files. The idea is to have in Main UI showing the suggested config file syntax for any thing/item.
What I propose is to add in core framework the following REST endpoints:
I will also extend console commands to provide the same features.
In Main UI, several options are possible but here is what I imagine as the easiest:
WDYT ?
@florian-h05 in particular for the feedback regarding Main UI/
The text was updated successfully, but these errors were encountered: