From d8173024d0e1aca33e5d42e27eda9dcff3a3ade6 Mon Sep 17 00:00:00 2001 From: posseydon6891 <66778456+posseydon6891@users.noreply.github.com> Date: Mon, 15 Jun 2020 21:04:53 +0200 Subject: [PATCH] [hyperion] Fixes #6377 hyperion NPE (#7898) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [hyperion] Fixes #6377 hyperion NPE Incorporate changes to HyperionNG serverInfo API - alpha6. HyperionEnabled state channel is now determined by special component state "ALL" for newer APIs. See: https://docs.hyperion-project.org/en/json/ServerInfo.html * Update bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/handler/HyperionNgHandler.java Signed-off-by: Ɓukasz Serwicki Co-authored-by: Connor Petty --- .../hyperion/internal/HyperionBindingConstants.java | 1 + .../hyperion/internal/handler/HyperionNgHandler.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/HyperionBindingConstants.java b/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/HyperionBindingConstants.java index 005d9bfbd573f..be0648b041db4 100644 --- a/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/HyperionBindingConstants.java +++ b/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/HyperionBindingConstants.java @@ -55,6 +55,7 @@ public class HyperionBindingConstants { public static final String COMPONENT_GRABBER = "GRABBER"; public static final String COMPONENT_V4L = "V4L"; public static final String COMPONENT_LEDDEVICE = "LEDDEVICE"; + public static final String COMPONENT_ALL = "ALL"; // List of all properties public static final String PROP_HOST = "host"; diff --git a/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/handler/HyperionNgHandler.java b/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/handler/HyperionNgHandler.java index e197ed752da79..540f4a2646333 100644 --- a/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/handler/HyperionNgHandler.java +++ b/bundles/org.openhab.binding.hyperion/src/main/java/org/openhab/binding/hyperion/internal/handler/HyperionNgHandler.java @@ -173,10 +173,13 @@ public void dispose() { protected void handleServerInfoResponse(NgResponse response) { NgInfo info = response.getInfo(); if (info != null) { - // update Hyperion + // update Hyperion, older API compatibility Hyperion hyperion = info.getHyperion(); - updateHyperion(hyperion); - + if (hyperion != null) { + + updateHyperion(hyperion); + } + // populate the effect states List effects = info.getEffects(); populateEffects(effects); @@ -295,6 +298,9 @@ private void updateComponents(List components) { case COMPONENT_LEDDEVICE: updateState(CHANNEL_LEDDEVICE, componentState); break; + case COMPONENT_ALL: + updateState(CHANNEL_HYPERION_ENABLED, componentState); + break; default: logger.debug("Unknown component: {}", componentName); }