[netatmo] Update only the channel for which the REFRESH is sent (#9188)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2020-12-01 01:40:56 +01:00 committed by GitHub
parent 6afbe23ea6
commit 1abe9da2d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 15 deletions

View File

@ -122,9 +122,7 @@ public abstract class AbstractNetatmoThingHandler extends BaseThingHandler {
protected abstract void initializeThing();
protected State getNAThingProperty(String channelId) {
Optional<State> result;
result = getBatteryHelper().flatMap(helper -> helper.getNAThingProperty(channelId));
Optional<State> result = getBatteryHelper().flatMap(helper -> helper.getNAThingProperty(channelId));
if (result.isPresent()) {
return result.get();
}
@ -146,15 +144,13 @@ public abstract class AbstractNetatmoThingHandler extends BaseThingHandler {
}
private void updateDataChannels() {
getThing().getChannels().stream().filter(channel -> !channel.getKind().equals(ChannelKind.TRIGGER))
.forEach(channel -> {
getThing().getChannels().stream()
.filter(channel -> !ChannelKind.TRIGGER.equals(channel.getKind()) && isLinked(channel.getUID()))
.map(channel -> channel.getUID()).forEach(this::updateChannel);
}
String channelId = channel.getUID().getId();
if (isLinked(channelId)) {
State state = getNAThingProperty(channelId);
updateState(channel.getUID(), state);
}
});
private void updateChannel(ChannelUID channelUID) {
updateState(channelUID, getNAThingProperty(channelUID.getId()));
}
/**
@ -162,8 +158,8 @@ public abstract class AbstractNetatmoThingHandler extends BaseThingHandler {
* (when a channel is triggered, a rule can get all other information from the updated non-trigger channels)
*/
private void triggerEventChannels() {
getThing().getChannels().stream().filter(channel -> channel.getKind().equals(ChannelKind.TRIGGER))
.forEach(channel -> triggerChannelIfRequired(channel.getUID().getId()));
getThing().getChannels().stream().filter(channel -> ChannelKind.TRIGGER.equals(channel.getKind()))
.map(channel -> channel.getUID().getId()).forEach(this::triggerChannelIfRequired);
}
/**
@ -177,8 +173,8 @@ public abstract class AbstractNetatmoThingHandler extends BaseThingHandler {
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (command == RefreshType.REFRESH) {
logger.debug("Refreshing {}", channelUID);
updateChannels();
logger.debug("Refreshing '{}'", channelUID);
updateChannel(channelUID);
}
}