From 2cfcf784ea9824a1443ea42c950b2cc960cfdd92 Mon Sep 17 00:00:00 2001 From: Stewart Cossey Date: Thu, 9 Dec 2021 20:28:37 +1300 Subject: [PATCH] Change status channel from hash map values to state description options. Signed-off-by: Stewart Cossey --- .../internal/api/HPProductUsageFeatures.java | 2 +- .../hpprinter/internal/api/HPStatus.java | 21 +------------------ .../resources/OH-INF/thing/channel-types.xml | 14 ++++++++++++- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPProductUsageFeatures.java b/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPProductUsageFeatures.java index 41207f4598706..24ba4e77cd439 100644 --- a/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPProductUsageFeatures.java +++ b/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPProductUsageFeatures.java @@ -65,7 +65,7 @@ public HPProductUsageFeatures(final Document document) { final String inkName = currInk.getElementsByTagName("dd:MarkerColor").item(0).getTextContent(); final String consumeType = currInk.getElementsByTagName("dd:ConsumableTypeEnum").item(0).getTextContent(); - if (consumeType.equalsIgnoreCase("printhead")) { + if ("printhead".equalsIgnoreCase(consumeType)) { continue; } diff --git a/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPStatus.java b/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPStatus.java index 19773d6eba057..c9b9c8686b33a 100644 --- a/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPStatus.java +++ b/bundles/org.openhab.binding.hpprinter/src/main/java/org/openhab/binding/hpprinter/internal/api/HPStatus.java @@ -12,9 +12,6 @@ */ package org.openhab.binding.hpprinter.internal.api; -import java.util.HashMap; -import java.util.Map; - import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.w3c.dom.Document; @@ -30,8 +27,6 @@ public class HPStatus { public static final String ENDPOINT = "/DevMgmt/ProductStatusDyn.xml"; - private static final Map STATUS_MESSAGES = initializeStatus(); - private final String printerStatus; private final boolean trayEmptyOrOpen; @@ -44,7 +39,7 @@ public HPStatus(Document document) { Element element = (Element) nodes.item(i); String statusCategory = element.getElementsByTagName("pscat:StatusCategory").item(0).getTextContent(); if (!"genuineHP".equals(statusCategory) && !"trayEmpty".equals(statusCategory)) { - localPrinterStatus = STATUS_MESSAGES.getOrDefault(statusCategory, statusCategory); + localPrinterStatus = statusCategory; } if ("trayEmpty".equals(statusCategory)) { localTrayEmptyOrOpen = true; @@ -54,20 +49,6 @@ public HPStatus(Document document) { printerStatus = localPrinterStatus; } - private static Map initializeStatus() { - Map statusMap = new HashMap<>(); - - statusMap.put("processing", "Printing..."); - statusMap.put("scanProcessing", "Scanning..."); - statusMap.put("inPowerSave", "Power Save"); - statusMap.put("ready", "Idle"); - statusMap.put("initializing", "Initializing..."); - statusMap.put("closeDoorOrCover", "Door/Cover Open"); - statusMap.put("inkSystemInitializing", "Loading Ink..."); - statusMap.put("shuttingDown", "Shutting Down..."); - return statusMap; - } - public boolean getTrayEmptyOrOpen() { return trayEmptyOrOpen; } diff --git a/bundles/org.openhab.binding.hpprinter/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.hpprinter/src/main/resources/OH-INF/thing/channel-types.xml index 72054a69be92e..a628b51010b2e 100644 --- a/bundles/org.openhab.binding.hpprinter/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.hpprinter/src/main/resources/OH-INF/thing/channel-types.xml @@ -35,7 +35,19 @@ String Printer Status - + + + + + + + + + + + + +