-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[somfycul] Initial contribution #19207
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
base: main
Are you sure you want to change the base?
Conversation
init codebase from @weisserd replace gnu.io dependency with serial transport, remove commons-io dependency Signed-off-by: Marc Klasser <shox06@gmx.de>
Signed-off-by: Marc Klasser <shox06@gmx.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.
Pull Request Overview
Adds a new SomfyCUL binding to control Somfy RTS rollershutters via CUL devices (e.g. nanoCUL), based on initial work by Daniel Weisser with permission to develop officially.
Key changes:
- Complete new binding implementation with CUL bridge and Somfy device support
- Serial communication for CUL stick control with proper resource management
- Rolling code persistence and device address management for RTS protocol
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
bundles/pom.xml | Adds somfycul module to build |
bundles/org.openhab.binding.somfycul/pom.xml | Maven configuration for the binding |
bundles/org.openhab.binding.somfycul/src/main/java/.../*.java | Core binding classes including handlers, commands, and configuration |
bundles/org.openhab.binding.somfycul/src/main/resources/OH-INF/**/*.xml | Thing types and addon configuration |
bundles/org.openhab.binding.somfycul/src/main/resources/OH-INF/i18n/somfycul.properties | Internationalization strings |
bundles/org.openhab.binding.somfycul/README.md | Documentation and usage examples |
bom/openhab-addons/pom.xml | Adds dependency to BOM |
CODEOWNERS | Assigns code ownership |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...openhab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/CULHandler.java
Outdated
Show resolved
Hide resolved
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Outdated
Show resolved
Hide resolved
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Outdated
Show resolved
Hide resolved
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Show resolved
Hide resolved
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Outdated
Show resolved
Hide resolved
...openhab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/CULHandler.java
Outdated
Show resolved
Hide resolved
...openhab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/CULHandler.java
Outdated
Show resolved
Hide resolved
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.
Thank you for creating this contribution. I had a good look at all files except for the handlers, i scanned them quickly and once all is fixed i'll need another round to look closer.
...g.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULBindingConstants.java
Outdated
Show resolved
Hide resolved
...g.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULBindingConstants.java
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somfycul/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somfycul/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.somfycul/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
*/ | ||
public SomfyCULHandler(Thing thing) { | ||
super(thing); | ||
String somfyFolderName = OpenHAB.getUserDataFolder() + File.separator + "somfycul"; |
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.
Two comments abou this.
- Better to move this to the initialize method. As Enabling/disabling a thing does not re instantiate the handler, so changes are not picked up. Also the resources are used while the thing is not being used (when disabled)
- when moved to the initliaze, reading the file should be made in a async method. You can check some other bindings who make use of this pattern for reading from the userfolder.
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.
sounds reasonable, I'll change that, but it'll probably take a few days until I have time for it
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Outdated
Show resolved
Hide resolved
if (command instanceof UpDownType) { | ||
switch ((UpDownType) command) { |
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.
Use instanceof pattern matching, also on other locations
if (command instanceof UpDownType) { | |
switch ((UpDownType) command) { | |
if (command instanceof UpDownType upDownCommand) { | |
switch (upDownCommand) { |
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Outdated
Show resolved
Hide resolved
...ab.binding.somfycul/src/main/java/org/openhab/binding/somfycul/internal/SomfyCULHandler.java
Outdated
Show resolved
Hide resolved
…/binding/somfycul/internal/SomfyCULHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/binding/somfycul/internal/CULHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/binding/somfycul/internal/SomfyCULHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/binding/somfycul/internal/SomfyCULHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/binding/somfycul/internal/CULHandler.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
Signed-off-by: Marc Klasser <shox06@gmx.de>
3aa9016
to
91f2501
Compare
…/binding/somfycul/internal/CULHandler.java Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/thing/thing-types.xml Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/thing/thing-types.xml Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
Signed-off-by: Marc Klasser <shox06@gmx.de>
Signed-off-by: Marc Klasser <shox06@gmx.de>
Signed-off-by: Marc Klasser <shox06@gmx.de>
Signed-off-by: Marc Klasser <shox06@gmx.de>
…/binding/somfycul/internal/SomfyCULHandlerFactory.java Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…/binding/somfycul/internal/SomfyCULHandlerFactory.java Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
Signed-off-by: Marc Klasser <shox06@gmx.de>
…/binding/somfycul/internal/SomfyCULHandler.java Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Nookyx <62805370+Nookyx@users.noreply.github.com>
…addons into binding-somfycul
Signed-off-by: Marc Klasser <shox06@gmx.de>
Signed-off-by: Marc Klasser <shox06@gmx.de>
623672a
to
25ed987
Compare
Thank you @lsiepel for your extensive review so far! I'm unsure how you handle resolving discussion in this project. I usually leave it up to the person who created the discussion to decide if it is resolved or not, instead of assuming I've resolved it just because I pushed a commit that may or may not resolve the discussed issue - so unless you tell me otherwise, I'll refrain from resolving them on my end, apart from applied suggestions, because github automatically resolves the discussion in that case. |
Take your time, we are still early in the 5.1.0 development. There is one more comments a bit buried #19207 (comment) , just mention it so they won’t be overlooked. |
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.
Some more comments, Only the handler is left.
| Name | Type | Description | Default | Required | Advanced | | ||
|-----------------|---------|---------------------------------------|---------|----------|----------| | ||
| Serial Port (port) | String | The serial port (COM1, /dev/ttyS0, ...) your CUL stick is attached to | /dev/ttyUSB0 | yes | no | | ||
| Baud Rate (baudrate) | int | The serial port baud rate | 38400 | yes | no | |
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 align with your favorite markdown tool. It makes it easier for future reviews.
Same for the other table in this file
``` | ||
|
||
|
||
### Copy an existing Somfy RTS remote to your `somfy-device` |
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.
### Copy an existing Somfy RTS remote to your `somfy-device` | |
### Clone Somfy RTS Rmote to `somfy-device` |
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.
Last set of comments. All files have now been reviewed, some open comments and these new ones to fix.
@Nullable | ||
private SerialPortIdentifier portId; | ||
@Nullable | ||
private SerialPort serialPort; | ||
private final SerialPortManager serialPortManager; | ||
@Nullable | ||
private OutputStream outputStream; | ||
@Nullable | ||
private InputStream inputStream; |
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.
@Nullable | |
private SerialPortIdentifier portId; | |
@Nullable | |
private SerialPort serialPort; | |
private final SerialPortManager serialPortManager; | |
@Nullable | |
private OutputStream outputStream; | |
@Nullable | |
private InputStream inputStream; | |
private final SerialPortManager serialPortManager; | |
private @Nullable SerialPortIdentifier portId; | |
private @Nullable SerialPort serialPort; | |
private @Nullable OutputStream outputStream; | |
private @Nullable InputStream inputStream; |
* @return true if the command was successfully transmitted to the CUL device, false otherwise | ||
*/ | ||
public boolean executeCULCommand(Thing somfyDevice, SomfyCommand somfyCommand, String rollingCode, String address) { | ||
String culCommand = "Ys" + "A1" + somfyCommand.getActionKey() + "0" + rollingCode + address; |
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.
An inline comment on the meaning of these magic strings would be appreciated.
String culCommand = "Ys" + "A1" + somfyCommand.getActionKey() + "0" + rollingCode + address; | |
String culCommand = "YsA1" + somfyCommand.getActionKey() + "0" + rollingCode + address; |
* @param msg | ||
* the string to send |
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.
* @param msg | |
* the string to send | |
* @param msg the string to send |
lastCommandTime = System.currentTimeMillis(); | ||
return true; | ||
} catch (IOException e) { | ||
logger.error("Error writing '{}' to serial port {}: {}", msg, localPortId.getName(), e.getMessage()); |
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.
logger.error("Error writing '{}' to serial port {}: {}", msg, localPortId.getName(), e.getMessage()); | |
logger.warn("Error writing '{}' to serial port {}: {}", msg, localPortId.getName(), e.getMessage()); |
|
||
@Override | ||
public void initialize() { | ||
logger.debug("Start initializing!"); |
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.
logger.debug("Start initializing!"); |
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, | ||
"somfycul configuration missing or invalid"); |
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 make user if i18n custom keys for updateStatus so translations can be created (applies to all occurences)
Description
Adds a new binding to control somfy RTS rollershutters via CUL devices (e.g. nanoCUL).
This is based off the initial work done by Daniel Weisser back then with the somfycul binding (he never released it officially).
I have asked the original author (Daniel Weisser) in the community forum for permissions to further develop his addon, and he agreed to it.
The binding has been adapted to pass the build tests, be able to compile against OH5 and should also fix the gnu.io dependency issue that was still used in the original codebase.
Testing
For testing purposes, the addon can be installed manually with the latest JAR File.
I have tested it on my own setup with a nanoCUL
References
Fixes #15974