Custom Component - HP Printer

That fixed it! Thanks.

Does this support multiple printers?

Currently no, will work on that later this week to support gor multiple devices

1 Like

works great with my hp 5510, thank you very much! @bar

2019-11-13%2012_35_16-Window

3 Likes

Can you share the config of lovelace?

@phdelodder

 - type: custom:vertical-stack-in-card
         cards:
         - type: entities       
           entities:
             - type: custom:text-divider-row
               text: HP Photosmart 5510 Infos ### HP Photosmart 5510 B111a 
             - type: custom:bar-card
               columns: 4
               entities: 
                 - sensor.hp_photosmart_5510_b111a_black_ink
                 - sensor.hp_photosmart_5510_b111a_cyan_ink
                 - sensor.hp_photosmart_5510_b111a_magenta_ink
                 - sensor.hp_photosmart_5510_b111a_yellow_ink
               height: 200px
               min: 0
               max: 100
               width: 100px
               direction: up
               align: center-split
               title_position: inside
               severity:
                 - color: '#ff0000'
                   value: 10
                 - color: '#bf4040'
                   value: 25
                 - color: '#d3db39'
                   value: 60
                 - color: '#40bf40'
                   value: 100                            
         - type: markdown
           content: |
                  [HP Photosmart 5510 B111a Weboberfläche](http://192.168.1.121)
                  
                  - <ha-icon icon="mdi:counter"></ha-icon> - Druck Counter: **[[ sensor.hp_photosmart_5510_b111a_printer ]]** Seiten
                  - <ha-icon icon="mdi:cancel"></ha-icon> - Druck ABBRÜCHE: **[[ sensor.hp_photosmart_5510_b111a_printer.attributes.Cancelled ]]** Seiten
                  - <ha-icon icon="mdi:scanner"></ha-icon> - Scan Vorgänge: **[[ sensor.hp_photosmart_5510_b111a_scanner ]]** Seiten
6 Likes

Hi all,

Additional features available in latest version,
Updated version has breaking changes.

New features:

  • Support for multiple devices
  • Support printhead and not just toner / ink cartridges
  • More information on each of the cartridge’s sensors
    • Product Number
    • Serial Number
    • Manufactured By
    • Manufactured At
    • Warranty Expiration Date
    • Installed At
  • Store debug files service - Stores the XML and JSON of each request and final JSON to files, Path in CONFIG_PATH/*

Configuration changes:

Instead of:

hpprinter:
   host: hostname / IP
   name: printer name (Optional - Default - HP Printer)

Use:

hpprinter:
    devices:
        - host: hostname / IP
          name: printer name (Optional - Default - HP Printer)

All the information available in the README file,
Feel free to share feedbacks.

In case you encountered an issue, please try to provide the data from the store debug file service.

1 Like

Works great! just use devices instead of “devies” or the integration will fail.

Just gave it a try.
Seems my second printer, HP Photosmart C4700 series, doesn’t support the DevMgmt/ProductUsageDyn.xml (get a 404) even though it has a web server.
Oh well :frowning: Thanks for your work on this anyway!

Thanks! corrected the readme

C4700 is working with HP PrintOS which is another API

Is that a cloud only API?

Don’t know exactly, but in HP developer community there’s java integraion that need to reverse engineer it,
It works with authentication and access token and from that point you can access the information,
Since I don’t have that printer I cannot try doing that…

With the new version I am getting this error:

Failed to set printer consumable data (HP LaserJet M175nw @192.168.1.2), Error: 'OPC', Line: 220

Everything does seem to be working though…

found the potential cause for that error,
the error caused by unmapped color acronym into colors which is being represented differently in the 2 endpoints the component collects the information from the printer (one is working with acronym while the other with full name),
In the previous version I added just the mappings I were familiar with and didn’t protect the code too much when unknown color is being processed.

the “fix” I applied was to handle it better and log with warnning message if there is unmapped color,
I guess you will see a warnning message know, if you do, please post the warnning message and I will map that color as well.
On top of the color, I added the head type to the message, the reason - OPC (Organic Photo Conductor) maybe falls on another head type and needed to be treated diffrently than ink / toner.

Message will look like:
Head type {head_type} color mapping for {consumable_label_code} not available

Current color mapping:

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

I have this in my Log when Printer is Off.

Log Details (ERROR)
Mon Nov 18 2019 17:59:35 GMT+0100 (Mitteleuropäische Normalzeit)
Failed to update data (ProductUsageDyn) and parse it, Error: 'NoneType' object is not iterable, Line: 33

Added new binary sensor for device’s status,
In case the printer is not available, binary sensor will be off and will not try to throw the error

1 Like

I have been following this topic, but am confused.
Can someone explain the steps to install this and what yaml files and such go where.
Thank you
carltonb

Are you using HACS?

Yes using HACS. Looked at it but did not find the “plugin/integration” to use.
What is it called?
Thanks
carltonb