From fdebb330591df17c6666a7d7e4f675f9a56fc94e Mon Sep 17 00:00:00 2001 From: J-N-K Date: Sun, 8 Nov 2020 00:55:33 +0100 Subject: [PATCH] [deconz] add doorlock support (#8965) Signed-off-by: Jan N. Klug --- bundles/org.openhab.binding.deconz/README.md | 10 +++++--- .../deconz/internal/BindingConstants.java | 2 ++ .../discovery/ThingDiscoveryService.java | 3 +++ .../internal/handler/LightThingHandler.java | 4 +++- .../deconz/internal/types/LightType.java | 1 + .../OH-INF/thing/light-thing-types.xml | 23 +++++++++++++++++++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.deconz/README.md b/bundles/org.openhab.binding.deconz/README.md index d10d17bf8..01dbdfed0 100644 --- a/bundles/org.openhab.binding.deconz/README.md +++ b/bundles/org.openhab.binding.deconz/README.md @@ -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]" { 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 diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java index a13ea4710..4dfc4f8ab 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/BindingConstants.java @@ -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"; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java index d848feaf0..e95fdd0e7 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/discovery/ThingDiscoveryService.java @@ -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; diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java index 1e79bcaf4..269a98cca 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/handler/LightThingHandler.java @@ -63,7 +63,7 @@ import com.google.gson.Gson; public class LightThingHandler extends DeconzBaseThingHandler { public static final Set 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 { 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 { 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)); } diff --git a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java index 85aba0fa3..65a24e823 100644 --- a/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java +++ b/bundles/org.openhab.binding.deconz/src/main/java/org/openhab/binding/deconz/internal/types/LightType.java @@ -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 MAPPING = Arrays.stream(LightType.values()) diff --git a/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml b/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml index e7a3e2a5e..ce7c74b78 100644 --- a/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml +++ b/bundles/org.openhab.binding.deconz/src/main/resources/OH-INF/thing/light-thing-types.xml @@ -13,6 +13,10 @@ + + uid + + @@ -107,6 +111,21 @@ + + + + + + A doorlock that can be locked (ON) or unlocked (OFF). + + + + + uid + + + + Rollershutter @@ -140,4 +159,8 @@ + + Switch + +