mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Enhance getActiveChildren() (#16573)
Signed-off-by: clinique <gael@lhopital.org> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
b861c02386
commit
8e4a8314e2
@ -14,7 +14,6 @@ package org.openhab.binding.netatmo.internal.handler;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -107,7 +106,7 @@ public interface CommonInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void expireData() {
|
default void expireData() {
|
||||||
getCapabilities().values().forEach(cap -> cap.expireData());
|
getCapabilities().values().forEach(Capability::expireData);
|
||||||
}
|
}
|
||||||
|
|
||||||
default String getId() {
|
default String getId() {
|
||||||
@ -152,13 +151,12 @@ public interface CommonInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default List<CommonInterface> getActiveChildren() {
|
default List<CommonInterface> getActiveChildren() {
|
||||||
Thing thing = getThing();
|
return getThing() instanceof Bridge bridge
|
||||||
if (thing instanceof Bridge bridge) {
|
? bridge.getThings().stream().filter(Thing::isEnabled)
|
||||||
return bridge.getThings().stream().filter(Thing::isEnabled)
|
.filter(th -> th.getStatusInfo().getStatusDetail() != ThingStatusDetail.BRIDGE_OFFLINE)
|
||||||
.filter(th -> th.getStatusInfo().getStatusDetail() != ThingStatusDetail.BRIDGE_OFFLINE)
|
.map(Thing::getHandler).filter(CommonInterface.class::isInstance)
|
||||||
.map(Thing::getHandler).filter(Objects::nonNull).map(CommonInterface.class::cast).toList();
|
.map(CommonInterface.class::cast).toList()
|
||||||
}
|
: List.of();
|
||||||
return List.of();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default Stream<CommonInterface> getActiveChildren(FeatureArea area) {
|
default Stream<CommonInterface> getActiveChildren(FeatureArea area) {
|
||||||
@ -207,7 +205,7 @@ public interface CommonInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void proceedWithUpdate() {
|
default void proceedWithUpdate() {
|
||||||
updateReadings().forEach(dataSet -> setNewData(dataSet));
|
updateReadings().forEach(this::setNewData);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<NAObject> updateReadings() {
|
default List<NAObject> updateReadings() {
|
||||||
@ -244,7 +242,6 @@ public interface CommonInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void removeChannels(List<Channel> channels) {
|
default void removeChannels(List<Channel> channels) {
|
||||||
ThingBuilder builder = editThing().withoutChannels(channels);
|
updateThing(editThing().withoutChannels(channels).build());
|
||||||
updateThing(builder.build());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user