Change status channel from hash map values to state description options. (#11739)

Signed-off-by: Stewart Cossey <stewart.cossey@gmail.com>
This commit is contained in:
Stewart Cossey 2021-12-09 21:00:18 +13:00 committed by GitHub
parent 1d65e10bba
commit dc11890f32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 22 deletions

View File

@ -65,7 +65,7 @@ public class HPProductUsageFeatures {
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;
}

View File

@ -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 @@ import org.w3c.dom.NodeList;
public class HPStatus {
public static final String ENDPOINT = "/DevMgmt/ProductStatusDyn.xml";
private static final Map<String, String> STATUS_MESSAGES = initializeStatus();
private final String printerStatus;
private final boolean trayEmptyOrOpen;
@ -44,7 +39,7 @@ public class HPStatus {
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 class HPStatus {
printerStatus = localPrinterStatus;
}
private static Map<String, String> initializeStatus() {
Map<String, String> 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;
}

View File

@ -35,7 +35,19 @@
<item-type>String</item-type>
<label>Status</label>
<description>Printer Status</description>
<state readOnly="true"/>
<state readOnly="true">
<options>
<option value="ready">Idle</option>
<option value="processing">Printing</option>
<option value="scanProcessing">Scanning</option>
<option value="inPowerSave">Power Save</option>
<option value="initializing">Initializing</option>
<option value="closeDoorOrCover">Door/Cover</option>
<option value="inkSystemInitializing">Loading Ink</option>
<option value="shuttingDown">Shutting Down</option>
<option value="replaceCartridgeOut">Cartridge Depleted</option>
</options>
</state>
</channel-type>
<channel-type id="readonlyswitch" advanced="true">