Skip to content

Commit

Permalink
Merge pull request #164 from elad-bar/sensor-pages-printed-per-consum…
Browse files Browse the repository at this point in the history
…able

Add sensor of total printed pages per consumable (toner only)
  • Loading branch information
elad-bar authored Jun 20, 2024
2 parents e9ba3bb + b2949bf commit 6f5f810
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.0.3

- Add support for `inktank` cartridge type
- Add sensor of total printed pages per consumable, available for toner only

## 2.0.2

Expand Down
12 changes: 9 additions & 3 deletions custom_components/hpprinter/managers/ha_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,15 @@ def _is_valid_entity(
for exclude_key in exclude:
exclude_value = exclude[exclude_key]

if data.get(exclude_key) == exclude_value:
is_valid = False
break
if isinstance(exclude_value, list):
if data.get(exclude_key) in exclude_value:
is_valid = False
break

else:
if data.get(exclude_key) == exclude_value:
is_valid = False
break

return is_valid

Expand Down
16 changes: 16 additions & 0 deletions custom_components/hpprinter/parameters/data_points.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@
"unit_of_measurement": "refills",
"state_class": "total_increasing",
"icon": "mdi:format-color-fill"
},
"total_impression": {
"path": "TotalImpressions",
"platform": "sensor",
"unit_of_measurement": "pages",
"state_class": "total_increasing",
"icon": "mdi:file-document-check",
"exclude": {
"consumable_type_enum": [
"ink",
"inkcartridge",
"printhead",
"tonercartridge",
"inktank"
]
}
}
}
},
Expand Down

0 comments on commit 6f5f810

Please sign in to comment.