From 030012b106280e48bcc29beb236c57050f3ad6e2 Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Tue, 10 Dec 2024 19:52:44 +0000 Subject: [PATCH] [hue] show friends of hue battery sensors as online (#17878) Signed-off-by: Andrew Fiddian-Green Signed-off-by: Ciprian Pascu --- .../internal/api/dto/clip2/enums/ZigbeeStatus.java | 11 +++++++++++ .../hue/internal/handler/Clip2ThingHandler.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/enums/ZigbeeStatus.java b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/enums/ZigbeeStatus.java index db65ccbd715..13c85fda909 100644 --- a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/enums/ZigbeeStatus.java +++ b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/api/dto/clip2/enums/ZigbeeStatus.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.hue.internal.api.dto.clip2.enums; +import java.util.Set; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -27,6 +29,8 @@ public enum ZigbeeStatus { CONNECTIVITY_ISSUE, UNIDIRECTIONAL_INCOMING; + private static final Set CONNECTIVITY_ISSUES = Set.of(DISCONNECTED, CONNECTIVITY_ISSUE); + public static ZigbeeStatus of(@Nullable String value) { if (value != null) { try { @@ -43,4 +47,11 @@ public enum ZigbeeStatus { String s = this.name().replace("_", " "); return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); } + + /** + * Return true if the status is a connectivity issue + */ + public boolean isConnectivityIssue() { + return CONNECTIVITY_ISSUES.contains(this); + } } diff --git a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java index 15e2c8b484e..947454f4fdd 100644 --- a/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java +++ b/bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2ThingHandler.java @@ -1045,7 +1045,7 @@ public class Clip2ThingHandler extends BaseThingHandler { if (Objects.nonNull(zigbeeStatus)) { logger.debug("{} -> updateConnectivityState() thingStatus:{}, zigbeeStatus:{}", resourceId, thing.getStatus(), zigbeeStatus); - hasConnectivityIssue = zigbeeStatus != ZigbeeStatus.CONNECTED; + hasConnectivityIssue = zigbeeStatus.isConnectivityIssue(); if (hasConnectivityIssue) { if (thing.getStatusInfo().getStatusDetail() != ThingStatusDetail.COMMUNICATION_ERROR) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE,