diff --git a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java index 13cf7735b..c6fd16e6b 100644 --- a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java +++ b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/handler/EcowattHandler.java @@ -116,6 +116,15 @@ public class EcowattHandler extends BaseThingHandler { } } + @Override + public void handleRemoval() { + EcowattRestApi localApi = api; + if (localApi != null) { + localApi.deleteServiceAndAccessToken(); + } + super.handleRemoval(); + } + /** * Schedule the next update of channels. * diff --git a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java index 7da333721..c7f8d01fe 100644 --- a/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java +++ b/bundles/org.openhab.binding.ecowatt/src/main/java/org/openhab/binding/ecowatt/internal/restapi/EcowattRestApi.java @@ -140,4 +140,8 @@ public class EcowattRestApi { public void dispose() { oAuthFactory.ungetOAuthService(authServiceHandle); } + + public void deleteServiceAndAccessToken() { + oAuthFactory.deleteServiceAndAccessToken(authServiceHandle); + } }