From 0a6bedeb60b91ae8252ed04ef7833ca8ec1449ca Mon Sep 17 00:00:00 2001 From: Ondrej Pecta Date: Sat, 30 Sep 2023 11:22:10 +0200 Subject: [PATCH] [somfytahoma] Add support for noise and CO2 sensor (#15671) Signed-off-by: Ondrej Pecta --- .../org.openhab.binding.somfytahoma/README.md | 4 +++ .../internal/SomfyTahomaBindingConstants.java | 19 ++++++++++- .../internal/SomfyTahomaHandlerFactory.java | 6 ++++ .../SomfyTahomaItemDiscoveryService.java | 12 +++++++ ...SomfyTahomaCarbonDioxideSensorHandler.java | 33 +++++++++++++++++++ .../SomfyTahomaNoiseSensorHandler.java | 33 +++++++++++++++++++ .../OH-INF/i18n/somfytahoma.properties | 6 ++++ .../main/resources/OH-INF/thing/channels.xml | 14 ++++++++ .../main/resources/OH-INF/thing/co2sensor.xml | 19 +++++++++++ .../resources/OH-INF/thing/noisesensor.xml | 19 +++++++++++ 10 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaCarbonDioxideSensorHandler.java create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaNoiseSensorHandler.java create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/co2sensor.xml create mode 100644 bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/noisesensor.xml diff --git a/bundles/org.openhab.binding.somfytahoma/README.md b/bundles/org.openhab.binding.somfytahoma/README.md index 0132673f2c806..3efd9b68e0e06 100644 --- a/bundles/org.openhab.binding.somfytahoma/README.md +++ b/bundles/org.openhab.binding.somfytahoma/README.md @@ -32,6 +32,8 @@ Any home automation system based on the OverKiz API is potentially supported. - rain sensors (OPEN/CLOSE contact) - temperature sensors (get temperature) - electricity sensors (get energy consumption) +- carbon dioxide sensors (get CO2 concentration) +- noise sensors (get noise) - door locks (LOCK/UNLOCK, OPEN/CLOSE commands) - heating systems (control temperature, set heating level) - valve heating systems (control temperature, derogation mode and temperature) @@ -126,6 +128,8 @@ Please see the example below. | light sensor | luminance | light luminance value in luxes | | electricity sensor | energy_consumption | energy consumption value in watts | | humidity sensor | humidity | current relative humidity | +| carbon dioxide sensor | co2_concentration | CO2 concentration in ppm | +| noise sensor | noise | noise in decibel | | dock | battery_status | indicates running on battery (yes/no) | | dock | battery_level | remaining battery percentage | | dock | siren_status | used for controlling and getting siren state (on, off, cyclic) | 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 30edae823d4f0..8b2b7e6d864ff 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 @@ -178,6 +178,12 @@ public class SomfyTahomaBindingConstants { // RainSensor public static final ThingTypeUID THING_TYPE_RAINSENSOR = new ThingTypeUID(BINDING_ID, "rainsensor"); + // CarbonDioxideSensor + public static final ThingTypeUID THING_TYPE_CARBON_DIOXIDE_SENSOR = new ThingTypeUID(BINDING_ID, "co2sensor"); + + // NoiseSensor + public static final ThingTypeUID THING_TYPE_NOISE_SENSOR = new ThingTypeUID(BINDING_ID, "noisesensor"); + // List of all Channel ids public static final String RSSI = "rssi"; @@ -238,6 +244,12 @@ public class SomfyTahomaBindingConstants { // Temperature sensor public static final String TEMPERATURE = "temperature"; + // Carbon dioxide sensor + public static final String CO2_CONCENTRATION = "co2_concentration"; + + // Noise sensor + public static final String NOISE = "noise"; + // Alarm public static final String ALARM_COMMAND = "alarm_command"; public static final String ALARM_STATE = "alarm_state"; @@ -494,12 +506,15 @@ public class SomfyTahomaBindingConstants { 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"; + public static final String CLASS_CARBON_DIOXIDE_SENSOR = "CarbonDioxideSensor"; + public static final String CLASS_NOISE_SENSOR = "NoiseSensor"; // unsupported uiClasses public static final String THING_PROTOCOL_GATEWAY = "ProtocolGateway"; public static final String THING_REMOTE_CONTROLLER = "RemoteController"; public static final String THING_NETWORK_COMPONENT = "NetworkComponent"; public static final String THING_GENERIC = "Generic"; + public static final String THING_CONFIGURATION_COMPONENT = "ConfigurationComponent"; // Event states public static final String FAILED_EVENT = "FAILED"; @@ -518,7 +533,8 @@ 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_RAINSENSOR, THING_TYPE_SHUTTER)); + THING_TYPE_HITACHI_DHW, THING_TYPE_HITACHI_ATWMC, THING_TYPE_RAINSENSOR, THING_TYPE_SHUTTER, + THING_TYPE_CARBON_DIOXIDE_SENSOR, THING_TYPE_NOISE_SENSOR)); // somfy gateways public static Map gatewayTypes = new HashMap<>() { @@ -560,6 +576,7 @@ public class SomfyTahomaBindingConstants { put(72, "TAHOMA_RAIL_DIN"); put(77, "ELIOT"); put(88, "WISER"); + put(92, "NETATMO"); put(99, "CONNECTIVITY KIT"); } }; 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 9ad60a8bbbc3e..e54376952a5dc 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 @@ -21,6 +21,7 @@ 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.SomfyTahomaCarbonDioxideSensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaContactSensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaCurtainHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaDimmerLightHandler; @@ -39,6 +40,7 @@ import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaLightSensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxAlarmHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaMyfoxCameraHandler; +import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaNoiseSensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOccupancySensorHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHandler; import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaOnOffHeatingSystemHandler; @@ -202,6 +204,10 @@ protected ThingHandler createHandler(Thing thing) { return new SomfyTahomaHitachiATWMCHandler(thing); } else if (thingTypeUID.equals(THING_TYPE_RAINSENSOR)) { return new SomfyTahomaRainSensorHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_CARBON_DIOXIDE_SENSOR)) { + return new SomfyTahomaCarbonDioxideSensorHandler(thing); + } else if (thingTypeUID.equals(THING_TYPE_NOISE_SENSOR)) { + return new SomfyTahomaNoiseSensorHandler(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 54f55a4b762b5..471094f218083 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 @@ -287,6 +287,7 @@ private void discoverDevice(SomfyTahomaDevice device, SomfyTahomaSetup setup) { // widget: RelativeHumiditySensor deviceDiscovered(device, THING_TYPE_HUMIDITYSENSOR, place); } + break; case CLASS_DOOR_LOCK: // widget: UnlockDoorLockWithUnknownPosition deviceDiscovered(device, THING_TYPE_DOOR_LOCK, place); @@ -364,10 +365,21 @@ private void discoverDevice(SomfyTahomaDevice device, SomfyTahomaSetup setup) { } else { logUnsupportedDevice(device); } + break; + case CLASS_CARBON_DIOXIDE_SENSOR: + // widget: CO2Sensor + deviceDiscovered(device, THING_TYPE_CARBON_DIOXIDE_SENSOR, place); + break; + case CLASS_NOISE_SENSOR: + // widget: NoiseSensor + deviceDiscovered(device, THING_TYPE_NOISE_SENSOR, place); + break; case THING_PROTOCOL_GATEWAY: case THING_REMOTE_CONTROLLER: // widget: AlarmRemoteController case THING_NETWORK_COMPONENT: + case THING_CONFIGURATION_COMPONENT: + // widget: NetatmoHome case THING_GENERIC: // widget: unknown break; diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaCarbonDioxideSensorHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaCarbonDioxideSensorHandler.java new file mode 100644 index 0000000000000..c96034cdb7110 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaCarbonDioxideSensorHandler.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2010-2023 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.CO2_CONCENTRATION; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.thing.Thing; + +/** + * The {@link SomfyTahomaCarbonDioxideSensorHandler} is responsible for handling commands, + * which are sent to one of the channels of the carbon dioxide sensor thing. + * + * @author Ondrej Pecta - Initial contribution + */ +@NonNullByDefault +public class SomfyTahomaCarbonDioxideSensorHandler extends SomfyTahomaBaseThingHandler { + + public SomfyTahomaCarbonDioxideSensorHandler(Thing thing) { + super(thing); + stateNames.put(CO2_CONCENTRATION, "core:CO2ConcentrationState"); + } +} diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaNoiseSensorHandler.java b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaNoiseSensorHandler.java new file mode 100644 index 0000000000000..9f6077e0cd09f --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaNoiseSensorHandler.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2010-2023 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.NOISE; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.thing.Thing; + +/** + * The {@link SomfyTahomaNoiseSensorHandler} is responsible for handling commands, + * which are sent to one of the channels of the noise sensor thing. + * + * @author Ondrej Pecta - Initial contribution + */ +@NonNullByDefault +public class SomfyTahomaNoiseSensorHandler extends SomfyTahomaBaseThingHandler { + + public SomfyTahomaNoiseSensorHandler(Thing thing) { + super(thing); + stateNames.put(NOISE, "core:NoiseState"); + } +} 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 5b6906dfd3d56..7e6d1e53d9446 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 @@ -12,6 +12,7 @@ thing-type.somfytahoma.awning.label = Somfy Awning thing-type.somfytahoma.bioclimaticpergola.label = Somfy Bioclimatic Pergola thing-type.somfytahoma.bridge.label = Bridge thing-type.somfytahoma.bridge.description = Bridge enabling communication with devices through a cloud portal +thing-type.somfytahoma.co2sensor.label = Somfy CO2 Sensor thing-type.somfytahoma.contactsensor.label = Somfy Contact Sensor thing-type.somfytahoma.curtain.label = Somfy Curtain thing-type.somfytahoma.dimmerlight.label = Somfy Dimmer Light @@ -35,6 +36,7 @@ thing-type.somfytahoma.light.label = Somfy Light Switch thing-type.somfytahoma.lightsensor.label = Somfy Light Sensor thing-type.somfytahoma.myfoxalarm.label = Somfy Myfox Alarm thing-type.somfytahoma.myfoxcamera.label = Somfy Myfox Camera +thing-type.somfytahoma.noisesensor.label = Somfy Noise Sensor thing-type.somfytahoma.occupancysensor.label = Somfy Occupancy Sensor thing-type.somfytahoma.onoff.label = Somfy On/Off Switch thing-type.somfytahoma.onoffheatingsystem.label = Somfy Heating System with On/Off @@ -161,6 +163,8 @@ channel-type.somfytahoma.control.label = Control channel-type.somfytahoma.control.description = Device control (UP, DOWN, MY/STOP, closure 0-100%) channel-type.somfytahoma.moving.label = Moving channel-type.somfytahoma.moving.description = Indicates if the device is currently operating a command +channel-type.somfytahoma.co2_concentration.label = CO2 concentration +channel-type.somfytahoma.co2_concentration.description = A CO2 sensor carbon dioxide concentration in ppm channel-type.somfytahoma.control_silent.label = Control (silent) channel-type.somfytahoma.control_silent.description = Device control (UP, DOWN, MY/STOP, closure 0-100%) (only for IO devices) channel-type.somfytahoma.current_heating_mode.label = Current Heating Mode @@ -258,6 +262,8 @@ channel-type.somfytahoma.myfox_alarm_command.description = A channel used for se channel-type.somfytahoma.myfox_alarm_command.state.option.arm = ARM channel-type.somfytahoma.myfox_alarm_command.state.option.disarm = DISARM channel-type.somfytahoma.myfox_alarm_command.state.option.partial = ARM_PARTIAL +channel-type.somfytahoma.noise.label = Noise +channel-type.somfytahoma.noise.description = A noise sensor noise in decibel channel-type.somfytahoma.open.label = Open/Close channel-type.somfytahoma.open.description = A channel for controlling door OPEN/CLOSE state channel-type.somfytahoma.open_closed_valve.label = Valve Open/Closed state diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml index 60e3b2c0a8542..da65407387af3 100644 --- a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml @@ -44,6 +44,20 @@ + + Number:DimensionLess + + A CO2 sensor carbon dioxide concentration in ppm + + + + + Number:DimensionLess + + A noise sensor noise in decibel + + + String diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/co2sensor.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/co2sensor.xml new file mode 100644 index 0000000000000..fdc93c6293090 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/co2sensor.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + url + + + + diff --git a/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/noisesensor.xml b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/noisesensor.xml new file mode 100644 index 0000000000000..8b8f9aad82f78 --- /dev/null +++ b/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/noisesensor.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + url + + + +