]> git.basschouten.com Git - openhab-addons.git/commitdiff
[somfytahoma] Add support for noise and CO2 sensor (#15671)
authorOndrej Pecta <opecta@gmail.com>
Sat, 30 Sep 2023 09:22:10 +0000 (11:22 +0200)
committerGitHub <noreply@github.com>
Sat, 30 Sep 2023 09:22:10 +0000 (11:22 +0200)
Signed-off-by: Ondrej Pecta <opecta@gmail.com>
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/SomfyTahomaCarbonDioxideSensorHandler.java [new file with mode: 0644]
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaNoiseSensorHandler.java [new file with mode: 0644]
bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/i18n/somfytahoma.properties
bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml
bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/co2sensor.xml [new file with mode: 0644]
bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/noisesensor.xml [new file with mode: 0644]

index 0132673f2c8069ca8b21db09a17f41dfcd280d15..3efd9b68e0e061bed07a60bdebef60df50178c2b 100644 (file)
@@ -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)                                                                                                                                                                    |
index 30edae823d4f0334b3d80d9124532d1da86a8831..8b2b7e6d864ffa8e1b6b325a3bec2a64b51dd0de 100644 (file)
@@ -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<Integer, String> 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");
         }
     };
index 9ad60a8bbbc3e8ef4a7b4f94e4bb15ba6cb82e1f..e54376952a5dc1f259efb29b0390c09ed8101cf4 100644 (file)
@@ -21,6 +21,7 @@ import org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaAdjustableSla
 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.SomfyTahomaInternalAlarm
 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 @@ public class SomfyTahomaHandlerFactory extends BaseThingHandlerFactory {
             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;
         }
index 54f55a4b762b5df6780b4e5cfa924db002ff71ea..471094f21808310311245bc10de8d08d2c318d43 100644 (file)
@@ -287,6 +287,7 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService
                     // 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 @@ public class SomfyTahomaItemDiscoveryService extends AbstractDiscoveryService
                 } 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 (file)
index 0000000..c96034c
--- /dev/null
@@ -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 (file)
index 0000000..9f6077e
--- /dev/null
@@ -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");
+    }
+}
index 5b6906dfd3d562a3873f4499f9fa9a1a51c25513..7e6d1e53d94463b6d095019ac85ebc5f6fac6f8f 100644 (file)
@@ -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
index 60e3b2c0a8542eac1ce20d11068c1318fae01c3b..da65407387af3dcbc1f51cea9262544132209f99 100644 (file)
                <state readOnly="true" pattern="%.1f %unit%"/>
        </channel-type>
 
+       <channel-type id="co2_concentration">
+               <item-type>Number:DimensionLess</item-type>
+               <label>CO2 concentration</label>
+               <description>A CO2 sensor carbon dioxide concentration in ppm</description>
+               <state readOnly="true" pattern="%d %unit%"/>
+       </channel-type>
+
+       <channel-type id="noise">
+               <item-type>Number:DimensionLess</item-type>
+               <label>Noise</label>
+               <description>A noise sensor noise in decibel</description>
+               <state readOnly="true" pattern="%d %unit%"/>
+       </channel-type>
+
        <channel-type id="alarm_command">
                <item-type>String</item-type>
                <label>Command</label>
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 (file)
index 0000000..fdc93c6
--- /dev/null
@@ -0,0 +1,19 @@
+<?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="co2sensor">
+               <supported-bridge-type-refs>
+                       <bridge-type-ref id="bridge"/>
+               </supported-bridge-type-refs>
+               <label>Somfy CO2 Sensor</label>
+               <channels>
+                       <channel id="co2_concentration" typeId="co2_concentration"></channel>
+               </channels>
+               <representation-property>url</representation-property>
+               <config-description-ref uri="thing-type:somfytahoma:device"/>
+       </thing-type>
+
+</thing:thing-descriptions>
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 (file)
index 0000000..8b8f9aa
--- /dev/null
@@ -0,0 +1,19 @@
+<?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="noisesensor">
+               <supported-bridge-type-refs>
+                       <bridge-type-ref id="bridge"/>
+               </supported-bridge-type-refs>
+               <label>Somfy Noise Sensor</label>
+               <channels>
+                       <channel id="noise" typeId="noise"></channel>
+               </channels>
+               <representation-property>url</representation-property>
+               <config-description-ref uri="thing-type:somfytahoma:device"/>
+       </thing-type>
+
+</thing:thing-descriptions>