Skip to content

Commit 655116f

Browse files
authored
improved fix introduced by openhab#18168 (openhab#18284)
Signed-off-by: Alexander Friese <[email protected]>
1 parent e14381d commit 655116f

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/handler/EaseeChargerHandler.java

+26-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.openhab.core.thing.Thing;
4040
import org.openhab.core.thing.ThingStatus;
4141
import org.openhab.core.thing.ThingStatusDetail;
42+
import org.openhab.core.thing.ThingStatusInfo;
4243
import org.openhab.core.thing.binding.BaseThingHandler;
4344
import org.openhab.core.types.Command;
4445
import org.openhab.core.types.State;
@@ -70,10 +71,22 @@ public EaseeChargerHandler(Thing thing) {
7071
this.sessionDataPollingJobReference = new AtomicReference<>(null);
7172
}
7273

73-
void reInit() {
74-
if (isInitialized()) {
75-
dispose();
76-
initialize();
74+
@Override
75+
public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) {
76+
super.bridgeStatusChanged(bridgeStatusInfo);
77+
if (bridgeStatusInfo.getStatus() == ThingStatus.ONLINE) {
78+
logger.debug("bridgeStatusChanged: ONLINE");
79+
if (isInitialized()) {
80+
startPolling();
81+
}
82+
} else {
83+
logger.debug("bridgeStatusChanged: NOT ONLINE");
84+
if (isInitialized()) {
85+
if (bridgeStatusInfo.getStatus() == ThingStatus.UNKNOWN) {
86+
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, STATUS_WAITING_FOR_BRIDGE);
87+
}
88+
stopPolling();
89+
}
7790
}
7891
}
7992

@@ -131,6 +144,14 @@ private void startPolling() {
131144
POLLING_INITIAL_DELAY, getBridgeConfiguration().getSessionDataPollingInterval(), TimeUnit.SECONDS));
132145
}
133146

147+
/**
148+
* Stops the polling.
149+
*/
150+
private void stopPolling() {
151+
cancelJobReference(dataPollingJobReference);
152+
cancelJobReference(sessionDataPollingJobReference);
153+
}
154+
134155
/**
135156
* Poll the Easee Cloud API one time.
136157
*/
@@ -198,8 +219,7 @@ protected final void updateOnlineStatus(CommunicationStatus status, JsonObject j
198219
@Override
199220
public void dispose() {
200221
logger.debug("Handler disposed.");
201-
cancelJobReference(dataPollingJobReference);
202-
cancelJobReference(sessionDataPollingJobReference);
222+
stopPolling();
203223
}
204224

205225
/**

bundles/org.openhab.binding.easee/src/main/java/org/openhab/binding/easee/internal/handler/EaseeSiteHandler.java

-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.openhab.binding.easee.internal.connector.CommunicationStatus;
3636
import org.openhab.binding.easee.internal.connector.WebInterface;
3737
import org.openhab.binding.easee.internal.discovery.EaseeSiteDiscoveryService;
38-
import org.openhab.core.config.core.Configuration;
3938
import org.openhab.core.config.discovery.DiscoveryService;
4039
import org.openhab.core.thing.Bridge;
4140
import org.openhab.core.thing.ThingStatus;
@@ -175,15 +174,6 @@ public void dispose() {
175174
webInterface.dispose();
176175
}
177176

178-
@Override
179-
protected void updateConfiguration(Configuration configuration) {
180-
super.updateConfiguration(configuration);
181-
getChildChargerHandlers().forEach((name, handler) -> {
182-
logger.debug("notify {}: config update", name);
183-
handler.reInit();
184-
});
185-
}
186-
187177
@Override
188178
public EaseeConfiguration getBridgeConfiguration() {
189179
return this.getConfigAs(EaseeConfiguration.class);

0 commit comments

Comments
 (0)