Skip to content

Commit

Permalink
[somfymylink] Somfy MyLink Binding initial contribution (#5652)
Browse files Browse the repository at this point in the history
* Initial contribution

Signed-off-by: Chris Johnson <chrisfjohnson@live.com>

Co-authored-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
  • Loading branch information
Chris Johnson and Connor Petty committed May 25, 2020
1 parent ba44848 commit 2176127
Show file tree
Hide file tree
Showing 39 changed files with 1,880 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -183,6 +183,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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>
@@ -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";
}
@@ -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;
}
}
@@ -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 = "";
}

0 comments on commit 2176127

Please sign in to comment.