Skip to content

Commit

Permalink
Fix #51 image drum OPC name
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Apr 27, 2020
1 parent 46317f4 commit 45b0090
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

**Fixed bugs:**

- Fix image drum OPC name [\#51](https://github.com/elad-bar/ha-hpprinter/issues/51)

## 2020-04-26

**Fixed bugs:**

- Fix disabled entities are getting enabled after periodic update (update interval)
- Fix offline printer is not updating entities correctly and after restart [\#45](https://github.com/elad-bar/ha-hpprinter/issues/45) [\#47](https://github.com/elad-bar/ha-hpprinter/issues/47)

Expand Down
2 changes: 2 additions & 0 deletions custom_components/hpprinter/helpers/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@

HP_HEAD_TYPE_INK = "ink"
HP_HEAD_TYPE_PRINT_HEAD = "printhead"
HP_ORGANIC_PHOTO_CONDUCTOR = "OPC"
HP_ORGANIC_PHOTO_CONDUCTOR_NAME = "Organic Photo Conductor"

HP_INK_MAPPING = {"C": "Cyan", "Y": "Yellow", "M": "Magenta", "K": "Black"}

Expand Down
20 changes: 12 additions & 8 deletions custom_components/hpprinter/managers/HPDeviceData.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,21 @@ def set_printer_consumable_data(self, printer_consumable_data):
color = consumable_label_code
else:
color_map = []
for color_letter in consumable_label_code:
mapped_color = HP_INK_MAPPING.get(color_letter, color_letter)

color_map.append(mapped_color)
if consumable_label_code == HP_ORGANIC_PHOTO_CONDUCTOR:
color = HP_ORGANIC_PHOTO_CONDUCTOR_NAME
else:
for color_letter in consumable_label_code:
mapped_color = HP_INK_MAPPING.get(color_letter, color_letter)

color_map.append(mapped_color)

color = "".join(color_map)
color = "".join(color_map)

if color == consumable_label_code:
_LOGGER.warning(
f"Head type {head_type} color mapping for {consumable_label_code} not available"
)
if color == consumable_label_code:
_LOGGER.warning(
f"Head type {head_type} color mapping for {consumable_label_code} not available"
)

cartridge_key = f"{head_type} {color}"

Expand Down

0 comments on commit 45b0090

Please sign in to comment.