Pass event source to profiles - #4990
Conversation
003c022 to
d132a38
Compare
1ecdfe6 to
b02811b
Compare
So that a user can define a profile that takes different actions depending on what's generating the command. Signed-off-by: Cody Cutrer <cody@cutrer.us>
b02811b to
8e4485b
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR extends the StateProfile interface to pass the event source to profiles, enabling users to define profiles that take different actions based on what generates the command.
- Adds a new overloaded
onCommandFromItemmethod to StateProfile that accepts an optional source parameter - Updates the CommunicationManager to pass the source parameter through the profile application chain
- Updates test cases to verify the new method signature and source parameter handling
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| StateProfile.java | Adds new overloaded method with source parameter and default implementation |
| CommunicationManager.java | Updates profile application methods to propagate source parameter |
| CommunicationManagerOSGiTest.java | Updates test verifications to match new method signature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /** | ||
| * Will be called if a command should be forwarded to the binding. | ||
| * | ||
| * @param command |
There was a problem hiding this comment.
The javadoc is missing parameter documentation for the command parameter. Both parameters should be properly documented with @param tags.
| /** | |
| * Will be called if a command should be forwarded to the binding. | |
| * | |
| * @param command | |
| * @param command the command to forward |
|
Please don’t forget updating the docs. |
|
@florian-h05 Do you think we should extend this section of the docs and basically state that custom implementations of |
Only applicable to commands from items. Dependent on openhab/openhab-core#4990 Signed-off-by: Cody Cutrer <cody@cutrer.us>
|
Yes, would be good I think. |
|
Ideally the ScriptProfile should support the source and inject it or pass it into the script. |
I'm not sure this is going to be possible. |
|
What if we add a new method to it so we can optionally pass the second source parameter, and then inject the source into the script like it’s done with the arguments? |
So that a user can define a profile that takes different actions depending on what's generating the command.