Ink levels in Home Assistant

Note: Please, be aware that this post may contain affiliate links.

Awesome! Now we can get printer ink levels in Home Assistant. There has been a community HP addon available through HACS now for quite a few weeks. But with the release of Home Assistant 0.108, it’s now available as standard using the new IPP Integration (printer not included).

What Can The Integration Do?

The details the integration can provide will more than likely depend on your printer. For my HP OfficeJet Pro 8620, I get ink levels as well as the printer status and a disabled entity, letting me know when the printer came online.

For me, personally, the integration doesn’t provide as many details as the HP Printer addon, as that supplies info such as

  • Connected status (connect or not) as well as printer status
  • Number of printed pages
  • Number of scanned pages

Admittedly, this information is generally of little use & so speaking for myself, I’ll be more than happy with the official IPP Printer integration, as this comes with the knowledge that if there were any security bugs found they would be quickly fixed.

Obviously, the IPP Integration not only supporting HP Printers but any device that supports the IPP protocol.

Setup

Screenshot of my printer being auto detected by the Home Assistant software. resulting in a persistent notification letting me know it had found the printer and offering the option of configuring it.
I didn’t even have to add it manually
Screenshot of ta box/pop up on the webpage showing that the printer has been successfully added to the system. In the pop up are the word "Success", the serial number (which I have blurred), the printer title, and a drop down box which allowed me to choose the room  which contains the printer.
All Added!

If you are in luck, as I was; you’re printer will have been auto-detected and you will have a persistent notification in your left sidebar. If that is the case, simply follow the “Configure” instructions.

If you have to set the printer integration up by hand however, it’s simply a case of visiting the Integrations section of the Configuration panel.

Add an integration and select IPP, then, again, follow the instructions.

Finding Your Printer Details

Once the printer has been installed and configured. You can find out what sensors etc are available by going into the Devices area of your Configuration panel and finding the IPP integration.

Screenshot showing that the only device under this particular integration (IPP) is the printer, which I have just added.
Just one device in the IPP integration

Once you’ve found your printer, click on it and you’ll see all the things that are available

Screenshot of all the things that are available to do with this device. As well as the printer title at the top there are three columns below the title.
The left hand column, has a card showing the title of the printer again, there is also a card underneath titles entities, it has the printer status ie "Idle", then a separate entity for each of the black; cyan; magenta and yellow ink levels. lastly there is a sensor for the printer uptime.
In the center column there is a single card titled automations, but is empty, as when I took the screenshot, there were no automation associated with the printer.
In the right hand column there are two empty cards. The first is titled Scenes and the second is titled scripts.
All the things associated with the device

So, if we to take my printer as an example. You can see above that I mainly have ink levels available, as well as the printer status. I also have an uptime entity, that for some reason was/is disabled by default. I did enable it, but after this post, I will be disabling it again, as it’s something that I won’t be using.

What Information Is Available?

The amount of information will depend on your printer make and model, but hopefully, as a minimum, it will include your printer ink levels.

As you can see from my data – my information includes the ink levels as well as the printer state.

Automations

You could also make a few automations from the UI. For example, you can see in my screenshot that I have several automations based on the ink levels.

automation:
  # Repeat for all colours
  - id: black_ink_low
    trigger:
      platform: numeric_state
      entity_id: sensor.hp_officejet_pro_8620_black_ink
      below: 20
    action:
      - service: notify.alexa_media
        data:
          message: "Your black ink cartridge is low in the printer"
          target: media_player.dad
          data:
            type: tts

If you do copy this automation across you will need to change the entity_id, and add your own service.

If you are interested in the Home Assistant TTS Service though, then you can check out my post on the subject… just in case you missed it of course.

In my screenshot: you can see that I have a dedicated button to re-order ink cartridges. This button takes me straight to the Amazon.co.uk Ink cartridges category. For you though, it would take you to your local Amazon store (details below)

entity: light.kitchen
hold_action:
  action: more-info
icon: 'mdi:printer'
icon_height: 50px
name: Buy Ink Cartridge
show_icon: true
show_name: true
tap_action:
  action: url
  url_path: 'https://hasscasts.com/suggests/ink-cartridges/'
type: button
theme: dark_teal # You may have to change the theme

Please take note of the URL. This is an affiliate link that will redirect you to your local Amazon stores Ink Cartridges category pages, so you won’t land on my site.

If you want to keep the button, please feel free to change the link to one of your choosing. If you do wish to support me though, these are the amazon stores it will redirect you to, if you are in those countries.

Amazon stores supported (affiliate links except where stated):

Obviously, if you wanted to use the button and you did want to contribute to my effort, then that would be fantastic.

Conclusion

I am really glad the IPP integration has come along. It means that there should be a fairly up to date and bug-free integration for my printer.

All My Config

As I have included images of my example Lovelace screen that I have set up, it seems only fair that I share it with you. Notes on the code are below it.

views:
  - icon: 'mdi:home'
    path: home
    title: Home
    theme: ''
    badges: []
    cards:
      - hold_action:
          action: none
        image: /local/assets/images/hp-8620.jpg
        tap_action:
          action: none
        type: picture
      - cards:
          - cards:
              - entity: sensor.hp_officejet_pro_8620_black_ink
                max: 100
                min: 0
                name: Black
                severity:
                  green: 25
                  red: 0
                  yellow: 10
                type: gauge
              - entity: sensor.hp_officejet_pro_8620_cyan_ink
                max: 100
                min: 0
                name: Cyan
                severity:
                  green: 25
                  red: 0
                  yellow: 10
                type: gauge
            type: vertical-stack
          - cards:
              - entity: sensor.hp_officejet_pro_8620_magenta_ink
                max: 100
                min: 0
                name: Magenta
                severity:
                  green: 25
                  red: 0
                  yellow: 10
                type: gauge
              - entity: sensor.hp_officejet_pro_8620_yellow_ink
                max: 100
                min: 0
                name: Yellow
                severity:
                  green: 25
                  red: 0
                  yellow: 10
                type: gauge
            type: vertical-stack
        title: Printer Ink Levels
        type: horizontal-stack
      - card:
          type: 'custom:button-text-card'
          title: Warning!
          subtitle: There is a printer error!
          icon: 'mdi:comment-alert'
          large: true
          font_color: '#fff'
          background_color: '#A81419'
        conditions:
          -  entity: sensor.hp_officejet_pro_8620
             state: stopped
        type: conditional
      - card:
          entity: sensor.hp_officejet_pro_8620
          hold_action:
            action: more-info
          icon: 'mdi:printer'
          icon_height: 50px
          name: Buy Ink Cartridge
          show_icon: true
          show_name: true
          tap_action:
            action: url
            url_path: 'https://hasscasts.com/suggests/ink-cartridges/'
          type: button
          theme: dark_teal
        conditions:
          - entity: sensor.hp_officejet_pro_8620
            state: stopped
        type: conditional
      - card:
          entity: sensor.hp_officejet_pro_8620
          type: entity
        conditions:
          - entity: sensor.hp_officejet_pro_8620
            state_not: stopped
        type: conditional

Code Notes

  • The image of my printer is just one I downloaded from the internet.
  • For the red warning card, I use the “Button Text Card” by Xavier Decuyper. I appreciate that others may wish to use another card type if they wish to replicate it.

Grandadevans

I am a disabled veteran of 3 tours of Iraq and a tour of Afghanistan as part of the British Army. No longer able to work as I have to lay down on a sofa-bed in my living room 20-ish hours a day. I'm hoping to be able to make a living blogging about my Home Automation /Smart Home journey and maybe regain some dignity in life.

One thought on “Ink levels in Home Assistant

  • June 8, 2020 at 14:32
    Permalink

    Great Post. This integration just popped up in my HA recently. Is there any way to have the sensor cards ‘retain’ the last known ink levels please? As these disappear if the printer is offline. Thanks.

    Reply

Leave a Reply