From 2763b54a188851429f9cf0cf2a6bb811dde73bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Thu, 21 Mar 2024 13:43:33 +0100 Subject: [PATCH] [netatmo] Bring back auto refresh for Weather Station and HomeCoach (#16546) * Corrects and completes PR #16492 --------- Signed-off-by: gael@lhopital.org --- bundles/org.openhab.binding.netatmo/README.md | 4 +- .../netatmo/internal/api/data/ModuleType.java | 4 +- .../main/resources/OH-INF/config/config.xml | 13 ----- .../internal/api/data/ModuleTypeTest.java | 50 +++++++++++++++++++ 4 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/api/data/ModuleTypeTest.java diff --git a/bundles/org.openhab.binding.netatmo/README.md b/bundles/org.openhab.binding.netatmo/README.md index 7312a1de1366f..3bece02857a39 100644 --- a/bundles/org.openhab.binding.netatmo/README.md +++ b/bundles/org.openhab.binding.netatmo/README.md @@ -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 | diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java index 7c431bf9b34a0..8b9dc7ccbde20 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java @@ -102,7 +102,7 @@ ChannelGroup.BATTERY, ChannelGroup.TIMESTAMP, new ChannelGroup(SirenChannelHelpe 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 @@ ChannelGroup.BATTERY, ChannelGroup.TIMESTAMP, new ChannelGroup(SirenChannelHelpe 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, diff --git a/bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/config/config.xml index f1d88a60ecda9..40fb6f0f868ec 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/config/config.xml @@ -147,17 +147,4 @@ - - - - @text/config.equipmentId.description - - - - - @text/config.refreshInterval.description - 180 - - - 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 index 0000000000000..3698a461527f7 --- /dev/null +++ b/bundles/org.openhab.binding.netatmo/src/test/java/org/openhab/binding/netatmo/internal/api/data/ModuleTypeTest.java @@ -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); + } + }); + } +}