-
Notifications
You must be signed in to change notification settings - Fork 23
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
[basicprofiles] Initial contribution #95
Conversation
bundles/org.smarthomej.binding.basicprofiles/src/main/feature/feature.xml
Outdated
Show resolved
Hide resolved
...iles/src/main/java/org/smarthomej/binding/basicprofiles/internal/BasicProfilesConstants.java
Outdated
Show resolved
Hide resolved
...es/src/main/java/org/smarthomej/transform/basicprofiles/internal/BasicProfilesConstants.java
Outdated
Show resolved
Hide resolved
bundles/org.smarthomej.transform.basicprofiles/src/main/resources/OH-INF/binding/binding.xml
Outdated
Show resolved
Hide resolved
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
30871ce
to
c907883
Compare
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. These look like great additions. I have left some comments.
bundles/org.smarthomej.transform.basicprofiles/src/main/resources/OH-INF/binding/binding.xml
Outdated
Show resolved
Hide resolved
bundles/org.smarthomej.transform.basicprofiles/src/main/resources/OH-INF/binding/binding.xml
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public void onStateUpdateFromItem(State state) { | ||
callback.sendUpdate((State) applyRound(state)); |
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.
Is that correct? I thought that sendUpdate
updates the item's state. But shouldn't this result in a state that is processed by the handler?
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.
No. Round is a one-way Profile. It should be applied only in updates / commands from handler towards Item.
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.
@cweitkamp I would like to come back to this comment, as the current implementation causes issues with latest core changes. I also came across this when using the invert/negate profile.
As a result of this line we end up in an endless loop:
- The item updates its state to
123.12
and sends anItemStateUpdatedEvent
with a state of123.12
. - The
CommunicationManager
forwards this state update to the and according to its configuration the profile rounds that to123
and forwards that to the callback'ssendUpdate
method. - The callback issues an
ItemStateEvent
which is received by the item, which sets its state to123
. After that, it sends anItemStateUpdatedEvent
with a state of123
. - The
CommunicationManager
receives that, ... (start again at 2).
the same issue arises with the invert profile, because CLOSED
is inverted to OPEN
and after updating the item state to OPEN
it is again inverted to CLOSED
, resulting in the same update loop.
We can't prevent that by checking event source
, because the ItemUpdater
(that receives the ItemStateEvent
) calls GenericItem.setState
(which creates the ItemStateUpdatedEvent/ItemStateChangedEvent
) and the source
is lost (otherwise we could have set the source
of the ItemStateUpdatedEvent
to the same value as the ItemStateEvent
.
IMO a profile should only change values that are transferred from the handler to the item (or from the item to the handler), not interact with the item state itself.
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.
And, obviously, it is right now a blocking issue to migrate to OH 4 with M2 or newer snapshots, so maybe this can be resolved somehow.
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.
Your explanation sounds reasonable. I won't argue against it. Feel free to change/remove this part of code.
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.
After upgrading to latest OH milestone I am suffering from this myself. I submitted #478 to fix this.
bundles/org.smarthomej.transform.basicprofiles/src/main/resources/OH-INF/binding/binding.xml
Outdated
Show resolved
Hide resolved
bundles/org.smarthomej.transform.basicprofiles/src/main/resources/OH-INF/config/config.xml
Outdated
Show resolved
Hide resolved
...g.smarthomej.transform.basicprofiles/src/main/resources/OH-INF/i18n/basicprofiles.properties
Outdated
Show resolved
Hide resolved
...t/java/org/smarthomej/transform/basicprofiles/internal/factory/BasicProfilesFactoryTest.java
Outdated
Show resolved
Hide resolved
One more question. Should I contribute against the "main" branch? |
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
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.
Just two comments. Otherwise looks good. Jenkins fails unrelated.
Regarding the branch: I sync both branches manually by cherry-pciking the commits, so it doesn't matter wher you contribute. Just use what better fits your need.
...rc/main/java/org/smarthomej/transform/basicprofiles/internal/profiles/RoundStateProfile.java
Show resolved
Hide resolved
...rc/main/java/org/smarthomej/transform/basicprofiles/internal/profiles/RoundStateProfile.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
…le (#95) * Initial contribution Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Christoph Weitkamp github@christophweitkamp.de