-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[lcn] Add LCN binding #7509
[lcn] Add LCN binding #7509
Conversation
Travis tests were successfulHey @fwolter, |
Migrates the Local Control Network Binding from OH1 to OH2. Closes #108 Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Fabian Wolter <[email protected]>
Travis tests were successfulHey @fwolter, |
1 similar comment
Travis tests were successfulHey @fwolter, |
Wow, a huge work @fwolter, thanks! |
Thanks, the following classes are based on the OH1 implementation. Most of them are DTOs and constant definitions. The rest is written from scratch.
|
Signed-off-by: Fabian Wolter <[email protected]>
Travis tests were successfulHey @fwolter, |
Signed-off-by: Fabian Wolter <[email protected]>
Travis tests have failedHey @fwolter, |
Travis tests have failedHey @fwolter, |
Signed-off-by: Fabian Wolter <[email protected]>
Travis tests were successfulHey @fwolter, |
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.
Awesome work, @fwolter!
Really very clean and professional code and I see that you dived deep into the openHAB concepts already by using advanced stuff like profiles, vetos, etc.
My review comments should all be fairly simple, there's nothing that should mean any huge effort. Please see below and let me know, if you have any questions!
bundles/org.openhab.binding.lcn/src/main/resources/ESH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.lcn/src/main/resources/ESH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.lcn/src/main/resources/ESH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.lcn/src/main/resources/ESH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
<channel-type id="output" advanced="true"> | ||
<item-type>Dimmer</item-type> | ||
<label>Output</label> | ||
<autoUpdatePolicy>veto</autoUpdatePolicy> |
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.
Please note that your binding is expected to quickly provide state updates after receiving commands, if you go for a veto here.
Is that really the case for all the channels where you have put "veto"?
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.
I removed the vetos for these states which must be polled after changing and left the veto for those, which are updated event-based (~100ms after the change).
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.
This is amazing work you have done here. Nice job!
....openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/PckGenerator.java
Outdated
Show resolved
Hide resolved
....openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/PckGenerator.java
Outdated
Show resolved
Hide resolved
....openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/PckGenerator.java
Outdated
Show resolved
Hide resolved
....openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/PckGenerator.java
Outdated
Show resolved
Hide resolved
....openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/PckGenerator.java
Outdated
Show resolved
Hide resolved
...org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleHandler.java
Outdated
Show resolved
Hide resolved
...org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleHandler.java
Outdated
Show resolved
Hide resolved
...org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleHandler.java
Outdated
Show resolved
Hide resolved
AbstractLcnModuleSubHandler newHandler = type.getSubHandlerClass() | ||
.getDeclaredConstructor(LcnModuleHandler.class, ModInfo.class).newInstance(this, info); |
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.
Why not have each LcnChannelGroup enum instance include a AbstractLcnModuleSubHandler factory lambda method for creating class instances? That way you wouldn't need to use reflection here.
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.
I really like this idea! Refactored.
...enhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/LcnChannelGroup.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Fabian Wolter <[email protected]>
Thank you very much for your positive feedback and your time spent! Really appreciate it! I implemented your remarks and commented on your questions. During testing, I found two bugs, I fixed. |
Travis tests were successfulHey @fwolter, |
Signed-off-by: Fabian Wolter <[email protected]>
Signed-off-by: Fabian Wolter <[email protected]>
...rg.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/PckGatewayHandler.java
Outdated
Show resolved
Hide resolved
...ab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleDiscoveryService.java
Outdated
Show resolved
Hide resolved
...org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fabian Wolter <[email protected]>
....openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/SendData.java
Outdated
Show resolved
Hide resolved
...s/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/common/LcnDefs.java
Outdated
Show resolved
Hide resolved
...enhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/SendDataPck.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fabian Wolter <[email protected]>
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.
I think these are my final changes. Thanks for keeping up 😄
...nhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/connection/StateMachine.java
Outdated
Show resolved
Hide resolved
...cn/src/main/java/org/openhab/binding/lcn/internal/pchkdiscovery/LcnPchkDiscoveryService.java
Outdated
Show resolved
Hide resolved
...cn/src/main/java/org/openhab/binding/lcn/internal/pchkdiscovery/LcnPchkDiscoveryService.java
Outdated
Show resolved
Hide resolved
Travis tests were successfulHey @fwolter, |
Signed-off-by: Fabian Wolter <[email protected]>
Travis tests were successfulHey @fwolter, |
* | ||
* @author Fabian Wolter - Initial Contribution | ||
*/ | ||
@NonNullByDefault | ||
public abstract class AbstractState { | ||
public abstract class AbstractState<T extends AbstractStateMachine<T, U>, U extends AbstractState<T, U>> { |
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 it necessary to add all these generics? Shouldn't the new state factory function just be a simple Function< AbstractStateMachine, AbstractState>
?
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.
I tried several approaches, but couldn't get rid of the generics. Any suggestions?
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.
Not sure what to say. As an example, this code compiles just fine:
public interface State {
}
public interface StateMachine {
public void nextState(Function<StateMachine, State> stateFactory);
}
public class StateImpl implements State {
private StateMachine context;
public StateImpl(StateMachine context) {
this.context = context;
}
public void changeState() {
context.nextState(StateImpl::new);
}
}
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.
The problems arise when storing data in the context like the connection object. These data cannot be accessed from within StateImpl
, because the reference to the context is of the interface's type. I used generics to be able to access the concrete type.
The state machine and state abstraction layer could be removed (and so the generics), but then the code wouldn't be reusable.
Another approach is to replace the generics by casts. If I see correctly only a single cast would be necessary.
As always, there are several solutions with their pros and cons. Maybe I hadn't the bright idea, yet.
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.
Well, I took that as a challenge and spent way too much time trying to find a better solution, but I can't say I really found one. I think the generics are irreducibly complex, so they have to stay.
With that resolved I don't really have anything else to suggest. Nice work.
Me too :) Thanks! |
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.
Many thanks again, @fwolter!
Also for your patience with the numerous reviews by @cpmeister. 🤣
Let's get that in openHAB 2.5.6!
Thanks for merging and thank you very much for the highly professional review feedback. I integrated your proposals very gladly! |
Thanks for this great enhancement |
Can you please open an issue? I will take a look into it. |
Was about to do so. No reason to do so. Sorry for the confusion. |
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]> Signed-off-by: CSchlipp <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]> Signed-off-by: Daan Meijer <[email protected]>
* [lcn] Add LCN binding Migrates the Local Control Network Binding from OH1 to OH2. Closes openhab#108 Signed-off-by: Fabian Wolter <[email protected]>
Migrates the Local Control Network Binding from OH1 to OH2.
Closes #108
Signed-off-by: Fabian Wolter [email protected]