Skip to content

Commit 91d6b62

Browse files
authored
[hue] show friends of hue battery sensors as online (openhab#17878)
Signed-off-by: Andrew Fiddian-Green <[email protected]>
1 parent 93e0723 commit 91d6b62

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/enums/ZigbeeStatus.java

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
package org.openhab.binding.hue.internal.api.dto.clip2.enums;
1414

15+
import java.util.Set;
16+
1517
import org.eclipse.jdt.annotation.NonNullByDefault;
1618
import org.eclipse.jdt.annotation.Nullable;
1719

@@ -27,6 +29,8 @@ public enum ZigbeeStatus {
2729
CONNECTIVITY_ISSUE,
2830
UNIDIRECTIONAL_INCOMING;
2931

32+
private static final Set<ZigbeeStatus> CONNECTIVITY_ISSUES = Set.of(DISCONNECTED, CONNECTIVITY_ISSUE);
33+
3034
public static ZigbeeStatus of(@Nullable String value) {
3135
if (value != null) {
3236
try {
@@ -43,4 +47,11 @@ public String toString() {
4347
String s = this.name().replace("_", " ");
4448
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
4549
}
50+
51+
/**
52+
* Return true if the status is a connectivity issue
53+
*/
54+
public boolean isConnectivityIssue() {
55+
return CONNECTIVITY_ISSUES.contains(this);
56+
}
4657
}

bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ private void updateConnectivityState(Resource resource) {
10451045
if (Objects.nonNull(zigbeeStatus)) {
10461046
logger.debug("{} -> updateConnectivityState() thingStatus:{}, zigbeeStatus:{}", resourceId,
10471047
thing.getStatus(), zigbeeStatus);
1048-
hasConnectivityIssue = zigbeeStatus != ZigbeeStatus.CONNECTED;
1048+
hasConnectivityIssue = zigbeeStatus.isConnectivityIssue();
10491049
if (hasConnectivityIssue) {
10501050
if (thing.getStatusInfo().getStatusDetail() != ThingStatusDetail.COMMUNICATION_ERROR) {
10511051
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE,

0 commit comments

Comments
 (0)