]> git.basschouten.com Git - openhab-addons.git/commitdiff
[deconz] add doorlock support (#8965)
authorJ-N-K <J-N-K@users.noreply.github.com>
Sat, 7 Nov 2020 23:55:33 +0000 (00:55 +0100)
committerGitHub <noreply@github.com>
Sat, 7 Nov 2020 23:55:33 +0000 (15:55 -0800)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.deconz/README.md
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java
bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java
bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml

index d10d17bf8dd917e560789ccbbdcc1f9a8264b1c7..01dbdfed0af46863cded95a0cb823caff2d8d901 100644 (file)
@@ -29,7 +29,7 @@ These sensors are supported:
 | Color Controller                  | ZBT-Remote-ALL-RGBW               | `colorcontrol`       |
 
 
-Additionally lights, window coverings (blinds) and thermostats are supported:
+Additionally lights, window coverings (blinds), door locks and thermostats are supported:
 
 | Device type                          | Resource Type                                 | Thing type              |
 |--------------------------------------|-----------------------------------------------|-------------------------|
@@ -41,6 +41,7 @@ Additionally lights, window coverings (blinds) and thermostats are supported:
 | Blind / Window Covering              | Window covering device                        | `windowcovering`        |
 | Thermostat                           | ZHAThermostat                                 | `thermostat`            |
 | Warning Device (Siren)               | Warning device                                | `warningdevice`         |
+| Door Lock                            | A remotely operatable door lock               | `doorlock`              |
 
 Currently only light-groups are supported via the thing-type `lightgroup`.
 
@@ -159,7 +160,8 @@ Other devices support
 | brightness        | Dimmer                   |     R/W     | Brightness of the light               | `dimmablelight`, `colortemperaturelight`        |                                 
 | switch            | Switch                   |     R/W     | State of a ON/OFF device              | `onofflight`                                    |
 | color             | Color                    |     R/W     | Color of an multi-color light         | `colorlight`, `extendedcolorlight`, `lightgroup`|
-| color_temperature | Number                   |     R/W     | Color temperature in kelvin. The value range is determined by each individual light          | `colortemperaturelight`, `extendedcolorlight`, `lightgroup` |
+| color_temperature | Number                   |     R/W     | Color temperature in kelvin. The value range is determined by each individual light     | `colortemperaturelight`, `extendedcolorlight`, `lightgroup` |
+| lock              | Switch                   |     R/W     | Lock (ON) or unlock (OFF) the doorlock| `doorlock`                                      |                 
 | position          | Rollershutter            |     R/W     | Position of the blind                 | `windowcovering`                                |
 | heatsetpoint      | Number:Temperature       |     R/W     | Target Temperature in °C              | `thermostat`                                    |
 | valve             | Number:Dimensionless     |     R       | Valve position in %                   | `thermostat`                                    |
@@ -213,6 +215,7 @@ Bridge deconz:deconz:homeserver [ host="192.168.0.10", apikey="ABCDEFGHIJ" ] {
     alarmsensor         basement-alarm          "Basement Alarm Sensor"     [ id="8", lastSeenPolling=5 ]
     dimmablelight       livingroom-ceiling      "Livingroom Ceiling"        [ id="1" ]
     lightgroup          livingroom              "Livingroom"                [ id="1" ]
+    doorlock            entrance-door           "Door Lock"                 [ id="20" ]
 }
 ```
 
@@ -227,7 +230,8 @@ Contact                 Livingroom_Window       "Window Livingroom [%s]"
 Switch                  Basement_Water_Leakage  "Basement Water Leakage [%s]"                       { channel="deconz:waterleakagesensor:homeserver:basement-water-leakage:waterleakage" }
 Switch                  Basement_Alarm          "Basement Alarm Triggered [%s]"                     { channel="deconz:alarmsensor:homeserver:basement-alarm:alarm" }
 Dimmer                  Livingroom_Ceiling      "Livingroom Ceiling [%d]"           <light>         { channel="deconz:dimmablelight:homeserver:livingroom-ceiling:brightness" }                 
-Color                   Livingroom              "Livingroom Light Control"
+Color                   Livingroom              "Livingroom Light Control"                          { channel="deconz:lightgroup:homeserver:livingroom:color" }
+Switch                  Entrance_Door           "Doorlock"                                          { channel="deconz:doorlock:homeserver:entrance-door:lock" }
 ```
 
 ### Events
index a13ea47100a92fce52be02b4d427eabb76dd318c..4dfc4f8ab0ff789f175addc4ae960176fc03eda3 100644 (file)
@@ -62,6 +62,7 @@ public class BindingConstants {
             "extendedcolorlight");
     public static final ThingTypeUID THING_TYPE_WINDOW_COVERING = new ThingTypeUID(BINDING_ID, "windowcovering");
     public static final ThingTypeUID THING_TYPE_WARNING_DEVICE = new ThingTypeUID(BINDING_ID, "warningdevice");
+    public static final ThingTypeUID THING_TYPE_DOORLOCK = new ThingTypeUID(BINDING_ID, "doorlock");
 
     // groups
     public static final ThingTypeUID THING_TYPE_LIGHTGROUP = new ThingTypeUID(BINDING_ID, "lightgroup");
@@ -110,6 +111,7 @@ public class BindingConstants {
     public static final String CHANNEL_ALERT = "alert";
     public static final String CHANNEL_ALL_ON = "all_on";
     public static final String CHANNEL_ANY_ON = "any_on";
+    public static final String CHANNEL_LOCK = "lock";
 
     // Thing configuration
     public static final String CONFIG_HOST = "host";
index d848feaf08e84a6c85f567e9eb8cdb5566c87fc4..e95fdd0e7331465cf03771c8aa93a605837fa020 100644 (file)
@@ -196,6 +196,9 @@ public class ThingDiscoveryService extends AbstractDiscoveryService implements D
             case WARNING_DEVICE:
                 thingTypeUID = THING_TYPE_WARNING_DEVICE;
                 break;
+            case DOORLOCK:
+                thingTypeUID = THING_TYPE_DOORLOCK;
+                break;
             case CONFIGURATION_TOOL:
                 // ignore configuration tool device
                 return;
index 1e79bcaf4005f71da0b843327eff48c184d93186..269a98ccaa42e49b7de79e72193ef15c097c3a98 100644 (file)
@@ -63,7 +63,7 @@ import com.google.gson.Gson;
 public class LightThingHandler extends DeconzBaseThingHandler<LightMessage> {
     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPE_UIDS = Set.of(THING_TYPE_COLOR_TEMPERATURE_LIGHT,
             THING_TYPE_DIMMABLE_LIGHT, THING_TYPE_COLOR_LIGHT, THING_TYPE_EXTENDED_COLOR_LIGHT, THING_TYPE_ONOFF_LIGHT,
-            THING_TYPE_WINDOW_COVERING, THING_TYPE_WARNING_DEVICE);
+            THING_TYPE_WINDOW_COVERING, THING_TYPE_WARNING_DEVICE, THING_TYPE_DOORLOCK);
 
     private static final long DEFAULT_COMMAND_EXPIRY_TIME = 250; // in ms
     private static final int BRIGHTNESS_DIM_STEP = 26; // ~ 10%
@@ -137,6 +137,7 @@ public class LightThingHandler extends DeconzBaseThingHandler<LightMessage> {
                     return;
                 }
             case CHANNEL_SWITCH:
+            case CHANNEL_LOCK:
                 if (command instanceof OnOffType) {
                     newLightState.on = (command == OnOffType.ON);
                 } else {
@@ -290,6 +291,7 @@ public class LightThingHandler extends DeconzBaseThingHandler<LightMessage> {
                 updateState(channelId, "alert".equals(newState.alert) ? OnOffType.ON : OnOffType.OFF);
                 break;
             case CHANNEL_SWITCH:
+            case CHANNEL_LOCK:
                 if (on != null) {
                     updateState(channelId, OnOffType.from(on));
                 }
index 85aba0fa38f9e807314ef4d1e2d59e9050bd481b..65a24e82331ac59779e3412c13d1de7096f0ea17 100644 (file)
@@ -39,6 +39,7 @@ public enum LightType {
     WINDOW_COVERING_DEVICE("Window covering device"),
     CONFIGURATION_TOOL("Configuration tool"),
     WARNING_DEVICE("Warning device"),
+    DOORLOCK("Door Lock"),
     UNKNOWN("");
 
     private static final Map<String, LightType> MAPPING = Arrays.stream(LightType.values())
index e7a3e2a5e584cbf881866f7400f6b0f002f6ff79..ce7c74b78ff36a98ef67a17314892f38247d70d4 100644 (file)
                <channels>
                        <channel id="alert" typeId="alert"></channel>
                </channels>
+
+               <representation-property>uid</representation-property>
+
+               <config-description-ref uri="thing-type:deconz:sensor"/>
        </thing-type>
 
        <thing-type id="windowcovering">
                <config-description-ref uri="thing-type:deconz:light"/>
        </thing-type>
 
+       <thing-type id="doorlock">
+               <supported-bridge-type-refs>
+                       <bridge-type-ref id="deconz"/>
+               </supported-bridge-type-refs>
+               <label>Doorlock</label>
+               <description>A doorlock that can be locked (ON) or unlocked (OFF).</description>
+               <channels>
+                       <channel typeId="lock" id="switch"/>
+               </channels>
+
+               <representation-property>uid</representation-property>
+
+               <config-description-ref uri="thing-type:deconz:sensor"/>
+       </thing-type>
+
        <channel-type id="position">
                <item-type>Rollershutter</item-type>
                <label>Position</label>
                <label>Alert</label>
        </channel-type>
 
+       <channel-type id="lock">
+               <item-type>Switch</item-type>
+               <label>Lock</label>
+       </channel-type>
 </thing:thing-descriptions>