Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hpprinter] Change status channel from hash map values to state description options #11739

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,8 +27,6 @@
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;

Expand All @@ -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;
Expand All @@ -54,20 +49,6 @@ public HPStatus(Document document) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down