Closed jlaur closed 2 years ago
If the thing is disposed/initialized, this is very probably because the thing configuration was updated and this should happen only if the the "refreshToken" parameter is not set in your thing. https://github.com/openhab/openhab-addons/blob/main/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ApiBridgeHandler.java#L130 So yes, this will happen the first when you authenticate.
If the thing is disposed/initialized, this is very probably because the thing configuration was updated and this should happen only if the the "refreshToken" parameter is not set in your thing.
The problem is that in fact it is stored in my thing - in a file (shortened):
Bridge netatmo:account:home "Netatmo API" [ clientId="xxx", clientSecret="yyy", refreshToken="zzz" ] {
Bridge weather-station main [ id="xx:xx:xx:xx:xx:xx" ] {
indoor indoor [ id="yy:yy:yy:yy:yy:yy" ]
}
}
I have setup it like you.
If I restart the binding, I cannot reproduce your problem with "Shutting down Netatmo API bridge handler".
But for my outside module and rain gauge module, I can see your pattern OFFLINE/BRIDGE_OFFLINE => ONLINE => UNKNOWN => ONLINE.
Ok, bridgeStatusChanged
is correctly overriden.
So that means there is a call to setThingStatus
with ONLINE for these things run too early (before or during bridgeStatusChanged
is called), maybe here:
https://github.com/openhab/openhab-addons/blob/main/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/CommonInterface.java#L148
Verified, this is the only place that sets the thing status to ONLINE.
So the only explanation I can find is that setNewData
is called for this thing before the call to bridgeStatusChanged
=> commonInitialize
. Probably by the bridge handler of this thing (weather station in our case).
Probably something done in this method (class RestCapability<T extends RestManager>
):
@Override
protected void updateNADevice(Device newData) {
super.updateNADevice(newData);
NAObjectMap<Module> modules = newData.getModules();
handler.getActiveChildren().forEach(child -> {
Module childData = modules.get(child.getId());
if (childData != null) {
child.setNewData(childData);
}
});
}
Maybe if getActiveChildren()
filters things that are in status OFFLINE/BRIDGE_OFFLINE, it could resolve the problem.
When starting the binding, there are too many status transitions and possibly also requests. It seems that an additional cycle is triggered.
Here is a distilled log for one weather station with one additional indoor module:
The two requests with ~11 seconds between them are identical and receives the same response payloads. The line "Shutting down Netatmo API bridge handler." is from
ApiBridgeHandler.dispose()
, which could indicate a configuration update: https://github.com/openhab/openhab-core/blob/cabb3f73150d13f44d647f46af8362e396684b92/bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/binding/BaseThingHandler.java#L105-L107Expected Behavior
One initial request and one set of status transitions towards ONLINE.
Current Behavior
Too many status updates:
Possible Solution
Steps to Reproduce
ssh openhab@localhost -p8101 'bundle:restart org.openhab.binding.netatmo'
refreshToken is stored in a .things file.
Your Environment
openHAB 3.3.0M5, binding compiled from main branch May 25th 2022.