From bff08b1180ba4d708324b48f15fee4fe20287876 Mon Sep 17 00:00:00 2001 From: Ondrej Pecta Date: Thu, 24 Feb 2022 20:26:43 +0100 Subject: [PATCH] [somfytahoma] added support for the Rain sensor thing Signed-off-by: Ondrej Pecta --- .../org.openhab.binding.somfytahoma/README.md | 3 +- .../internal/SomfyTahomaBindingConstants.java | 10 ++++-- .../internal/SomfyTahomaHandlerFactory.java | 3 ++ .../SomfyTahomaItemDiscoveryService.java | 7 ++++ .../handler/SomfyTahomaRainSensorHandler.java | 33 +++++++++++++++++++ .../OH-INF/i18n/somfytahoma.properties | 1 + .../resources/OH-INF/thing/rainsensor.xml | 19 +++++++++++ 7 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaRainSensorHandler.java create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/rainsensor.xml diff --git a/bundles/org.openhab.binding.somfytahoma/README.md b/bundles/org.openhab.binding.somfytahoma/README.md index 3683ad6e198eb..6294264ee1790 100644 --- a/bundles/org.openhab.binding.somfytahoma/README.md +++ b/bundles/org.openhab.binding.somfytahoma/README.md @@ -28,6 +28,7 @@ Any home automation system based on the OverKiz API is potentially supported. - occupancy sensors (OPEN/CLOSE contact) - smoke sensors (OPEN/CLOSE contact, alarm check) - contact sensors (OPEN/CLOSE contact) +- rain sensors (OPEN/CLOSE contact) - temperature sensors (get temperature) - electricity sensors (get energy consumption) - door locks (LOCK/UNLOCK, OPEN/CLOSE commands) @@ -80,7 +81,7 @@ Please see the example below. | 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 | -| smoke sensor, occupancy sensor, contact sensor & water sensor | contact | normal value is CLOSE, changes to OPEN when detection triggered | +| smoke sensor, occupancy sensor, contact sensor, water sensor & rain sensor | contact | normal value is CLOSE, changes to OPEN when detection triggered | | smoke sensor, occupancy sensor, contact sensor & water sensor | sensor_defect | indicates the health of the sensor (dead, lowBatter, maintenanceRequired, noDefect) | | smoke sensor | radio_battery | maintenance radio part battery state (low, normal) | | smoke sensor | sensor_battery | maintenance sensor part battery state (absence, low, normal) | diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java index e2310122b8f90..564c766c26bb4 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaBindingConstants.java @@ -172,6 +172,9 @@ public class SomfyTahomaBindingConstants { // HitachiAirToWaterMainComponent public static final ThingTypeUID THING_TYPE_HITACHI_ATWMC = new ThingTypeUID(BINDING_ID, "hitachiatwmc"); + // RainSensor + public static final ThingTypeUID THING_TYPE_RAINSENSOR = new ThingTypeUID(BINDING_ID, "rainsensor"); + // List of all Channel ids public static final String RSSI = "rssi"; @@ -211,8 +214,10 @@ public class SomfyTahomaBindingConstants { public static final String LOCK = "lock"; public static final String OPEN = "open"; - // Smoke sensor, Occupancy sensor, Contact sensor, Water sensor + // Smoke sensor, Occupancy sensor, Contact sensor, Water sensor, Rain sensor public static final String CONTACT = "contact"; + + // Smoke sensor, Occupancy sensor, Contact sensor, Water sensor public static final String SENSOR_DEFECT = "sensor_defect"; // Humidity sensor @@ -469,6 +474,7 @@ public class SomfyTahomaBindingConstants { public static final String CLASS_CAMERA = "Camera"; public static final String CLASS_WATER_HEATING_SYSTEM = "WaterHeatingSystem"; public static final String CLASS_HITACHI_HEATING_SYSTEM = "HitachiHeatingSystem"; + public static final String CLASS_RAIN_SENSOR = "RainSensor"; // unsupported uiClasses public static final String THING_PROTOCOL_GATEWAY = "ProtocolGateway"; @@ -493,7 +499,7 @@ public class SomfyTahomaBindingConstants { 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_BIOCLIMATIC_PERGOLA, THING_TYPE_WATERHEATINGSYSTEM, THING_TYPE_HITACHI_ATWHZ, - THING_TYPE_HITACHI_DHW, THING_TYPE_HITACHI_ATWMC)); + THING_TYPE_HITACHI_DHW, THING_TYPE_HITACHI_ATWMC, THING_TYPE_RAINSENSOR)); // somfy gateways public static Map gatewayTypes = new HashMap() { diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java index c55286e2a10ed..1d3a1648a0e26 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/SomfyTahomaHandlerFactory.java @@ -44,6 +44,7 @@ import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHeatingSystemHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPergolaHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaPodHandler; +import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRainSensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaRollerShutterHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSilentRollerShutterHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaSirenHandler; @@ -196,6 +197,8 @@ protected ThingHandler createHandler(Thing thing) { return new SomfyTahomaHitachiDHWHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_HITACHI_ATWMC)) { return new SomfyTahomaHitachiATWMCHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_RAINSENSOR)) { + return new SomfyTahomaRainSensorHandler(thing); } else { return null; } diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java index 62de14ebc10f0..58e1a185d2429 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/discovery/SomfyTahomaItemDiscoveryService.java @@ -340,6 +340,13 @@ private void discoverDevice(SomfyTahomaDevice device, SomfyTahomaSetup setup) { logUnsupportedDevice(device); } break; + case CLASS_RAIN_SENSOR: + if ("RainSensor".equals(device.getWidget())) { + // widget: RainSensor + deviceDiscovered(device, THING_TYPE_RAINSENSOR, place); + } else { + logUnsupportedDevice(device); + } case THING_PROTOCOL_GATEWAY: case THING_REMOTE_CONTROLLER: // widget: AlarmRemoteController diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaRainSensorHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaRainSensorHandler.java new file mode 100644 index 0000000000000..3e41c750c9fe8 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaRainSensorHandler.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2010-2022 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.Thing; + +/** + * The {@link SomfyTahomaRainSensorHandler} is responsible for handling commands, + * which are sent to one of the channels of the rain sensor thing. + * + * @author Ondrej Pecta - Initial contribution + */ +@NonNullByDefault +public class SomfyTahomaRainSensorHandler extends SomfyTahomaBaseThingHandler { + + public SomfyTahomaRainSensorHandler(Thing thing) { + super(thing); + stateNames.put(CONTACT, "core:RainState"); + } +} diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties index ad40cd3b7b0b8..a1bfd983ed4c4 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties @@ -40,6 +40,7 @@ thing-type.somfytahoma.onoff.label = Somfy On/Off Switch thing-type.somfytahoma.onoffheatingsystem.label = Somfy Heating System with On/Off thing-type.somfytahoma.pergola.label = Somfy Pergola thing-type.somfytahoma.pod.label = Somfy Pod +thing-type.somfytahoma.rainsensor.label = Somfy Rain Sensor thing-type.somfytahoma.rollershutter.label = Somfy Roller Shutter thing-type.somfytahoma.rollershutter_silent.label = Somfy Silent Roller Shutter thing-type.somfytahoma.rollershutter_uno.label = Somfy Roller Shutter Uno diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/rainsensor.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/rainsensor.xml new file mode 100644 index 0000000000000..a2d942099d45e --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/rainsensor.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + url + + + +