-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Script profile: Separate toHandlerScript for commands and states #4058
Conversation
This allows much more fine-grained control for the script profile. E.g. it is now possible to mimic the behaviour of the `system:follow` profile, but apply a script transformation to the forwarded state. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
...rg.openhab.core.automation.module.script/src/main/resources/OH-INF/config/script-profile.xml
Outdated
Show resolved
Hide resolved
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
...rg.openhab.core.automation.module.script/src/main/resources/OH-INF/config/script-profile.xml
Outdated
Show resolved
Hide resolved
// try to parse the value | ||
Command newCommand = TypeParser.parseCommand(handlerAcceptedCommandTypes, returnValue); | ||
if (newCommand != null) { | ||
callback.handleCommand(newCommand); |
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.
If we try to keep it as "open as possible", do we need to apply the same workaround here that we have in openhab/openhab-addons#16263?
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.
Probably yes, but I am not sure whether we want to "distribute" that work-around across the code or if it would be better to wait for a solution of the underlying issue/problem.
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.
While having a look at ProfileCallbackImpl
, the problem seems to be that CommunicationManager::toAcceptedCommand
does not accept OpenClosedType
, which IMO is correct as you normally do not command contact Items.
The question is, how to solve that.
I would think the cleanest solution is to add a method like CommunicationManager::toAcceptedState
and to introduce a method called handleState
or handleUpdate
to the ProfileCallback
.
Then all profiles could call handleUpdate
instead of handleCommand
for state updates from the Item to the Thing.
...le.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java
Outdated
Show resolved
Hide resolved
...le.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java
Outdated
Show resolved
Hide resolved
...le.script/src/main/java/org/openhab/core/automation/module/script/profile/ScriptProfile.java
Outdated
Show resolved
Hide resolved
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@J-N-K I don't want to be pushy, but it would be great to get this PR merged soon. |
discard the states and not pass them through.</description> | ||
<limitToOptions>false</limitToOptions> | ||
</parameter> | ||
<parameter name="toHandlerScript" type="text"> |
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.
Maybe show this one as "advanced"? That hides it for new users, while keeping it for this that already have it configured.
Side note: It would be great if Main UI would automatically show "advanced" parameters if something is configured there. This would also be helpful e.g. for HTTP binding things.
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.
Side note: It would be great if Main UI would automatically show "advanced" parameters if something is configured there. This would also be helpful e.g. for HTTP binding things.
There we go: openhab/openhab-webui#2313
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.
Otherwise LGTM
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
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!
Refs openhab/openhab-core#4058. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Refs openhab/openhab-core#4058. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Refs openhab/openhab-core#4058. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@openhab/jruby-maintainers FYI in case you need to adjust documentation. |
It would be great if an upgrade tool could automatically update managed links to rename toHandlerScript |
Yeah, good idea. |
…ns folder (#2235) * Update transformation docs for script profile changes Refs openhab/openhab-core#4058. Signed-off-by: Florian Hotze <florianh_dev@icloud.com> * Migrate actions docs from addons to configuration folder Signed-off-by: Florian Hotze <florianh_dev@icloud.com> * Clean-up addons docs The removed files have not been picked up by the build process, i.e. they were not used by the website. Looking at their content, they also seem outdated. Signed-off-by: Florian Hotze <florianh_dev@icloud.com> * Minor enhancements Signed-off-by: Florian Hotze <florianh_dev@icloud.com> * Address review Signed-off-by: Florian Hotze <florianh_dev@icloud.com> --------- Signed-off-by: Florian Hotze <florianh_dev@icloud.com> Co-authored-by: stefan-hoehn <mail@stefanhoehn.com>
* Upgrade tool: Add upgrade task for script profile changes Refs #4058. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Refs #4058. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This allows much more fine-grained control for the script profile.
E.g. it is now possible to mimic the behaviour of the
system:follow
profile, but apply a script transformation to the forwarded state. I discovered the need for this when trying to make a KNX channel follow an Item state, but at the same time needed to transform the Item state before sending it to KNX.