]> git.basschouten.com Git - openhab-addons.git/commitdiff
[netatmo] Bring back auto refresh for Weather Station and HomeCoach (#16546)
authorGaël L'hopital <gael@lhopital.org>
Thu, 21 Mar 2024 12:43:33 +0000 (13:43 +0100)
committerGitHub <noreply@github.com>
Thu, 21 Mar 2024 12:43:33 +0000 (13:43 +0100)
* Corrects and completes PR #16492

---------

Signed-off-by: gael@lhopital.org <gael@lhopital.org>
bundles/org.openhab.binding.netatmo/README.md
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java
bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/config/config.xml
bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/api/data/ModuleTypeTest.java [new file with mode: 0644]

index 7312a1de1366f41e329659c6b34a7b7b47e7fb95..3bece02857a390b99c2f41eea4543ea794fc9946 100644 (file)
@@ -83,12 +83,12 @@ Once authentication process has been done, current refreshToken is stored in `/O
 | presence        | Thing  | NOC            | The Netatmo Smart Outdoor Camera (Presence) camera with or without siren.                             | id, ipAddress                                                             |
 | siren           | Thing  | NIS            | The Netatmo Smart Indoor Siren.                                                                       | id                                                                        |
 | doorbell        | Thing  | NDB            | The Netatmo Smart Video Doorbell device.                                                              | id, ipAddress                                                             |
-| weather-station | Bridge | NAMain         | Main indoor module reporting temperature, humidity, pressure, air quality and sound level.            | id, refreshInterval                                                       |
+| weather-station | Bridge | NAMain         | Main indoor module reporting temperature, humidity, pressure, air quality and sound level.            | id                                                                        |
 | outdoor         | Thing  | NAModule1      | Outdoor module reporting temperature and humidity.                                                    | id                                                                        |
 | wind            | Thing  | NAModule2      | Wind sensor reporting wind angle and strength.                                                        | id                                                                        |
 | rain            | Thing  | NAModule3      | Rain Gauge measuring precipitation.                                                                   | id                                                                        |
 | indoor          | Thing  | NAModule4      | Additional indoor module reporting temperature, humidity and CO2 level.                               | id                                                                        |
-| home-coach      | Thing  | NHC            | Healthy home coach reporting health-index, temperature, humidity, pressure, air quality, sound level. | id, refreshInterval                                                       |
+| home-coach      | Thing  | NHC            | Healthy home coach reporting health-index, temperature, humidity, pressure, air quality, sound level. | id                                                                        |
 | plug            | Thing  | NAPlug         | The relay connected to the boiler controlling a Thermostat and zero or more valves.                   | id                                                                        |
 | thermostat      | Thing  | NATherm1       | The Thermostat device placed in a given room.                                                         | id                                                                        |
 | room            | Thing  | NARoom         | A room in your house.                                                                                 | id                                                                        |
index 2ac81a0e8ab7a3e9e46247bf4d8fab5962f455ee..a1b201fb86f2527c0bd0b9109d0d698641559212 100644 (file)
@@ -102,7 +102,7 @@ public enum ModuleType {
                     GROUP_DOORBELL_LIVE),
             new ChannelGroup(EventCameraChannelHelper.class, GROUP_DOORBELL_LAST_EVENT, GROUP_DOORBELL_SUB_EVENT)),
 
-    WEATHER_STATION(FeatureArea.WEATHER, "NAMain", 1, "configurable", ACCOUNT,
+    WEATHER_STATION(FeatureArea.WEATHER, "NAMain", 1, "device", ACCOUNT,
             Set.of(DeviceCapability.class, WeatherCapability.class, MeasureCapability.class,
                     ChannelHelperCapability.class),
             ChannelGroup.SIGNAL, ChannelGroup.HUMIDITY, ChannelGroup.TSTAMP_EXT, ChannelGroup.MEASURE,
@@ -127,7 +127,7 @@ public enum ModuleType {
             ChannelGroup.TSTAMP_EXT, ChannelGroup.MEASURE, ChannelGroup.BATTERY, ChannelGroup.HUMIDITY,
             ChannelGroup.TEMP_INSIDE_EXT, ChannelGroup.AIR_QUALITY),
 
-    HOME_COACH(FeatureArea.AIR_CARE, "NHC", 1, "configurable", ACCOUNT,
+    HOME_COACH(FeatureArea.AIR_CARE, "NHC", 1, "device", ACCOUNT,
             Set.of(DeviceCapability.class, AirCareCapability.class, MeasureCapability.class,
                     ChannelHelperCapability.class),
             ChannelGroup.LOCATION, ChannelGroup.SIGNAL, ChannelGroup.NOISE, ChannelGroup.HUMIDITY,
index f1d88a60ecda948c026cf636173a2c2894278261..40fb6f0f868ec6e4df8538c019c947d76085bd6f 100644 (file)
                </parameter>
        </config-description>
 
-       <config-description uri="netatmo:configurable">
-               <parameter name="id" type="text" pattern="([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})" required="true">
-                       <label>@text/config.equipmentId.label</label>
-                       <description>@text/config.equipmentId.description</description>
-               </parameter>
-
-               <parameter name="refreshInterval" type="integer" min="20" unit="s">
-                       <label>@text/config.refreshInterval.label</label>
-                       <description>@text/config.refreshInterval.description</description>
-                       <default>180</default>
-               </parameter>
-       </config-description>
-
 </config-description:config-descriptions>
diff --git a/bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/api/data/ModuleTypeTest.java b/bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/api/data/ModuleTypeTest.java
new file mode 100644 (file)
index 0000000..3698a46
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2010-2024 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.netatmo.internal.api.data;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.BINDING_ID;
+
+import java.net.URI;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.junit.jupiter.api.Test;
+
+/**
+ * @author Gaël L'hopital - Initial contribution
+ */
+@NonNullByDefault
+public class ModuleTypeTest {
+    public URI getConfigDescription(ModuleType mt) {
+        if (mt == ModuleType.WELCOME || mt == ModuleType.PRESENCE || mt == ModuleType.DOORBELL) {
+            // This did not exist prior to PR #16492
+            return URI.create(BINDING_ID + ":camera");
+        }
+        // This was previous method for calculating configuration URI
+        return URI.create(BINDING_ID + ":"
+                + (mt == ModuleType.ACCOUNT ? "api_bridge"
+                        : mt == ModuleType.HOME ? "home"
+                                : (mt.isLogical() ? "virtual"
+                                        : ModuleType.UNKNOWN == mt.getBridge() ? "configurable" : "device")));
+    }
+
+    @Test
+    public void checkConfigDescription() {
+        ModuleType.AS_SET.stream().forEach(mt -> {
+            if (mt != ModuleType.WELCOME) {
+                URI confDesc = mt.configDescription;
+                assertEquals(getConfigDescription(mt), confDesc);
+            }
+        });
+    }
+}