diff --git a/bundles/org.openhab.binding.linky/README.md b/bundles/org.openhab.binding.linky/README.md index 1d146c0599c33..181685537a291 100644 --- a/bundles/org.openhab.binding.linky/README.md +++ b/bundles/org.openhab.binding.linky/README.md @@ -11,13 +11,13 @@ The binding will not provide these informations unless this step is ok. This new binding version is able to use multiple bridge to access the consumption data. You can use : -- The EnedisWebBridge : this one will use the old Enedis API, base on the enedis web site to gather the data. -- The MyElectricalDataBridge : this one will use the new Rest Enedis API. We will use the MyElectricalData proxy site to access the data. -- The EnedisBridge : this one will also use the new Rest Enedis API, and will directly gather data from Enedis Site. +- The enedis-web bridge : this one will use the old Enedis API, base on the enedis web site to gather the data. +- The myelectricaldata bridge : this one will use the new Rest Enedis API. We will use the MyElectricalData proxy site to access the data. +- The enedis bridge : this one will also use the new Rest Enedis API, and will directly gather data from Enedis Site. There is advantage and disadvantage for each method. -- EnedisWebBridge is the old way to go. +- enedis-web bridge is the old way to go. ## Supported Things diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyAuthServlet.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyAuthServlet.java index 4b13006bc33ad..4cf46870129f3 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyAuthServlet.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyAuthServlet.java @@ -69,6 +69,7 @@ public class LinkyAuthServlet extends HttpServlet { private static final String KEY_CB_DISPLAY_INSTRUCTION = "cb.displayInstruction"; private static final String KEY_ERROR = "error"; private static final String KEY_PAGE_REFRESH = "pageRefresh"; + private static final String TEMPLATE_PATH = "templates/"; private final Logger logger = LoggerFactory.getLogger(LinkyAuthServlet.class); private final String index; @@ -79,8 +80,6 @@ public class LinkyAuthServlet extends HttpServlet { private final String myelectricaldataStep2; private final String myelectricaldataStep3; - private static final String TEMPLATE_PATH = "templates/"; - private ApiBridgeHandler apiBridgeHandler; public LinkyAuthServlet(ApiBridgeHandler apiBridgeHandler) throws LinkyException { @@ -239,7 +238,7 @@ private void handleLinkyRedirect(Map replaceMap, String servletB try { replaceMap.put(KEY_AUTHORIZED_USER, String.format(HTML_USER_AUTHORIZED, reqCode + " / " + apiBridgeHandler.authorize(servletBaseURL, reqState, reqCode))); - } catch (RuntimeException e) { + } catch (LinkyException e) { logger.debug("Exception during authorizaton: ", e); replaceMap.put(KEY_ERROR, String.format(HTML_ERROR, e.getMessage())); } diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyHandlerFactory.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyHandlerFactory.java index d5ec63f2be954..6a517ec0497bd 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyHandlerFactory.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/LinkyHandlerFactory.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.linky.internal; +import static org.openhab.binding.linky.internal.LinkyBindingConstants.*; + import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZonedDateTime; @@ -100,24 +102,24 @@ public LinkyHandlerFactory(final @Reference LocaleProvider localeProvider, @Override public boolean supportsThingType(ThingTypeUID thingTypeUID) { - return LinkyBindingConstants.SUPPORTED_DEVICE_THING_TYPES_UIDS.contains(thingTypeUID); + return SUPPORTED_DEVICE_THING_TYPES_UIDS.contains(thingTypeUID); } @Override protected @Nullable ThingHandler createHandler(Thing thing) { - if (LinkyBindingConstants.THING_TYPE_API_ENEDIS_BRIDGE.equals(thing.getThingTypeUID())) { + if (THING_TYPE_API_ENEDIS_BRIDGE.equals(thing.getThingTypeUID())) { EnedisBridgeHandler handler = new EnedisBridgeHandler((Bridge) thing, this.httpClientFactory, this.oAuthFactory, this.httpService, thingRegistry, componentContext, gson); return handler; - } else if (LinkyBindingConstants.THING_TYPE_API_WEB_ENEDIS_BRIDGE.equals(thing.getThingTypeUID())) { + } else if (THING_TYPE_API_WEB_ENEDIS_BRIDGE.equals(thing.getThingTypeUID())) { EnedisWebBridgeHandler handler = new EnedisWebBridgeHandler((Bridge) thing, this.httpClientFactory, this.oAuthFactory, this.httpService, thingRegistry, componentContext, gson); return handler; - } else if (LinkyBindingConstants.THING_TYPE_API_MYELECTRICALDATA_BRIDGE.equals(thing.getThingTypeUID())) { + } else if (THING_TYPE_API_MYELECTRICALDATA_BRIDGE.equals(thing.getThingTypeUID())) { MyElectricalDataBridgeHandler handler = new MyElectricalDataBridgeHandler((Bridge) thing, this.httpClientFactory, this.oAuthFactory, this.httpService, thingRegistry, componentContext, gson); return handler; - } else if (LinkyBindingConstants.THING_TYPE_LINKY.equals(thing.getThingTypeUID())) { + } else if (THING_TYPE_LINKY.equals(thing.getThingTypeUID())) { LinkyHandler handler = new LinkyHandler(thing, localeProvider); return handler; } diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/TempoResponse.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/TempoResponse.java index 3994c836ed6ff..c18e7f5f71e09 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/TempoResponse.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/TempoResponse.java @@ -22,6 +22,5 @@ */ public class TempoResponse extends LinkedHashMap { - @java.io.Serial private static final long serialVersionUID = 362498820763181264L; } diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/WebPrmInfo.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/WebPrmInfo.java index aa0ce6684e952..a93700122b838 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/WebPrmInfo.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/WebPrmInfo.java @@ -20,11 +20,11 @@ public class WebPrmInfo { public class Adresse { - public Object adresseLigneUn; + public String adresseLigneUn; public String adresseLigneDeux; - public Object adresseLigneTrois; + public String adresseLigneTrois; public String adresseLigneQuatre; - public Object adresseLigneCinq; + public String adresseLigneCinq; public String adresseLigneSix; public String adresseLigneSept; } diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/ApiBridgeHandler.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/ApiBridgeHandler.java index fc6182b4c8db7..a000baabf5bdf 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/ApiBridgeHandler.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/ApiBridgeHandler.java @@ -138,7 +138,6 @@ public String authorize(String redirectUri, String reqState, String reqCode) thr logger.debug("Acces token: {}", accessToken); return accessToken; } catch (RuntimeException | OAuthException | IOException e) { - // updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage()); throw new LinkyException("Error during oAuth authorize :" + e.getMessage(), e); } catch (final OAuthResponseException e) { throw new LinkyException("\"Error during oAuth authorize :" + e.getMessage(), e); diff --git a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/EnedisBridgeHandler.java b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/EnedisBridgeHandler.java index ec395b4ae8d18..71ad3637eb971 100644 --- a/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/EnedisBridgeHandler.java +++ b/bundles/org.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/handler/EnedisBridgeHandler.java @@ -60,11 +60,6 @@ public EnedisBridgeHandler(Bridge bridge, final @Reference HttpClientFactory htt super(bridge, httpClientFactory, oAuthFactory, httpService, thingRegistry, componentContext, gson); } - @Override - public void initialize() { - super.initialize(); - } - @Override public String getClientId() { return config.clientId; @@ -77,7 +72,7 @@ public String getClientSecret() { @Override public void dispose() { - logger.debug("Shutting down Netatmo API bridge handler."); + logger.debug("Shutting down Enedis bridge handler."); super.dispose(); } diff --git a/bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml index fa428e55ccf6e..3e4f216ba6899 100644 --- a/bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/thing-types.xml @@ -49,10 +49,8 @@ Authentication ID delivered after the captcha (see documentation). - - @@ -66,7 +64,6 @@ - @@ -80,7 +77,6 @@ https://espace-client-particuliers.enedis.fr/web/espace-particuliers/compteur-linky. - @@ -91,9 +87,6 @@ - - - @@ -105,22 +98,19 @@ http://youopenhab/connectlinky) - - - - + - + @@ -135,13 +125,11 @@ - Maximum power usage value - Maximum power usage value for Yesterday @@ -172,7 +160,7 @@ - + @@ -194,7 +182,7 @@ - + @@ -216,7 +204,7 @@ - + @@ -241,20 +229,19 @@ - + - + - + - @@ -322,7 +309,7 @@ Number - + This status describes the tempo color of a day. @@ -348,7 +335,6 @@ - Number:Energy @@ -370,6 +356,4 @@ time - -