-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Add a transformations menu and editor #1448
Conversation
Job #892: Bundle Size — 15.69MiB (+0.18%).Metrics (2 changes)
Total size by type (3 changes)
|
I wonder, if we need to get the vocabulary straight: Are those now "Transformations" or "Transformation Configurations"? I'd actually say the header is correct - these are instances of "Transformations" that are created, managed and configured, wdyt? Is the "editor mode", what you call "context" in openhab/openhab-core#3036 or what is that about? |
Exactly, the "editor mode" and in the case of blockly the "non-scripted block information" is what the context is. Maybe the wording "context" is not good, but we need additional information. What is not shown in the pictures: for MAP the editor shows a hint that you have to enter a value behind the "=". Yes, in fact they are configurations for transformations (file-based are shown, but not editable, and managed can be created/edited/deleted, similar to things or items). "Transformation configuration" very long term which does not properly fit in the UI. I'm very happy if you have a good proposal what we should name it. |
Well, as stated above, I think what we deal with here are "Transformations". To be honest, I still haven't understood what A Transformation itself is defined by a type, and a filename or function (depending on the type) - let's call it parameter. Its String representation is so far simply If certain Transformation types now require specific information, this should imho simply be part of the The Parameter can imho be seen as the configuration of the Transformation. In order to make Transformations nicely manageable through the UI, I could imagine that we can add a unique id and a label to it and make the Parameter a map, so that it can be treated as the configuration and we could provide according ConfigDescriptions through the Transformation services. "Classic" transformation types that rely on files could e.g. always use "file" as a key and the filename as a value for the configuration. Script transformations could have a "script language" key, and refer either to a "file" or have an in-line script parameter. As a result, we should have a |
Sounds reasonable. I'll prepare that. |
I suppose the header "Transformations" is fine even if it's a transformation parameter/configuration that's actually being edited, as it still has to look good, so a short one-word header is better. Regarding its position in the menu, I'm wondering if those "deserve" that top-level spot along with the "big four" (things/inbox, items/model, pages, rules/scripts), to me they're far less important and merely a helper, like Profiles, or Rule Templates, or UI widgets: they have no purpose of their own but are meant to be used by top-level objects. I could imagine them in Developer Tools under "Advanced Object Management" instead, along with those future managed "secondary" objects - templates, managed profile configurations, managed metadata namespace descriptions, etc. I know they are actually configuration so it also makes sense to put them under Configuration in the main Settings, but just wanted to throw out the idea. Regarding Blockly in transformations, how would that work exactly? Does the script engine have the same scope as the script rule modules? Because then a lot of blocks in the Blockly toolbox would make no sense and more so, critical blocks to build a transformation script like |
From an end user perspective I don't like the idea of hiding them under Developer Tools. I wouldn't intuitively think to look for them there. While they may only be a helper, in the docs they are treated as their own thing on the same level as persistence, rules, items, etc. The other secondary objects you mention don't have their own top level page in the docs (or any page in the docs in some cases) so those make more sense to put into Developer Tools but I'm not so sure about transformations. Of course, its prominence in the docs is also an accident of the history of OH itself. But given that transformations can be used in a lot of places (Things/Channels, Profiles, Items, Rules) I'm not sure it makes sense to bury that page in one of the others either. Anyway, what's not clear is if one would be able to somehow launch the creation of a new transformation from, for example, the MQTT Channel configuration page. It would be pretty cool if I could launch the creation of it from there (and from other bindings that use transformations, the State Description metadata config form, and the transform Profile config form). Then it may not matter as much where they are placed. If not, the user would have to
|
Fair enough, as I've said it just me throwing out an idea to better surface essential concepts and distinguish them from others that are more technical. Maybe some reorganizing at some point would be in order.
Agreed that could also make sense. But if we're giving transformations the top-level treatment like Things or Items, then they would also have to appear on the left sidebar under Settings and have support in the developer toolbar (so you can 1. search for them with the omni searchbar there, 2. pin them while you're working on them and 3. have a create shortcut in the 4th tab). |
I'm already working, slowly, on a complete reorganization of the rules docs. They are in the worst shape of all the sections right now. But I agree. Ultimately I think a complete rethink of the docs structure needs to occur. We've been mostly coasting almost since OH 2.0 and I'm not sure the current structure works the best in a 3.x world.
Could they be on the right hand column under System Services or Other Services? Note we'll have a similar problem when Persistence configs come to the UI so we should keep that in mind. What ever is decided here will probably apply to Persistence so we are talking about adding two new entries in the end, not just this one. Just because it's in the "Configuration" section does it have to be in the sidebar? I too am just throwing out ideas. I do agree they transformations are not as "big" as rules, items and things. But they are also more than item metadata and templates and such for the average user. |
@rkoshak: IMO MQTT and HTTP state/commandTransformation parameters should be removed and replaced by a chaining transformation which can be applied as a profile. Another question is if chaining multiple transformations is really needed when we can use all scripting languages for transformations (in fact, this is already possible, the profile for applying the transformation on a channel/item link is missing). I have no preference where on the settings page it is placed, but to me the transformations are too important to be hidden in the developer section. |
Just so we're clear, my remark was about the settings menu, not the docs (though we could agree it could apply to both).
Depends, these sections are automatically generated (System Services are the configuration services whose id begins with
Right with you, that's why I'm conflicted.
It's kind of funny because I asked myself this very question along with a lot of others some time ago when building the UI and I finally decided that it does, as a principle. So either we break from that principle or we stick to it, up for debate - and it influenced my assessment on whether to feature it in those sections, and whether it could be under Developer Tools, where it would have its sidebar entry there for sure. It's easier to debate with yourself ;) but now that the question is asked we can have a discussion. |
I personally never draw any association between the sidebar elements and the configuration (+automation!) section of the settings page - i.e. I never noticed and as such I'd say that there is absolutely no need to have exactly the same entries. So having transformations only in the section, but not in the sidebar would imho be just fine. |
Another thing I've considered, for the record, is that the menu acts as a "wizard" of sorts. As in you can follow the menu entries, have your Things, then define the Model, act on Items if needed and then design some Pages. Then you can go on to automation. Somehow the transformations don't fit in that story. But whatever, let's keep the transformations there for lack of a better place! |
I could not agree more. I've said for years that binding authors shouldn't be responsible for implementing transformations. It's less work for the developers and easier for the end users to have just one way to apply them instead of needing to learn the various minor differences between add-ons.
I haven't thought about that too much, but I can see a number of cases where it feels more straight forward to chain them than to force users into a manually written script. For example extracting a value using JSONPATH or XPATH and using a MAP to convert that to ON/OFF is a pretty straight forward transformation config but less so as a script I think. There is also the REGEX filter on the MQTT binding which, while I'm really glad it's implemented I've always been a little uncomfortable with how it's implemented. It feels a little like a misuse of transformations. But the need is still there because sometimes you have multiple devices publishing to the same topic (looking at you Shelly 😠 ). And to make this work my understanding is that REGEX was modified to behave differently from all the rest. If there's no match to a JSONPATH, you get the whole JSON but if there's no match on the REGEX you get nothing back. I wonder if chaining profiles makes sense. Consider the case where an MQTT channel receives a JSON that we need to extract a value from but then want to apply the hysteresis profile or scale profile or the like. With transformations removed from the binding and without the ability to chain profiles that'd have to be implemented by hand which some users would consider a step backwards in usability, even if it's a step forward in flexibility. If you do that then chaining transformations happens as a matter of course plus the flexibility of profiles in general improves. |
This goes a little bit off-topic here, but chaining profiles is difficult to implement and also difficult to model in the UI. A single profile that allows chaining transformations is by far easier and behaves like the |
Chaining of profiles is possible and in some ways, a lot easier than for transformations which rely on passing around a string value. Profiles can abstain from firing a callback which is ideal for building up logical flows. I think some of arguments you have are close to what was discussed in opensmarthouse/opensmarthouse-core#35. I had small adjustments in there which were related to configuration handling. Main problem comes from fact that openHAB does not support a dynamic configuration with list of complex types (ie. profile configurations). For my own case I made it working through proper structuring of single profile configuration ie. |
bad8ef5
to
70b9740
Compare
What is the state of this PR? I could help with reviewing it, sounds like a very nice addition. |
I planned to review it but you can have a look. These items remain IMO:
|
The problem with selecting the correct editor mode automatically is that especially for |
Yes I was thinking something along those lines, first of all it would be nice to pick the transformation type instead of having to type it (that may require an API endpoint). |
What would be a good endpoint for that? We could probably handle it under Would
be sufficient? That can be easily extracted. It's more difficult if the also need a description, because that is currently not exposed by the service component. |
It sure works! Having no description is not a problem. Maybe there would be a way to link the transformation to the add-on somehow so that when creating a JSONPATH transformation we would have a handy link to https://www.openhab.org/addons/transformations/jsonpath/ but that's just wishful thinking for now! |
That‘s the difficult part. Currently we only add a property for the transformation „id“, but that is not linked in any way to the add-on. We can probably add more properties, but that requires some more work. One add-on could expose different services. |
Actually, it works for all transformations, if a language is given, then it is used. But since it seems this is not even documented somewhere (or at least I didn't find it), it is not much used. And yes, most useful for transformations like MAP. So if you have |
@J-N-K Can you please allow maintainers to edit this PR? I want to push my changes to this PR, so we don't need follow-up PRs. |
Please also have a look at openhab/openhab-core#3487 which will probably allow automatic selection of editor mode because it adds different transformations for all script languages instead of a single one. |
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
* Add selection for language * Add selection for transformation type * Add selection for scripting language (if SCRIPT transformation Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
* Rearrange template code for better overview * Fetch languages and script languages from server and pass to transformation-general-settings * Remove obsolete key bindings * Minor fixes Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
70b9740
to
06f08f0
Compare
This PR is now finished IMO. What I've changed:
Adjusting the current code for this change would be simple, I can adjust the code that currently only sets the editor mode for MAP and SCALE to also set it for JS, RUBY etc., and adjusting the code snippet injection is simple as well. @J-N-K WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@J-N-K One thing I noticed is, that file-provisioned transformations have their type lowercase, e.g. Does lowercase/uppercase make a difference for core? |
…tions) instead of saving it to configuration Except for SCRIPT - here the mode is saved to the transformation because it cannot be looked up. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Historically transformation services have upper-case identifiers ( Looking at the (old) code technically the extension was only used for the The check is now more strict, so the type has to be lower case (which it probably is in 99.999% of all installations) and the same is applied to the managed transformations. However, the service name is still upper-case and should stay that way, otherwise we would probably break the same amount of installation. I'm not sure if an automatic |
Thanks for the explanation, so we should make the transformation type lowercase when UI creates a new transformation. |
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@ghys Can you please have a look, especially at my commits (I have already reviewed the rest). |
It would be great to habe this in M2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to you both for the feature and the work involved!
Depends on openhab/openhab-core#3036
This should be merged for the next major version of openHAB.
Signed-off-by: Jan N. Klug github@klug.nrw