Brother printer integration works great!

First off, this is NOT my work, I’m just so impressed so I wanted to show the result of it.
@Bieniu created the Brother Printer integration, and @Gluwc made the bar card, and these in combination makes it completely lala :grin:

This is the result of it, and it is just great, thankyou for the excellent work @Bieniu and @Gluwc

The sensor names have been changed in customizations.

This is the card config:

cards:
  - entities:
      - entity: sensor.fribert_stuen_status
      - entity: sensor.fribert_stuen_uptime
      - entity: sensor.fribert_stuen_page_counter
      - entity: sensor.fribert_stuen_b_w_counter
      - entity: sensor.fribert_stuen_color_counter
    type: entities
  - entities:
      - color: black
        entity: sensor.fribert_stuen_black_toner_remaining
      - color: magenta
        entity: sensor.fribert_stuen_magenta_toner_remaining
      - color: yellow
        entity: sensor.fribert_stuen_yellow_toner_remaining
      - color: cyan
        entity: sensor.fribert_stuen_cyan_toner_remaining
      - entity: sensor.fribert_stuen_belt_unit_remaining_life
        severity:
          - color: red
            value: 10
          - color: yellow
            value: 20
          - color: green
            value: 100
      - entity: sensor.fribert_stuen_fuser_remaining_life
        severity:
          - color: red
            value: 10
          - color: yellow
            value: 20
          - color: green
            value: 100
      - entity: sensor.fribert_stuen_pf_kit_1_remaining_life
        severity:
          - color: red
            value: 10
          - color: yellow
            value: 20
          - color: green
            value: 100
    title_position: inside
    type: 'custom:bar-card'
title: Brother DCP-9020CDW Printer
type: vertical-stack
6 Likes

My printer seems to disappear often and gets listed as “Unavailable”. It’s using ethernet and not Wifi. Anyone have ideas on why it would do this?

fixed ip?
firmware updates?

my printer is a quite old model, but its very stable.

Yep. It’s got a static lease. I’ve never looked at firmware updates, though

Thanks for this example and thanks @Bieniu for creating this component. I have a Brother HL-L2380DW all-in-one printer and it was automatically detected by the integration.

2 Likes

great integration - thanks guys.

    - type: entities
      title: Laser Printer
      show_header_toggle: false
      entities:
        - type: custom:hui-horizontal-stack-card
          cards:
            - type: custom:hui-horizontal-stack-card
              cards:
              {% for color in colors %}
              - type: custom:bar-card
                entity: sensor.hl_l8250cdn_{{ color }}_toner_remaining
                color: {{ color }}
                title_position: 'off'
                unit_of_measurement: '%'
                direction: up
                indicator: auto-vertical
                width: 3em
                height: 8em
                rounding: 10px
                style: |
                  ha-card {
                    border-radius: 0;
                    box-shadow: none;
                    background: transparent;
                  }
              {% endfor %}
            - type: picture-elements
              image: /local/images/short-empty.png
              elements:
              - type: image
                image: /local/images/printer.png
                style:
                  top: 140%
                  left: 50%
                  width: 100%
                  filter: drop-shadow(2px 2px 5px rgb(100, 100, 100, 1)
              style: |
                ha-card {
                  border-radius: 0;
                  box-shadow: none;
                  background: transparent;
                  height: 100%;
                }

        - type: custom:hui-horizontal-stack-card
          cards:
            - type: entities
              show_header_toggle: false
              entities:
                - entity: sensor.hl_l8250cdn_page_counter
                  name: Pages
                - entity: sensor.hl_l8250cdn_color_counter
                  name: Colour
                - entity: sensor.hl_l8250cdn_b_w_counter
                  name: B&W
              theme: no-shadow
            - type: entities
              show_header_toggle: false
              entities:
                - entity: sensor.hl_l8250cdn_belt_unit_remaining_life
                  name: Belt
                - entity: sensor.hl_l8250cdn_drum_remaining_life
                  name: Drum
                - entity: sensor.hl_l8250cdn_fuser_remaining_life
                  name: Fuser
              theme: no-shadow

P.S. The code depends on lovelace_gen so I don’t repeat the setup for the colors, easy enough to do a section for each color if preferred. Otherwise you’d need to add lovelace_gen and the following:

{% set colors = ['cyan', 'magenta', 'yellow', 'black'] %}
4 Likes

So, as far as I can see, you are using two custom items.
hui-horizontal-stack-card
lovelace_gen
and you’ve placed them in a entities card.
The hui-horizontal-stack-card is not in HACS, right? Or is it called something weird.

Lovelace_gen isn’t really a card, more a way to build your config programmatically. I wouldn’t install it just for this, but I use it for more complex views, so it’s already there.

I put everything into an entities card so they end up looking like a single card. You can use other cards as rows in entity cards. But if you do you have to refer to them as custom:hui-card-name-card. So, I’m just using the standard horizontal-stack card.

1 Like

Hi Bertie

I finally got some time to look into this, it is very enlightening with the way to use horizontal/vertical cards.
I used it on my ‘alarms’ card, that I wasn’t satisfied with, and it looks much better now.
I’m changing my printercard to match yours, it’s simply prettier :slight_smile:
One thing I can’t figure out, in the ‘pictures-elements’ card inside, where it shows the printer, you use a

image: /local/images/short-empty.png

What is that? A transparent picture of a certain size, or what does it do?

Yes, exactly that.

I used picture-elements here to give me control over positioning the printer image.

TBH looking at all this, it might have been easier to do the whole thing in a picture-elements card, and use the positioning options in that to place things (rather than all the horizontal / vertical stacks).

I often set off in one direction, find issues and fix them. I’m not so good at looking back at it and rethinking at the end, to see if it could have been done more simply.

Hmm, yes, it might be true, but I have the exact same problem, if it works, I’ll leave it :smiley: Otherwise I could keep changing stuff as I learn.
I’m trying to position the image, but I can’t make it look right, what’s the size of the printer picture compared to the short-empty???

Mine looks like this at the moment??? :slightly_smiling_face: :
image

Have you got those images available somewhere?

Ahh, got a lot closer, it looks almost correct now.
image
Still need to try and make the printer a bit smaller.

But below the edit window I see this message (it still works):

Expected a value of type {entity,name,icon} | entity-id for entities.0.type but received "custom:hui-horizontal-stack-card".

Is the ipaddress changing

Could u post your lovelace code
Thanks

looking good, if you want the printer smaller, just change the width and the height will scale

hard to say what the error might be unless you post your yaml

The yaml looks like this (it’s quite long)
No, the IP is the same.

type: entities
title: Brother DCP9020-CDW
show_header_toggle: false
entities:
  - type: 'custom:hui-horizontal-stack-card'
    cards:
      - type: 'custom:hui-horizontal-stack-card'
        cards:
          - type: 'custom:bar-card'
            entity: sensor.fribert_stuen_black_toner_remaining
            color: black
            title_position: 'off'
            unit_of_measurement: '%'
            direction: up
            indicator: auto-vertical
            width: 3em
            height: 14em
            rounding: 10px
            style: |
              ha-card {
                border-radius: 0;
                box-shadow: none;
                background: transparent;
              }
            icon_position: 'off'
            saturation: 50%
            animation: auto
            speed: 1000
            delay: 5000
            min: 0
            max: 100
            padding: 4px
            align: center
            tap_action: info
            show_value: true
            limit_value: false
            show_minmax: false
            title: false
            severity: false
            target: false
            attribute: false
            icon: false
            charge_entity: false
            card_style: false
            icon_style: false
            title_style: false
            value_style: false
            minmax_style: false
            background_style: false
            visibility: false
            decimal: false
            entities:
              - entity: sensor.fribert_stuen_black_toner_remaining
          - type: 'custom:bar-card'
            entity: sensor.fribert_stuen_cyan_toner_remaining
            color: cyan
            title_position: 'off'
            unit_of_measurement: '%'
            direction: up
            indicator: auto-vertical
            width: 3em
            height: 14em
            rounding: 10px
            style: |
              ha-card {
                border-radius: 0;
                box-shadow: none;
                background: transparent;
              }
            icon_position: 'off'
            saturation: 50%
            animation: auto
            speed: 1000
            delay: 5000
            min: 0
            max: 100
            padding: 4px
            align: center
            tap_action: info
            show_value: true
            limit_value: false
            show_minmax: false
            title: false
            severity: false
            target: false
            attribute: false
            icon: false
            charge_entity: false
            card_style: false
            icon_style: false
            title_style: false
            value_style: false
            minmax_style: false
            background_style: false
            visibility: false
            decimal: false
            entities:
              - entity: sensor.fribert_stuen_cyan_toner_remaining
          - type: 'custom:bar-card'
            entity: sensor.fribert_stuen_magenta_toner_remaining
            color: magenta
            title_position: 'off'
            unit_of_measurement: '%'
            direction: up
            indicator: auto-vertical
            width: 3em
            height: 14em
            rounding: 10px
            style: |
              ha-card {
                border-radius: 0;
                box-shadow: none;
                background: transparent;
              }
            icon_position: 'off'
            saturation: 50%
            animation: auto
            speed: 1000
            delay: 5000
            min: 0
            max: 100
            padding: 4px
            align: center
            tap_action: info
            show_value: true
            limit_value: false
            show_minmax: false
            title: false
            severity: false
            target: false
            attribute: false
            icon: false
            charge_entity: false
            card_style: false
            icon_style: false
            title_style: false
            value_style: false
            minmax_style: false
            background_style: false
            visibility: false
            decimal: false
            entities:
              - entity: sensor.fribert_stuen_magenta_toner_remaining
          - type: 'custom:bar-card'
            entity: sensor.fribert_stuen_yellow_toner_remaining
            color: yellow
            title_position: 'off'
            unit_of_measurement: '%'
            direction: up
            indicator: auto-vertical
            width: 3em
            height: 14em
            rounding: 10px
            style: |
              ha-card {
                border-radius: 0;
                box-shadow: none;
                background: transparent;
              }
            icon_position: 'off'
            saturation: 50%
            animation: auto
            speed: 1000
            delay: 5000
            min: 0
            max: 100
            padding: 4px
            align: center
            tap_action: info
            show_value: true
            limit_value: false
            show_minmax: false
            title: false
            severity: false
            target: false
            attribute: false
            icon: false
            charge_entity: false
            card_style: false
            icon_style: false
            title_style: false
            value_style: false
            minmax_style: false
            background_style: false
            visibility: false
            decimal: false
            entities:
              - entity: sensor.fribert_stuen_yellow_toner_remaining
      - type: picture-elements
        image: /local/printer/short-empty.png
        elements:
          - type: image
            image: /local/printer/brotherdcp9020cdw2.png
            style:
              top: 50%
              left: 50%
              width: 100%
              filter: 'drop-shadow(2px 2px 5px rgb(100, 100, 100, 1)'
        style: |
          ha-card {
            border-radius: 0;
            box-shadow: none;
            background: transparent;
            height: 100%;
          }
  - cards:
      - entities:
          - entity: sensor.fribert_stuen_page_counter
            name: Sider
          - entity: sensor.fribert_stuen_color_counter
            name: Farveprint
          - entity: sensor.fribert_stuen_b_w_counter
            name: Sort/Hvid print
        show_header_toggle: false
        theme: no-shadow
        type: entities
      - entities:
          - entity: sensor.fribert_stuen_belt_unit_remaining_life
            name: Belt
          - entity: sensor.fribert_stuen_pf_kit_1_remaining_life
            name: PF Kit
          - entity: sensor.fribert_stuen_fuser_remaining_life
            name: Fuser
        show_header_toggle: false
        theme: no-shadow
        type: entities
    type: 'custom:hui-horizontal-stack-card'

Guys I need some help to add some new sensors for the integration. If someone has a color printer with a small amount of color (not black) toner, this can do for me:

pip install --upgrade git+https://github.com/bieniu/brother@dev
curl https://raw.githubusercontent.com/bieniu/brother/dev/example.py -o example.py
python3 example.py <PRINTER_IP>

As a result, the text RAW data: {...} will appear. I need thit data from {...} with information which toner is low in the printer.

I have a yellow with 21% is that low enough?
How would I go about doing this, just via the ssh addon?

I’m not sure, I think that has to be below 11%. On the printer’s www panel should be information about low toner.