Epson WF-3540 ink level monitoring

Thanks a lot for your help I get it. I got it working with custum-ui, there only one little problem. When inkt level is 100% the wrong picture is shown. De status of the binary sensor is ok.
ink_level01

When I lower the threshold to 10% it is ok:
ink_level02

I think this has to do with rounding, Ink level is show as 10.0% and the value of Cyan is 100

I was able to solve this by checking the state of the binary_sensor instead of comparing the value of the the sensor with the ink_level. I don’t know how to use round.

sensor with ink_level:
    sensor.epson_ink_level_cyan:
      templates:
        entity_picture: >
          if (entities['binary_sensor.ink_level_cyan_threshold'].state != 'on' ) return '/local/images/devices/epson/ink_cyan.png';
          return '/local/images/devices/epson/ink_cyan_alert.png';

ink_level04

in jinja simply use |round(2) or |round see http://jinja.pocoo.org/docs/dev/templates/#round

{{states('sensor.epson_ink_level_black')|round}}
but since the ink_levels are int’s the above won’t make any difference.

You probably need to make an int of the input_number…

{{states('input_number.ink_level')|int }} should do it

and because you compare |ints, you should make ints out of both of these for the binary_sensors:

          {{(states('sensor.epson_ink_level_cyan') |int) <
            (states('input_number.ink_level') | int)}}

in my setup:

binary_sensor:
  - platform: template
    sensors:
      ink_level_black_threshold:
        friendly_name: 'Ink level black threshold'
        value_template: >
          {{ states('sensor.epson_ink_level_black') | int <
            states('input_number.ink_level') | int }}
      ink_level_magenta_threshold:
        friendly_name: 'Ink level magenta threshold'
        value_template: >
          {{ states('sensor.epson_ink_level_magenta') | int <
            states('input_number.ink_level') | int }}
      ink_level_yellow_threshold:
        friendly_name: 'Ink level yellow threshold'
        value_template: >
          {{ states('sensor.epson_ink_level_yellow') | int <
            states('input_number.ink_level') | int }}
      ink_level_cyan_threshold:
        friendly_name: 'Ink level cyan threshold'
        value_template: >
          {{ states('sensor.epson_ink_level_cyan') | int <
            states('input_number.ink_level') | int }}
      ink_level_waste_threshold:
        friendly_name: 'Ink level waste threshold'
        value_template: >
          {{ states('sensor.epson_ink_level_waste') | int <
            states('input_number.ink_level') | int }}

i copied your setup but i cant make work the device_tracker.epson_printer, any sugestion?

Hello.

You can post all your config for the printer, let’s say on github.com. A very nice solution.

what do you need? what did you try that doesn’t work yet?

1 Like

Hello.

I deduced the indicators themselves.

What I would like to do as you do.

  1. Display the ink notification setting as a percentage
  2. Alert
  3. Changes to the picture of a cartridge that has problems with the remaining toner.

I am using ui-lovelace.yaml and not standard tiles.

But it does not display a picture instead of an icon.

If you post the whole config it will be very cool. There are parts of the code in the entire branch, but collecting everything into one - I managed to display only % :frowning:

to change the regular icons and colors, I use custom-ui.

this is what I have now, might change the alert icons though :wink:

type: entities
title: Epson printer
card_mod:
  style: |
    .card-header {
      background-color: var(--background-color-off);
      color: var(--text-color-off);
      padding-top: 0px;
      padding-bottom: 0px;
      margin: 0px 0px 16px 0px;
    }
show_header_toggle: false
entities:

  - device_tracker.unifi_printer_epson
  - entity: script.update_epson_cartridge_sensors
    action_name: Update

  - type: custom:hui-glance-card
    card_mod:
      style: |
        ha-card {box-shadow:none;}
    entities:
      - entity: sensor.epson_ink_level_black
        name: Black
      - entity: sensor.epson_ink_level_cyan
        name: Cyan
      - entity: sensor.epson_ink_level_magenta
        name: Magenta
      - entity: sensor.epson_ink_level_yellow
        name: Yellow
      - entity: sensor.epson_ink_level_waste
        name: Waste

  - type: custom:bar-card
    card_mod:
      style: |
        ha-card {box-shadow:none;}
        bar-card-value {color:darkgrey;}
        bar-card-title {word-break:break-all;}
    stack: horizontal
    entity_row: true
    direction: up
    entities:
       - color: black
         entity: sensor.epson_ink_level_black
         name: Black
       - color: cyan
         entity: sensor.epson_ink_level_cyan
         name: Cyan
       - color: magenta
         entity: sensor.epson_ink_level_magenta
         name: Magenta
       - color: yellow
         entity: sensor.epson_ink_level_yellow
         name: Yellow
       - color: grey
         entity: sensor.epson_ink_level_waste
         name: Waste
    height: 150px
    max: 100
    min: 0
    target: 20
    unit_of_measurement: '%'
    width: 100%
    positions:
      icon: 'off'

  - type: custom:slider-entity-row
    entity: input_number.ink_level
  - automation.printer_ink_alert

  - type: custom:fold-entity-row
    head:
      type: section
      label: Low ink levels
    padding: 0
    entities:
      - type: custom:hui-glance-card
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
              /*background-image: url('/local/devices/epson/official/epson_background.png');
              background-size: cover;*/
            }
        entities:
          - entity: binary_sensor.threshold_ink_level_black
            name: Black
          - entity: binary_sensor.threshold_ink_level_cyan
            name: Cyan
          - entity: binary_sensor.threshold_ink_level_magenta
            name: Magenta
          - entity: binary_sensor.threshold_ink_level_yellow
            name: Yellow
          - entity: binary_sensor.threshold_ink_level_waste
            name: Waste

but admit not having looked at it for a long period, so maybe things can be improved upon

1 Like

Thanks. Installed custom-ui (very nice thing)

But you could not give all the configs (unless of course it is not difficult for you)

Flow rate adjustment sensors and sliders. I have been collecting on this topic. But it doesn’t work for me: (I really like your implementation and want to repeat it :slight_smile:

The main thing for me is to recreate all the elements and the display of pictures instead of icons. And already for my printer I will make both pictures and all the necessary colors.

Thank you so much for the earlier reply!

Ofc you need to install the used custom cards in the configuration

1 Like

Hello.

With the design, I figured out what to do. But with the normal operation of the sensors (how to make a picture + another if it ends) and how to display the notification settings slider and the notifications themselves, I did not understand :frowning:

I am just starting to use this system and I like it more and more :slight_smile:

Could you share the sensor settings, how to replace icons with pictures (for 2 types of pictures) and how to display the slider with notifications. As I understand it, I have no binary sensors.

top one: device_tracker for your printer, ofc, replace with the device you have, this is my config… :wink:

thew customizations is rather nifty:

##########################################################################################
# Customize
##########################################################################################

homeassistant:

  customize_glob:

    sensor.epson_ink_level_*:
      templates: &cartridge
        entity_picture: >
          var cart = entity.entity_id.split('level_')[1];
          if (entities['input_number.ink_level'] &&
                state > entities['input_number.ink_level'].state)
              return '/local/devices/epson/ink_' + cart + '.png';
          return '/local/devices/epson/ink_' + cart + '_alert.png';

  customize:

    device_tracker.unifi_printer_epson:
      templates: &state_color
        icon_color: >
          if (state == 'home') return 'green';
          return 'grey';

and the binaries are like:

template:

  - binary_sensor:

      - unique_id: threshold_ink_level_black
        name: Threshold ink level black
        state: >
          {{states('sensor.epson_ink_level_black')|int(default=0) <
            states('input_number.ink_level')|int(default=50)}}
        availability: >
         {{states('sensor.epson_ink_level_black') not in ['unknown','unavailable']}}

the slider input_number.ink_level you should be able to try for your self first?

1 Like

Thank you so much for your answers and patience! Everything turned out as I found something else in this huge topic :slight_smile: Once again, a huge thank you!

Hello. I apologize for so many questions. Could you tell me how to fit 6 sensors with a picture and Low ink levels on one line?

check Glance Card - Home Assistant

set that to 6? You’d have to change the names though, because it will get very messy. Better set it to 3m and have a double line, where each has more space for naming

1 Like