Skip to content

Commit a8623af

Browse files
committed
Change the matching of consumable to its details by marker color instead of station
1 parent 53c0350 commit a8623af

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.0.0b10
4+
5+
- Add support for mapping of multicolor consumable (CyanMagentaYellow)
6+
- Change the matching of consumable to its details by marker color instead of station
7+
38
## 2.0.0b9
49

510
- Add fallback mechanism for consumables, if station is not available, will use color mapping

custom_components/hpprinter/managers/rest_api.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,15 @@ def _extract_data(self, devices: list[dict]):
183183

184184
if identifier is not None:
185185
identifier_key = identifier.get("key")
186+
identifier_mapping = identifier.get("mapping")
186187

187-
device_id = item_data.get(identifier_key)
188+
key_data = item_data.get(identifier_key)
188189

189-
if device_id is None:
190-
fallback = identifier.get("fallback")
191-
if fallback is not None:
192-
fallback_key = fallback.get("key")
193-
fallback_mapping = fallback.get("mapping")
194-
195-
fallback_key_data = item_data.get(fallback_key)
196-
device_id = (
197-
fallback_key_data
198-
if fallback_mapping is None
199-
else fallback_mapping.get(fallback_key_data)
200-
)
190+
device_id = (
191+
item_data.get(identifier_key)
192+
if identifier_mapping is None
193+
else identifier_mapping.get(key_data)
194+
)
201195

202196
if flat:
203197
new_items_data = {

custom_components/hpprinter/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"iot_class": "local_polling",
1010
"issue_tracker": "https://github.com/elad-bar/ha-hpprinter/issues",
1111
"requirements": ["xmltodict~=0.13.0", "flatten_json", "defusedxml"],
12-
"version": "2.0.0b9"
12+
"version": "2.0.0b10"
1313
}

custom_components/hpprinter/parameters/data_points.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@
3636
"path": "ConsumableConfigDyn.ConsumableInfo",
3737
"device_type": "Consumable",
3838
"identifier": {
39-
"key": "consumable_station",
40-
"fallback": {
41-
"key": "consumable_label_code"
42-
}
39+
"key": "consumable_label_code"
4340
},
4441
"properties": {
4542
"consumable_label_code": {
@@ -119,15 +116,13 @@
119116
"path": "ProductUsageDyn.ConsumableSubunit.Consumable",
120117
"device_type": "Consumable",
121118
"identifier": {
122-
"key": "consumable_station",
123-
"fallback": {
124-
"key": "marker_color",
125-
"mapping": {
126-
"Cyan": "C",
127-
"Yellow": "Y",
128-
"Magenta": "M",
129-
"Black": "K"
130-
}
119+
"key": "marker_color",
120+
"mapping": {
121+
"Cyan": "C",
122+
"Yellow": "Y",
123+
"Magenta": "M",
124+
"CyanMagentaYellow": "CMY",
125+
"Black": "K"
131126
}
132127
},
133128
"properties": {

0 commit comments

Comments
 (0)