Skip to content

Commit

Permalink
Change the matching of consumable to its details by marker color inst…
Browse files Browse the repository at this point in the history
…ead of station
  • Loading branch information
elad-bar committed May 18, 2024
1 parent 53c0350 commit a8623af
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.0.0b10

- Add support for mapping of multicolor consumable (CyanMagentaYellow)
- Change the matching of consumable to its details by marker color instead of station

## 2.0.0b9

- Add fallback mechanism for consumables, if station is not available, will use color mapping
Expand Down
20 changes: 7 additions & 13 deletions custom_components/hpprinter/managers/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,15 @@ def _extract_data(self, devices: list[dict]):

if identifier is not None:
identifier_key = identifier.get("key")
identifier_mapping = identifier.get("mapping")

device_id = item_data.get(identifier_key)
key_data = item_data.get(identifier_key)

if device_id is None:
fallback = identifier.get("fallback")
if fallback is not None:
fallback_key = fallback.get("key")
fallback_mapping = fallback.get("mapping")

fallback_key_data = item_data.get(fallback_key)
device_id = (
fallback_key_data
if fallback_mapping is None
else fallback_mapping.get(fallback_key_data)
)
device_id = (
item_data.get(identifier_key)
if identifier_mapping is None
else identifier_mapping.get(key_data)
)

if flat:
new_items_data = {
Expand Down
2 changes: 1 addition & 1 deletion custom_components/hpprinter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/elad-bar/ha-hpprinter/issues",
"requirements": ["xmltodict~=0.13.0", "flatten_json", "defusedxml"],
"version": "2.0.0b9"
"version": "2.0.0b10"
}
21 changes: 8 additions & 13 deletions custom_components/hpprinter/parameters/data_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
"path": "ConsumableConfigDyn.ConsumableInfo",
"device_type": "Consumable",
"identifier": {
"key": "consumable_station",
"fallback": {
"key": "consumable_label_code"
}
"key": "consumable_label_code"
},
"properties": {
"consumable_label_code": {
Expand Down Expand Up @@ -119,15 +116,13 @@
"path": "ProductUsageDyn.ConsumableSubunit.Consumable",
"device_type": "Consumable",
"identifier": {
"key": "consumable_station",
"fallback": {
"key": "marker_color",
"mapping": {
"Cyan": "C",
"Yellow": "Y",
"Magenta": "M",
"Black": "K"
}
"key": "marker_color",
"mapping": {
"Cyan": "C",
"Yellow": "Y",
"Magenta": "M",
"CyanMagentaYellow": "CMY",
"Black": "K"
}
},
"properties": {
Expand Down

0 comments on commit a8623af

Please sign in to comment.