Issue of the topic: briefly search the community I fount that it could be impossible, but still don’t believe that such a base feature don’t work.
I assume the DSL as the first\main\base scripting language inside openhab (maybe I’m wrong)
So for one of transformations in modbus binding I use small DSL script and it works well, however when I try to pass the parameter to it like DSL(config:dsl:9a48d8ad72?param=100) besides it still runs well (considering the syntax for passing works), since I try to get the param variable inside script - it falls with error.
PS: I write the script in UI, so don’t use the file based config, on fresh system after reinstall on new hardware.
Not really. I’d call it the first legacy scripting language. But any of the other options will be as easy to get started in these days and provide a more complete set of capabilities. There’s lots that Rules DSL cannot do.
This is one of those things that Rules DSL cannot do. I don’t think there is a way to access the stuff that’s passed into the script in this way.
Rules DSL can be used in a Script Transformation certainly. But you can’t pass anything into the script like you can with the other languages. Or stated more precisely, you can pass the arguments but there’s no way to retrieve them inside the script.
If you need to do this, you need to use any of the other rules language options.
Because no one has volunteered to add that to the docs?
I can’t help with Groovy. My understanding is it’s possible but I have no experience with Groovy.
Indeed, the parameters are injected by OH core to all languages. But the language needs to have a way to access that parameter. There is no way to access it in Rule DSL. For jRuby and JS it’s as simple as referencing the variable by name. Maybe Groovy has a context Object or something like that.
Indeed, otherwise there’s be no point to the transformation. But the other passed in arguments are handled through a different mechanism as far as I understand it. And for Rules DSL there is special handling required to make input available to the script that runs.