]> git.basschouten.com Git - openhab-addons.git/commitdiff
[somfytahoma] added support for the Bioclimatic Pergola thing (#10498)
authorOndrej Pecta <opecta@gmail.com>
Fri, 16 Apr 2021 19:53:24 +0000 (21:53 +0200)
committerGitHub <noreply@github.com>
Fri, 16 Apr 2021 19:53:24 +0000 (21:53 +0200)
* [somfytahoma] added support for the Bioclimatic Pergola thing

Signed-off-by: Ondrej Pecta <opecta@gmail.com>
* Update bundles/org.openhab.binding.somfytahoma/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
bundles/org.openhab.binding.somfytahoma/README.md
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBioclimaticPergolaHandler.java [new file with mode: 0644]
bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/bioclimaticpergola.xml [new file with mode: 0644]
bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml

index 1613c6e9e28150f6a94f646a18c2653dbe29fd0b..bb2536fec36e4b61d6390b797f9c2bf94e215ee4 100644 (file)
@@ -69,9 +69,11 @@ Please see the example below.
 | roller shutter, screen, venetian blind, garage door, awning, pergola, curtain | control                      | device controller which reacts to commands UP/DOWN/ON/OFF/OPEN/CLOSE/MY/STOP + closure 0-100                                |
 | window                                                                        | control                      | device controller which reacts to commands UP/DOWN/ON/OFF/OPEN/CLOSE/STOP + closure 0-100                                   |
 | silent roller shutter                                                         | silent_control               | similar to control channel but in silent mode                                                                               |
-| venetian blind, adjustable slats roller shutter                               | orientation                  | percentual orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS)             |
+| venetian blind, adjustable slats roller shutter, bioclimatic pergola           | orientation                  | percentual orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS)             |
 | venetian blind, adjustable slats roller shutter                               | closure_orientation          | percentual closure and orientation of the blind's slats, it can have value 0-100. For IO Homecontrol devices only (non RTS) |
 | adjustable slats roller shutter                                               | rocker                       | used for setting the rocker position of the roller shutter, the only position allowing the slats control                    |
+| bioclimatic pergola                                                           | slats                        | slats state (open/closed)                                                                                                   |
+| bioclimatic pergola                                                           | pergola_command              | used for controlling biclimatic pergola (closeSlats, openSlats, stop)                                                       |
 | action group                                                                  | execute_action               | switch which reacts to ON command and triggers the predefined Tahoma action                                                 |
 | onoff, light                                                                  | switch                       | reacts to standard ON/OFF commands                                                                                          |
 | dimmer light                                                                  | light_intensity              | sets/gets intensity of the dimmer light or ON/OFF                                                                           |
index 87345342c01729a3bfca42d65d2eae55ff3cd08b..5e5fe956189021d65669d6b3c156a555e0adc66e 100644 (file)
@@ -124,6 +124,10 @@ public class SomfyTahomaBindingConstants {
     // Pergola
     public static final ThingTypeUID THING_TYPE_PERGOLA = new ThingTypeUID(BINDING_ID, "pergola");
 
+    // Bioclimatic Pergola
+    public static final ThingTypeUID THING_TYPE_BIOCLIMATIC_PERGOLA = new ThingTypeUID(BINDING_ID,
+            "bioclimaticpergola");
+
     // Window handle
     public static final ThingTypeUID THING_TYPE_WINDOW_HANDLE = new ThingTypeUID(BINDING_ID, "windowhandle");
 
@@ -171,8 +175,14 @@ public class SomfyTahomaBindingConstants {
     // Silent roller shutter
     public static final String CONTROL_SILENT = "control_silent";
 
-    // Blind
+    // Bioclimatic Pergola
+    public static final String SLATS = "slats";
+    public static final String PERGOLA_COMMAND = "pergola_command";
+
+    // Blind, Bioclimatic Pergola
     public static final String ORIENTATION = "orientation";
+
+    // Blind
     public static final String CLOSURE_AND_ORIENTATION = "closure_orientation";
 
     // Action group
@@ -306,6 +316,8 @@ public class SomfyTahomaBindingConstants {
     public static final String COMMAND_DOWN = "down";
     public static final String COMMAND_OPEN = "open";
     public static final String COMMAND_CLOSE = "close";
+    public static final String COMMAND_OPEN_SLATS = "openSlats";
+    public static final String COMMAND_CLOSE_SLATS = "closeSlats";
     public static final String COMMAND_STOP = "stop";
     public static final String COMMAND_OFF = "off";
     public static final String COMMAND_CHECK_TRIGGER = "checkEventTrigger";
@@ -385,7 +397,8 @@ public class SomfyTahomaBindingConstants {
             THING_TYPE_GATE, THING_TYPE_CURTAIN, THING_TYPE_ELECTRICITYSENSOR, THING_TYPE_DOCK, THING_TYPE_SIREN,
             THING_TYPE_ADJUSTABLE_SLATS_ROLLERSHUTTER, THING_TYPE_MYFOX_CAMERA, THING_TYPE_ROLLERSHUTTER_UNO,
             THING_TYPE_WATERSENSOR, THING_TYPE_HUMIDITYSENSOR, THING_TYPE_MYFOX_ALARM, THING_TYPE_THERMOSTAT,
-            THING_TYPE_DIMMER_LIGHT, THING_TYPE_EXTERIOR_HEATING_SYSTEM, THING_TYPE_VALVE_HEATING_SYSTEM));
+            THING_TYPE_DIMMER_LIGHT, THING_TYPE_EXTERIOR_HEATING_SYSTEM, THING_TYPE_VALVE_HEATING_SYSTEM,
+            THING_TYPE_BIOCLIMATIC_PERGOLA));
 
     // somfy gateways
     public static Map<Integer, String> gatewayTypes = new HashMap<Integer, String>() {
index bf6c40bbdeee855ee1de569fb74c442877a38796..85e2a80df659679913aa28b4d8dd5d9848f56a31 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaActionGroupHandler;
 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAdjustableSlatsRollerShutterHandler;
 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAwningHandler;
+import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaBioclimaticPergolaHandler;
 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaBridgeHandler;
 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaContactSensorHandler;
 import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaCurtainHandler;
@@ -159,6 +160,8 @@ public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
             return new SomfyTahomaDoorLockHandler(thing);
         } else if (thingTypeUID.equals(THING_TYPE_PERGOLA)) {
             return new SomfyTahomaPergolaHandler(thing);
+        } else if (thingTypeUID.equals(THING_TYPE_BIOCLIMATIC_PERGOLA)) {
+            return new SomfyTahomaBioclimaticPergolaHandler(thing);
         } else if (thingTypeUID.equals(THING_TYPE_WINDOW_HANDLE)) {
             return new SomfyTahomaWindowHandleHandler(thing);
         } else if (thingTypeUID.equals(THING_TYPE_TEMPERATURESENSOR)) {
index 29b3b66c67edb0669428714ed0e650ec11b6cc5b..41d03fc40b989c4e66491cddc31b922c4309bab6 100644 (file)
@@ -275,7 +275,12 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService
                 deviceDiscovered(device, THING_TYPE_DOOR_LOCK, place);
                 break;
             case CLASS_PERGOLA:
-                deviceDiscovered(device, THING_TYPE_PERGOLA, place);
+                if ("BioclimaticPergola".equals(device.getWidget())) {
+                    // widget: BioclimaticPergola
+                    deviceDiscovered(device, THING_TYPE_BIOCLIMATIC_PERGOLA, place);
+                } else {
+                    deviceDiscovered(device, THING_TYPE_PERGOLA, place);
+                }
                 break;
             case CLASS_WINDOW_HANDLE:
                 // widget: ThreeWayWindowHandle
diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBioclimaticPergolaHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBioclimaticPergolaHandler.java
new file mode 100644 (file)
index 0000000..2bb4a35
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) 2010-2021 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.somfytahoma.internal.handler;
+
+import static org.openhab.binding.somfytahoma.internal.SomfyTahomaBindingConstants.*;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.Thing;
+import org.openhab.core.types.Command;
+import org.openhab.core.types.RefreshType;
+
+/**
+ * The {@link SomfyTahomaBioclimaticPergolaHandler} is responsible for handling commands,
+ * which are sent to one of the channels of the bioclimatic pergola thing.
+ *
+ * @author Ondrej Pecta - Initial contribution
+ */
+@NonNullByDefault
+public class SomfyTahomaBioclimaticPergolaHandler extends SomfyTahomaBaseThingHandler {
+
+    public SomfyTahomaBioclimaticPergolaHandler(Thing thing) {
+        super(thing);
+        stateNames.put(SLATS, "core:SlatsOpenClosedState");
+        stateNames.put(ORIENTATION, "core:SlatsOrientationState");
+    }
+
+    @Override
+    public void handleCommand(ChannelUID channelUID, Command command) {
+        super.handleCommand(channelUID, command);
+
+        if (command instanceof RefreshType) {
+            return;
+        }
+
+        switch (channelUID.getId()) {
+            case PERGOLA_COMMAND:
+                String cmd = getTahomaCommand(command.toString().toUpperCase());
+                sendCommand(cmd);
+                break;
+            case ORIENTATION:
+                // Bioclimatic pergola can control only orientation and full closure, not partial closure
+                String param = "[" + toInteger(command) + "]";
+                sendCommand(COMMAND_SET_ORIENTATION, param);
+                break;
+            default:
+                return;
+        }
+    }
+
+    private String getTahomaCommand(String command) {
+        switch (command) {
+            case "OFF":
+            case "DOWN":
+            case "CLOSE":
+            case "CLOSESLATS":
+                return COMMAND_CLOSE_SLATS;
+            case "ON":
+            case "UP":
+            case "OPEN":
+            case "OPENSLATS":
+                return COMMAND_OPEN_SLATS;
+            default:
+                return COMMAND_STOP;
+        }
+    }
+}
diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/bioclimaticpergola.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/bioclimaticpergola.xml
new file mode 100644 (file)
index 0000000..cf94ba5
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<thing:thing-descriptions bindingId="somfytahoma"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
+       xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
+
+       <thing-type id="bioclimaticpergola">
+               <supported-bridge-type-refs>
+                       <bridge-type-ref id="bridge"/>
+               </supported-bridge-type-refs>
+               <label>Somfy Bioclimatic Pergola</label>
+               <channels>
+                       <channel id="slats" typeId="slats"></channel>
+                       <channel id="orientation" typeId="orientation"></channel>
+                       <channel id="pergola_command" typeId="pergola_command"></channel>
+               </channels>
+               <representation-property>url</representation-property>
+               <config-description-ref uri="thing-type:somfytahoma:device"/>
+       </thing-type>
+
+</thing:thing-descriptions>
index 4f20b1c23520a3e3f28c33668af355a75daa234c..44fee7caf86e670c7c96ddcd6095e1b251b6659f 100644 (file)
                <description>The scenarios defined in the cloud portal</description>
                <autoUpdatePolicy>recommend</autoUpdatePolicy>
        </channel-type>
+
+       <channel-type id="slats">
+               <item-type>Contact</item-type>
+               <label>Slats</label>
+               <description>Slats having OPEN/CLOSED state</description>
+               <state readOnly="true"/>
+       </channel-type>
+
+       <channel-type id="pergola_command">
+               <item-type>String</item-type>
+               <label>Command</label>
+               <description>A channel used for sending commands to Somfy Bioclimatic Pergola device</description>
+               <state>
+                       <options>
+                               <option value="closeSlats">Close slats</option>
+                               <option value="openSlats">Open slats</option>
+                               <option value="stop">Stop</option>
+                       </options>
+               </state>
+       </channel-type>
 </thing:thing-descriptions>