From 953e082fcb4fd0bc45a5466045e350c783c3d4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Fri, 27 Sep 2024 13:04:42 +0200 Subject: [PATCH] [meteofrance] New binding (#15462) * Adapting binding to new data feed Signed-off-by: clinique --- CODEOWNERS | 2 +- bom/openhab-addons/pom.xml | 4 +- .../org.openhab.binding.meteoalerte/README.md | 113 --- .../internal/MeteoAlerteBindingConstants.java | 44 - .../internal/MeteoAlerteHandlerFactory.java | 69 -- .../internal/handler/MeteoAlerteHandler.java | 176 ---- .../internal/json/ApiResponse.java | 49 -- .../meteoalerte/internal/json/Parameters.java | 56 -- .../meteoalerte/internal/json/Record.java | 54 -- .../internal/json/ResponseFieldDTO.java | 161 ---- .../OH-INF/i18n/meteoalerte.properties | 189 ----- .../resources/OH-INF/thing/thing-types.xml | 329 -------- .../resources/OH-INF/update/instructions.xml | 40 - .../NOTICE | 0 .../org.openhab.binding.meteofrance/README.md | 132 +++ .../doc/images}/avalanches.svg | 0 .../doc/images}/canicule.svg | 0 .../doc/images}/grand-froid.svg | 0 .../doc/images}/inondation.svg | 0 .../doc/images/intensity.svg | 67 ++ .../doc/images}/meteo_france.svg | 0 .../doc/images}/neige.svg | 0 .../doc/images}/orage.svg | 0 .../doc/images}/pluie-inondation.svg | 0 .../doc/images}/vague-submersion.svg | 0 .../doc/images}/vent.svg | 0 .../pom.xml | 4 +- .../src/main/feature/feature.xml | 6 +- .../internal/MeteoFranceBindingConstants.java | 56 ++ .../internal/MeteoFranceException.java | 34 + .../internal/MeteoFranceHandlerFactory.java | 73 ++ .../internal/MeteoFranceIconProvider.java} | 54 +- .../internal/config/BridgeConfiguration.java | 25 + .../config/DepartmentConfiguration.java} | 9 +- .../config/ForecastConfiguration.java | 27 + .../internal/db/DepartmentDbService.java | 77 ++ .../MeteoFranceDeserializer.java | 68 ++ .../deserialization/PeriodsDeserializer.java | 48 ++ .../StrictEnumTypeAdapterFactory.java | 67 ++ .../deserialization/TimelapsDeserializer.java | 49 ++ .../MeteoFranceDiscoveryService.java | 111 +++ .../meteofrance/internal/dto/BlocType.java | 27 + .../meteofrance/internal/dto/Domain.java | 269 ++++++ .../meteofrance/internal/dto/Hazard.java | 58 ++ .../meteofrance/internal/dto/MeteoFrance.java | 174 ++++ .../internal/dto/RainForecast.java | 61 ++ .../meteofrance/internal/dto/Risk.java | 41 + .../meteofrance/internal/dto/Term.java} | 20 +- .../handler/MeteoFranceBridgeHandler.java | 175 ++++ .../handler/MeteoFranceChildHandler.java | 42 + .../internal/handler/RainForecastHandler.java | 167 ++++ .../internal/handler/VigilanceHandler.java | 189 +++++ .../src/main/resources/OH-INF/addon/addon.xml | 6 +- .../OH-INF/i18n/meteofrance.properties | 211 +++++ .../src/main/resources/OH-INF/thing/api.xml | 22 + .../main/resources/OH-INF/thing/channels.xml | 178 ++++ .../resources/OH-INF/thing/rain-forecast.xml | 30 + .../main/resources/OH-INF/thing/vigilance.xml | 175 ++++ .../src/main/resources/db/departments.json | 770 ++++++++++++++++++ .../src/main/resources/icon/avalanches.svg | 18 + .../src/main/resources/icon/canicule.svg | 21 + .../src/main/resources/icon/grand-froid.svg | 20 + .../src/main/resources/icon/inondation.svg | 11 + .../src/main/resources/icon/intensity-0.svg | 81 ++ .../src/main/resources/icon/intensity-1.svg | 66 ++ .../src/main/resources/icon/intensity-2.svg | 66 ++ .../src/main/resources/icon/intensity-3.svg | 66 ++ .../src/main/resources/icon/intensity.svg | 67 ++ .../src/main/resources/icon/meteo_france.svg | 13 + .../src/main/resources/icon/neige.svg | 7 + .../src/main/resources/icon/orage.svg | 13 + .../main/resources/icon/pluie-inondation.svg | 16 + .../main/resources/icon/vague-submersion.svg | 7 + .../src/main/resources/icon/vent.svg | 29 + bundles/pom.xml | 2 +- 75 files changed, 3984 insertions(+), 1327 deletions(-) delete mode 100644 bundles/org.openhab.binding.meteoalerte/README.md delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/MeteoAlerteBindingConstants.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/MeteoAlerteHandlerFactory.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/handler/MeteoAlerteHandler.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/json/ApiResponse.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/json/Parameters.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/json/Record.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/json/ResponseFieldDTO.java delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/resources/OH-INF/i18n/meteoalerte.properties delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/resources/OH-INF/thing/thing-types.xml delete mode 100644 bundles/org.openhab.binding.meteoalerte/src/main/resources/OH-INF/update/instructions.xml rename bundles/{org.openhab.binding.meteoalerte => org.openhab.binding.meteofrance}/NOTICE (100%) create mode 100644 bundles/org.openhab.binding.meteofrance/README.md rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/avalanches.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/canicule.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/grand-froid.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/inondation.svg (100%) create mode 100755 bundles/org.openhab.binding.meteofrance/doc/images/intensity.svg rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/meteo_france.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/neige.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/orage.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/pluie-inondation.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/vague-submersion.svg (100%) rename bundles/{org.openhab.binding.meteoalerte/src/main/resources/icon => org.openhab.binding.meteofrance/doc/images}/vent.svg (100%) rename bundles/{org.openhab.binding.meteoalerte => org.openhab.binding.meteofrance}/pom.xml (80%) rename bundles/{org.openhab.binding.meteoalerte => org.openhab.binding.meteofrance}/src/main/feature/feature.xml (61%) create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceBindingConstants.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceException.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceHandlerFactory.java rename bundles/{org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/MeteoAlertIconProvider.java => org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceIconProvider.java} (59%) create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/config/BridgeConfiguration.java rename bundles/{org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/MeteoAlerteConfiguration.java => org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/config/DepartmentConfiguration.java} (69%) create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/config/ForecastConfiguration.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/db/DepartmentDbService.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/deserialization/MeteoFranceDeserializer.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/deserialization/PeriodsDeserializer.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/deserialization/StrictEnumTypeAdapterFactory.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/deserialization/TimelapsDeserializer.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/discovery/MeteoFranceDiscoveryService.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/BlocType.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/Domain.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/Hazard.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/MeteoFrance.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/RainForecast.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/Risk.java rename bundles/{org.openhab.binding.meteoalerte/src/main/java/org/openhab/binding/meteoalerte/internal/json/Refine.java => org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/dto/Term.java} (64%) create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/MeteoFranceBridgeHandler.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/MeteoFranceChildHandler.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/RainForecastHandler.java create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/VigilanceHandler.java rename bundles/{org.openhab.binding.meteoalerte => org.openhab.binding.meteofrance}/src/main/resources/OH-INF/addon/addon.xml (62%) create mode 100755 bundles/org.openhab.binding.meteofrance/src/main/resources/OH-INF/i18n/meteofrance.properties create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/OH-INF/thing/api.xml create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/OH-INF/thing/channels.xml create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/OH-INF/thing/rain-forecast.xml create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/OH-INF/thing/vigilance.xml create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/db/departments.json create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/avalanches.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/canicule.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/grand-froid.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/inondation.svg create mode 100755 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/intensity-0.svg create mode 100755 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/intensity-1.svg create mode 100755 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/intensity-2.svg create mode 100755 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/intensity-3.svg create mode 100755 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/intensity.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/meteo_france.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/neige.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/orage.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/pluie-inondation.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/vague-submersion.svg create mode 100644 bundles/org.openhab.binding.meteofrance/src/main/resources/icon/vent.svg diff --git a/CODEOWNERS b/CODEOWNERS index bf2fa5f9ce2..ae0d5d1a3c9 100755 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -211,8 +211,8 @@ /bundles/org.openhab.binding.mecmeter/ @kaikreuzer /bundles/org.openhab.binding.melcloud/ @lucacalcaterra @paulianttila @thewiep /bundles/org.openhab.binding.mercedesme/ @weymann -/bundles/org.openhab.binding.meteoalerte/ @clinique /bundles/org.openhab.binding.meteoblue/ @9037568 +/bundles/org.openhab.binding.meteofrance/ @clinique /bundles/org.openhab.binding.meteostick/ @cdjackson /bundles/org.openhab.binding.mffan/ @mark-brooks-180 /bundles/org.openhab.binding.miele/ @kgoderis @jlaur diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index 98ff5690022..3a3e20519ae 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -1053,12 +1053,12 @@ org.openhab.addons.bundles - org.openhab.binding.meteoalerte + org.openhab.binding.meteoblue ${project.version} org.openhab.addons.bundles - org.openhab.binding.meteoblue + org.openhab.binding.meteofrance ${project.version} diff --git a/bundles/org.openhab.binding.meteoalerte/README.md b/bundles/org.openhab.binding.meteoalerte/README.md deleted file mode 100644 index 7af859b6fd8..00000000000 --- a/bundles/org.openhab.binding.meteoalerte/README.md +++ /dev/null @@ -1,113 +0,0 @@ -# Meteo Alerte Binding - -The Meteo Alerte binding gives alert level regarding major weather related risk factors. -This binding provides its own icon set and provides appropriate static and dynamic SVG icons (see items examples below). - -## Supported Things - -There is exactly one supported thing type, which represents the weather alerts for a given department. -It has the `department` id. -Of course, you can add multiple things, e.g. for getting alerts for different locations. - -## Binding Configuration - -The binding has no configuration options, all configuration is done at Thing level. - -## Thing Configuration - -The thing has a few configuration parameters: - -| Parameter | Description | -|---------------|----------------------------------------------------------------------------------------| -| `department` | Name of the department. | -| refresh | Refresh interval in minutes. Optional, the default value is 1440 minutes (once a day). | - -## Channels - -The Météo Alerte information that are retrieved is available as these channels: - -| Channel ID | Item Type | Description | -|-----------------------|-----------|-----------------------------------------------| -| observation-time | DateTime | Date and time of report validity start | -| end-time | DateTime | Date and time of report validity end | -| comment | String | General comments on alerts for the department | -| vent | Number | Wind alert level (*) | -| pluie-inondation | Number | Rain alert level (*) | -| orage | Number | Storm alert level (*) | -| inondation | Number | Flood alert level (*) | -| neige | Number | Snow alert level (*) | -| canicule | Number | Heat alert level (*) | -| grand-froid | Number | Cold alert level (*) | -| avalanches | Number | Avalanche alert level (*) | -| vague-submersion | Number | Wave submersion alert level (*) | -| pluie-inondation-icon | Image | Pictogram of the Rain alert level | -| vent-icon | Image | Pictogram of the Wind alert level | -| orage-icon | Image | Pictogram of Storm alert level | -| inondation-icon | Image | Pictogram of Flood alert level | -| neige-icon | Image | Pictogram of Snow alert level | -| canicule-icon | Image | Pictogram of Heat alert level | -| grand-froid-icon | Image | Pictogram of Cold alert level | -| avalanches-icon | Image | Pictogram of Avalanche alert level | -| vague-submersion-icon | Image | Pictogram of Wave Submersion alert level | - -(*) Each alert level is described by a color : - -| Code | Color | Description | -|------|--------|-------------------------------------------| -| 0 | Green | No particular vigilance | -| 1 | Yellow | Be attentive to the weather situation | -| 2 | Orange | Be "very vigilant" in the concerned areas | -| 3 | Red | Absolute vigilance required | - -## Provided icon set - -This binding has its own IconProvider and makes available the following list of icons - -| Icon Name | Dynamic | Illustration | -|---------------------------------|---------|--------------| -| oh:meteoalerte:vent | Yes | ![](src/main/resources/icon/vent.svg) | -| oh:meteoalerte:pluie-inondation | Yes | ![](src/main/resources/icon/pluie-inondation.svg) | -| oh:meteoalerte:orage | Yes | ![](src/main/resources/icon/orage.svg) | -| oh:meteoalerte:inondation | Yes | ![](src/main/resources/icon/inondation.svg) | -| oh:meteoalerte:neige | Yes | ![](src/main/resources/icon/neige.svg) | -| oh:meteoalerte:canicule | Yes | ![](src/main/resources/icon/canicule.svg) | -| oh:meteoalerte:grand-froid | Yes | ![](src/main/resources/icon/grand-froid.svg) | -| oh:meteoalerte:avalanches | Yes | ![](src/main/resources/icon/avalanches.svg) | -| oh:meteoalerte:vague-submersion | Yes | ![](src/main/resources/icon/vague-submersion.svg) | -| oh:meteoalerte:meteo_france | No | ![](src/main/resources/icon/meteo_france.svg) | - - -## Full Example - -meteoalert.things: - -```java -Thing meteoalerte:department:yvelines @ "MyCity" [department="YVELINES", refresh=12] -``` - -meteoalert.items: - -```java -Group gMeteoAlert "Alertes Météo" -String MA_Dept78 "Département 78 [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:comment"} -Number MA_etat_canicule "Canicule [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:canicule"} -Number MA_etat_grand_froid "Grand Froid [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:grand-froid"} -Number MA_etat_pluie_inondation "Pluie-Inondation [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:pluie-inondation"} -Number MA_etat_neige "Neige [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:neige"} -Number MA_etat_vent "Vent [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:vent"} -Number MA_etat_inondation "Inondation [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:inondation"} -Number MA_etat_orage "Orage [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:orage"} -Number MA_etat_avalanche "Avalanches [%s]" (gMeteoAlert) {channel="meteoalerte:department:yvelines:avalanches"} - -Image MA_icon_canicule "Canicule" (gMeteoAlert) {channel="meteoalerte:department:yvelines:canicule-icon"} -Image MA_icon_grand_froid "Grand Froid" (gMeteoAlert) {channel="meteoalerte:department:yvelines:grand-froid-icon"} -Image MA_icon_pluie_inondation "Pluie-Inondation" (gMeteoAlert) {channel="meteoalerte:department:yvelines:pluie-inondation-icon"} -Image MA_icon_neige "Neige" (gMeteoAlert) {channel="meteoalerte:department:yvelines:neige-icon"} -Image MA_icon_vent "Vent" (gMeteoAlert) {channel="meteoalerte:department:yvelines:vent-icon"} -Image MA_icon_inondation "Inondation" (gMeteoAlert) {channel="meteoalerte:department:yvelines:inondation-icon"} -Image MA_icon_orage "Orage" (gMeteoAlert) {channel="meteoalerte:department:yvelines:orage-icon"} -Image MA_icon_avalanche "Avalanche" (gMeteoAlert) {channel="meteoalerte:department:yvelines:avalanches-icon"} - -DateTime MA_ObservationTS "Timestamp [%1$tH:%1$tM]"