Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[netatmo] REFRESH command from BaseThingHandler leads to loads of getstationsdata requests during startup #5440

Closed
aluedt opened this issue Apr 10, 2019 · 5 comments · Fixed by #8101
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@aluedt
Copy link

aluedt commented Apr 10, 2019

In typical applications during the startup/initialization phase lots of channel links are set up. For Netatmo devices this leads to lots of getstationsdata requests, one for every single channel linked.

The problem is the following:
The standard behavior of BaseThingHandler.channelLinked(ChannelUID) is to invoke a REFRESH command for the newly linked channel. This is overridden by AbstractNetatmoThingHandler.channelLinked(ChannelUID), but there a super call is executed first, so REFRESH is also invoked then. When a REFRESH command is handled by
AbstractNetatmoThingHandler.handleCommand(ChannelUID, Command), AbstractNetatmoThingHandler.updateChannels(String) is invoked. For Netatmo devices this is overridden and in NetatmoDeviceHandler.updateChannels(String), where NetatmoDeviceHandler.updateReadings(String) is called, so a full getstationsdata is executed then. As there's lots of channels which are typically linked during startup of applications, this happens very often and may even lead to IPs temporarily blocked by Netatmo and similar.

Expected Behavior

getstationsdata requests should only occur for regular updates (refreshInterval) and when the REFRESH command is explicitly posted, but not when a channel is linked.

Proposed solution:

Current Behavior

getstationsdata is executed repeatedly whenever a channel is linked.

Possible Solution

Simply remove the super call in AbstractNetatmoThingHandler.channelLinked(ChannelUID)

Steps to Reproduce (for Bugs)

Simply set up some channel links and, e.g., set a break point in NetatmoBridgeHandler.getStationsDataBody(String)

Context

Not relevant.

Your Environment

Embedded Busybox linux (or Windows 7 during development), Java 8, latest master

@wborn wborn changed the title [Netatmo] REFRESH command from BaseThingHandler leads to loads of getstationsdata requests during startup [netatmo] REFRESH command from BaseThingHandler leads to loads of getstationsdata requests during startup Apr 14, 2019
@wborn wborn added the bug An unexpected problem or unintended behavior of an add-on label Apr 14, 2019
@lolodomo
Copy link
Contributor

lolodomo commented Jul 7, 2019

@clinique : any thought ?

@lolodomo
Copy link
Contributor

There is already a cache implemented through the refresh strategy.

@lolodomo
Copy link
Contributor

Your initial analysis is correct, we can just add that there is a check whether the data is expired before requesting new data. The problem is that all REFRESH commands are run more or less at the same time and data is considered as expired each time.
My current feeling is that we should add a lock around the update of data to avoid concurrent requests.
I will try to fix that issue.

@lolodomo
Copy link
Contributor

Explanation found. For sthe weather station, the binding tries to identify automatically the refresh delay to consider. For that, it needs two different timestamps. Until that happened, the binding considers data as outdated.
The reason is clear but I have no immediate idea how to fix that.

lolodomo added a commit to lolodomo/openhab-addons that referenced this issue Jul 10, 2020
Fix openhab#5440

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
cpmeister pushed a commit that referenced this issue Jul 12, 2020
Fix #5440

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
@Novanic
Copy link
Contributor

Novanic commented Jul 14, 2020

Nice, thank you for the fix. :-)

CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this issue Jul 26, 2020
Fix openhab#5440

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: CSchlipp <christian@schlipp.de>
MPH80 pushed a commit to MPH80/openhab-addons that referenced this issue Aug 3, 2020
Fix openhab#5440

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: MPH80 <michael@hazelden.me>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this issue Sep 1, 2020
Fix openhab#5440

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this issue Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants