Once this is done, hopefully, all binding transformations will:
Use core’s ChannelTransformation class to perform transformations, instead of using separate in-binding implementations
Support both colon JSONPATH:$.path and parentheses JSONPATH($.path) syntax for specifying transformations. The idea is that new users can just use the parantheses syntax everywhere, as documented and used in the core (for e.g. item labels). So this eliminates confusion of whether to use colon or parentheses.
Support transformation chaining by listing each transformation on a separate line in the UI, or as a comma separated list in .things file. The old intersection symbol is still supported and can be mixed with the multi-line / list stype. Every time I needed to chain transformations, I had to hunt around for where I can copy the symbol from. I won’t have to look at an intersection symbol again!
Support comments in the transformation list. This is especially for UI users. PR (merged)
I’ve submitted these PRs related to transformations. I’m hoping that this makes it easier to deal with transformations and avoid future confusions to new users.
Not applicable. It uses core’s label formatting method REGEX(.*):%s, which doesn’t support chaining. It will be a separate task to implement chaining in this along with the core label.
enocean
Not changed. It only supports a single transformation. Its config defines the transformation type and transformation function separately. Refactoring would require deprecating these configuration parameters and introducing a new transformation parameter like the other bindings.
I’ve been lightly pushing for this since OH 1.x. Bindings shouldn’t be in the business of implementing transformations themselves.
I’ve always disliked using that special symbol for chaining. I understand why it was chosen but it is hard to type as you describe.
These are great improvements! Thanks for posting.
While you are working on this sort of thing, does this perhaps open some opportunities to support chaining in the transform profile too? Awhile back adding support for that was looked into but it was determined to be too hard to implement. Maybe with chaining now implemented in core support for chaining in the transform profile is more feasible.
Also, what about Item label/state description patterns?
I don’t think that’s the same thing. What @JimT’s PRs do is:
make it so defining a transform using : in MQTT, HTTP, and a couple other bindings will work everywhere
make it so the tranditional way of defining transformations using () instead of : will work everywhere
make it so chaining transformations works everywhere
Allowing the definition of an inline Map transformation will require changes to the Map transform add-on, not core.
Having a multiline text area to enter the transformation certainly makes inline mapt transformations more attractive.
Eventually though it would be nice if we could select transformations from a list too similar to what the transform profile allows. But that’s definitely outside of scope for this effort.
No, but this has been something I’ve thought of for a long time. Maybe I’ll look into this next.
Indeed
Yes. Although at the moment, one transformation must fit in one line. It cannot span multiple lines.
However, and I doubt it will get accepted, but I’m willing to make the POC for it, with parentheses syntax we could probably make it span multiple lines.
It allows inline script also be more complex, and support multi line map, for example
MAP(|
A=X
B=Y
)
# Chain it with ruby transform
RB (|
logger.info "hello"
Switch1.on # turn on Switch1
input.downcase
)
# maybe chain it with this too later
# JSONPATH($.device.temperature)
// That's all, folks!
That’s two inline transformations map and RB spanning multiple lines.
This idea is a bit iffy, because a) it can probably be done on the yaml level anyway (and better if it can be done), and b) it makes the list/array weird. It’s only useful for UI input. Not that useful nor practical for, say, .things file
I thought of this too but haven’t investigated it.
See Widget Expressions & Variables | openHAB For one way To do it as a ma in JS. It’s basically the same approach as ruby. Define the map as a dict and select using input.
@JimT Since you contributed the SCRIPT profiles: Do you have an idea why the config description for profile:transform:JS does not list the available scripts as options for the stateFromItemScript und commandFromItemScript?