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] Avoid requesting favorite stations when not needed #12777

Merged
merged 5 commits into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public StationDataResponse getStationsData(@Nullable String deviceId, boolean ge
return response;
}

public NAMain getStationData(String deviceId) throws NetatmoException {
ListBodyResponse<NAMain> answer = getStationsData(deviceId, true).getBody();
public NAMain getStationData(String deviceId, boolean getFavorites) throws NetatmoException {
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
ListBodyResponse<NAMain> answer = getStationsData(deviceId, getFavorites).getBody();
if (answer != null) {
NAMain station = answer.getElement(deviceId);
if (station != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
public class DeviceCapability extends Capability {
private static final int DATA_AGE_LIMIT_S = 3600;

protected boolean readonly = true;;
lolodomo marked this conversation as resolved.
Show resolved Hide resolved

public DeviceCapability(CommonInterface handler) {
super(handler);
}

@Override
protected void updateNAMain(NAMain newData) {
readonly = newData.isReadOnly();
if (firstLaunch) {
newData.getPlace().ifPresent(place -> {
place.getCity().map(city -> properties.put(PROPERTY_CITY, city));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public WeatherCapability(CommonInterface handler) {
@Override
protected List<NAObject> updateReadings(WeatherApi api) {
try {
return List.of(api.getStationData(handler.getId()));
return List.of(api.getStationData(handler.getId(), readonly));
lolodomo marked this conversation as resolved.
Show resolved Hide resolved
} catch (NetatmoException e) {
logger.warn("Error retrieving weather data '{}' : {}", handler.getId(), e.getMessage());
}
Expand Down