Skip to content

Conversation

Nookyx
Copy link

@Nookyx Nookyx commented Aug 20, 2025

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

Nookyx added 2 commits August 19, 2025 02:02
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>
@Nookyx Nookyx requested a review from a team as a code owner August 20, 2025 23:18
@wborn wborn added the new binding If someone has started to work on a binding. For a new binding PR. label Aug 20, 2025
@wborn wborn requested a review from Copilot August 20, 2025 23:23
Copy link

@Copilot Copilot AI left a 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.

Copy link
Contributor

@lsiepel lsiepel left a 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.

*/
public SomfyCULHandler(Thing thing) {
super(thing);
String somfyFolderName = OpenHAB.getUserDataFolder() + File.separator + "somfycul";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments abou this.

  1. 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)
  2. 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.

Copy link
Author

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

Comment on lines 78 to 79
if (command instanceof UpDownType) {
switch ((UpDownType) command) {
Copy link
Contributor

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

Suggested change
if (command instanceof UpDownType) {
switch ((UpDownType) command) {
if (command instanceof UpDownType upDownCommand) {
switch (upDownCommand) {

Nookyx and others added 6 commits August 21, 2025 22:06
…/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>
Nookyx and others added 14 commits August 21, 2025 22:51
…/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>
Signed-off-by: Marc Klasser <shox06@gmx.de>
@Nookyx
Copy link
Author

Nookyx commented Aug 21, 2025

Thank you @lsiepel for your extensive review so far!
I think I've fixed everything so far apart from this and I'll do that as well, as soon as I have the time for it.

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.

@lsiepel
Copy link
Contributor

lsiepel commented Aug 22, 2025

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.
I prefer the same review proces, perfect!

Copy link
Contributor

@lsiepel lsiepel left a 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.

Comment on lines +20 to +23
| 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 |
Copy link
Contributor

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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Copy an existing Somfy RTS remote to your `somfy-device`
### Clone Somfy RTS Rmote to `somfy-device`

Copy link
Contributor

@lsiepel lsiepel left a 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.

Comment on lines +53 to +61
@Nullable
private SerialPortIdentifier portId;
@Nullable
private SerialPort serialPort;
private final SerialPortManager serialPortManager;
@Nullable
private OutputStream outputStream;
@Nullable
private InputStream inputStream;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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;
Copy link
Contributor

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.

Suggested change
String culCommand = "Ys" + "A1" + somfyCommand.getActionKey() + "0" + rollingCode + address;
String culCommand = "YsA1" + somfyCommand.getActionKey() + "0" + rollingCode + address;

Comment on lines +93 to +94
* @param msg
* the string to send
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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!");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.debug("Start initializing!");

Comment on lines +133 to +134
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"somfycul configuration missing or invalid");
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new binding If someone has started to work on a binding. For a new binding PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[somfycul] New Binding somfycul

3 participants