Skip to content
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

[somfymylink] Somfy MyLink Binding initial contribution #5652

Merged
merged 53 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2dfa595
Initial contribution
May 28, 2019
b6c6444
fix: code style issues from static code analysis tool
May 29, 2019
cbafed4
fix: add entry in bundle pom.xml and code owners entry
May 29, 2019
5e05c8c
fix: update how to get bundle context based on upstream changes
Dec 5, 2019
f24ad9e
fix: update codeowners to correct binding name
Dec 5, 2019
563672b
rebasing issues
LoungeFlyZ May 1, 2020
26c77f4
fix: code style issues from static code analysis tool
May 29, 2019
df3234e
fix: remove redundant deps
Dec 5, 2019
b6ffd32
fix: formatting issues from spotless
Dec 5, 2019
eef995d
fix: inline nullables
Dec 5, 2019
b189d68
fix: formatting
Dec 5, 2019
2b8ae92
fix: remove boilerplate javadoc comments
Dec 5, 2019
ccf5848
fix: remove javadoc boiler plate comment
Dec 5, 2019
6aa86a8
fix: update namespaces
Dec 5, 2019
a2ddb7d
fix: namespaces
Dec 5, 2019
8aed467
fix: formatting of log entries
Dec 5, 2019
316e70f
fix: formatting of log entries, style fixes
Dec 5, 2019
875a5f4
fix: remove unused file
Dec 5, 2019
f35d9f1
fix: remove readonly flag off scene list
Dec 5, 2019
13d5ce1
fix: update README
Dec 15, 2019
1a15b02
fix: SomfyMyLinkStateDescriptionOptionsProvider to use BaseDynamicSta…
Dec 16, 2019
d72ff12
fix: remove duplicate checks in some if statements.
Dec 16, 2019
bb5a2e9
fix: use use try-with-resources vs.close and formatting.
Jan 18, 2020
e99281e
fix: tidy up bridge thingupdated handler
Jan 19, 2020
720b470
fix: fix sync on heartbeat setup, remove unneeded checks.
Apr 27, 2020
cf14ec2
fix: update pom with new version
LoungeFlyZ May 1, 2020
813d777
fix: make waiting for a response message more robust and handle parti…
LoungeFlyZ May 1, 2020
da8ea59
fix: spotless formatting updates
LoungeFlyZ May 1, 2020
aaba141
fix: update copyright message to current year
LoungeFlyZ May 2, 2020
3353417
fix: add author tags
LoungeFlyZ May 2, 2020
c6e618a
fix: remove length parameters from socket writing, not needed
LoungeFlyZ May 2, 2020
da8259e
fix: ensure use of ASCII char set when reading from socket
LoungeFlyZ May 2, 2020
b7ff1b8
fix: make sending commands with no response async instead of blocking.
LoungeFlyZ May 2, 2020
ac4e284
fix: make sending commands use single threaded exectutor and Completa…
LoungeFlyZ May 2, 2020
a5ac3f8
fix: review updates, exception handling, socket write flushing
LoungeFlyZ May 2, 2020
00e0847
fix: minor logging tweaks
LoungeFlyZ May 2, 2020
81d184a
fix: address review comments, refactor message building into objects …
LoungeFlyZ May 3, 2020
6ea95c2
fix: EOF markers in some files added, public final fields and in corr…
LoungeFlyZ May 4, 2020
855b8ad
fix: remove redundant thread execution in discovery
LoungeFlyZ May 4, 2020
cbc140c
fix: refactor discovery to simplify
LoungeFlyZ May 4, 2020
a1e01fd
fix: bridge handler config checks, heartbeat fixes, refactor command …
LoungeFlyZ May 4, 2020
1ff2dc2
fix: refactor keepalive/ping/heartbeat to simplify
LoungeFlyZ May 4, 2020
7768626
fix: refactored discovery as ThingHandlerService and formatting fixes
LoungeFlyZ May 4, 2020
cb5628a
fix: update to use correct class for logger, addressing broken code a…
LoungeFlyZ May 4, 2020
3b9b117
fix: removed unused code
LoungeFlyZ May 4, 2020
b0bd549
fix: address review comments and fix up exceptions and logging
LoungeFlyZ May 4, 2020
7064f66
fix: address review comments, NotNullByDefault annotations on missing…
LoungeFlyZ May 4, 2020
71b1852
fix: updated to JsonReader to avoid buffers reading from socket and W…
LoungeFlyZ May 5, 2020
552fe3b
fix: exception message
LoungeFlyZ May 5, 2020
7381a02
fix: additional cleanup, no longer needed null checks, and redundant …
LoungeFlyZ May 5, 2020
5425843
fix: tweaking some logging levels to be more appropriate.
LoungeFlyZ May 7, 2020
3ba9f7a
fix: remove redundant logging and null/empty checks
LoungeFlyZ May 22, 2020
c2abb35
fix: update pom to use 2.5.6-snapshot
LoungeFlyZ May 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
/bundles/org.openhab.binding.snmp/ @J-N-K
/bundles/org.openhab.binding.solaredge/ @alexf2015
/bundles/org.openhab.binding.solarlog/ @johannrichard
/bundles/org.openhab.binding.somfymylink/ @loungeflyz
/bundles/org.openhab.binding.somfytahoma/ @octa22
/bundles/org.openhab.binding.sonos/ @kgoderis @lolodomo
/bundles/org.openhab.binding.sonyaudio/ @freke
Expand Down
49 changes: 49 additions & 0 deletions bundles/org.openhab.binding.somfymylink/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions bundles/org.openhab.binding.somfymylink/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.somfymylink</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.somfymylink/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab2-addons
65 changes: 65 additions & 0 deletions bundles/org.openhab.binding.somfymylink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Somfy myLink Binding

This binding supports the [Somfy myLink](https://www.somfysystems.com/en-us/products/1811403/mylink-) device for control of Somfy RTS blinds/shades.

## Supported Things

Currently these things are supported:

- bridge (Somfy MyLink bridge, which can discover roller shades and scenes)
- roller shades (UP, DOWN, STOP control of a roller shade).

This binding has been tested with myLink firmware 5.23.

## Discovery

To start a discovery:

- install this binding
- open Paper UI
- add a new thing in menu Configuration/Things
- choose SomfyMyLink Binding and select Somfy MyLink Bridge
- enter it's IP Address and system id. The system id This can be found in the integration settings -> Control4 section of your My Link app

If the supplied ip address and system id are correct, the automatic discovery starts immediately and detected roller shades appear in Paper UI inbox.

## Thing Configuration

### mylink

| Parameter | Parameter ID | Required/Optional | Description |
|------------------|-------------------|-------------------|-------------|
| IP or Hostname | ipAddress | Required | Hostname or IP Address of the myLink device |
| System Id | systemId | Required | The system id configured on the myLink device |

### shade

| Parameter | Parameter ID | Required/Optional | Description |
|------------------|-------------------|-------------------|-------------|
| Target ID | targetId | Required | Address of shade in the Somfy system |

### scene

| Parameter | Parameter ID | Required/Optional | Description |
|------------------|-------------------|-------------------|-------------|
| Scene ID | sceneId | Required | Address of scene in the Somfy system |

## Channels

The following channels are supported by the binding. Note that specific weather station models may support only some or all of these channels.

| Channel ID | Item Type | Description |
|---------------------------------|-------------------------|---------------------------------------------------------------|
| shadeControl | Rollershutter | Device control (UP, DOWN, STOP) |
| scenelist | String | Comma-separated list of scenes of form sceneId=sceneName |
| button | Switch | Button to trigger a scene or rule |

## Example

### Things

```
Bridge somfymylink:mylink:mylink1 "myLink Bridge" @ "Office" [ ipAddress="192.168.1.1", systemId="mysystemidhere" ] {
Thing shade shade1 "Living Room" [ targetId="CC114A21.1" ]
}
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.somfymylink/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.6-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.somfymylink</artifactId>

<name>openHAB Add-ons :: Bundles :: Somfy MyLink Binding</name>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.somfymylink.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.thing.ThingTypeUID;

/**
* @author Chris Johnson - Initial contribution
*/
@NonNullByDefault
public class SomfyMyLinkBindingConstants {

private static final String BINDING_ID = "somfymylink";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_SHADE = new ThingTypeUID(BINDING_ID, "shade");
public static final ThingTypeUID THING_TYPE_SCENE = new ThingTypeUID(BINDING_ID, "scene");
public static final ThingTypeUID THING_TYPE_MYLINK = new ThingTypeUID(BINDING_ID, "mylink");

// List of all Channel ids
public static final String CHANNEL_SHADELEVEL = "shadelevel";
public static final String CHANNEL_SCENECONTROL = "scenecontrol";
public static final String CHANNEL_SCENES = "sceneid";

// Thing config properties
public static final String TARGET_ID = "targetId";
public static final String SCENE_ID = "sceneId";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.somfymylink.internal;

import static org.openhab.binding.somfymylink.internal.SomfyMyLinkBindingConstants.*;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.openhab.binding.somfymylink.internal.handler.SomfyMyLinkBridgeHandler;
import org.openhab.binding.somfymylink.internal.handler.SomfyMyLinkStateDescriptionOptionsProvider;
import org.openhab.binding.somfymylink.internal.handler.SomfySceneHandler;
import org.openhab.binding.somfymylink.internal.handler.SomfyShadeHandler;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* @author Chris Johnson - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.somfymylink", service = ThingHandlerFactory.class)
public class SomfyMyLinkHandlerFactory extends BaseThingHandlerFactory {

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = new HashSet<>(
Arrays.asList(THING_TYPE_MYLINK, THING_TYPE_SHADE, THING_TYPE_SCENE));

public static final Set<ThingTypeUID> DISCOVERABLE_DEVICE_TYPES_UIDS = new HashSet<>(
Arrays.asList(THING_TYPE_SHADE, THING_TYPE_SCENE));

private @Nullable SomfyMyLinkStateDescriptionOptionsProvider stateDescriptionProvider;

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (thingTypeUID.equals(THING_TYPE_MYLINK)) {
return new SomfyMyLinkBridgeHandler((Bridge) thing, stateDescriptionProvider);
}
if (THING_TYPE_SHADE.equals(thingTypeUID)) {
return new SomfyShadeHandler(thing);
}
if (THING_TYPE_SCENE.equals(thingTypeUID)) {
return new SomfySceneHandler(thing);
}

return null;
}

@Reference
protected void setDynamicStateDescriptionProvider(SomfyMyLinkStateDescriptionOptionsProvider provider) {
this.stateDescriptionProvider = provider;
}

protected void unsetDynamicStateDescriptionProvider(SomfyMyLinkStateDescriptionOptionsProvider provider) {
this.stateDescriptionProvider = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.somfymylink.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link SomfyMyLinkConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Chris Johnson - Initial contribution
*/
@NonNullByDefault
public class SomfyMyLinkConfiguration {
public String ipAddress = "";

public String systemId = "";
}
Loading