I created a decent looking printer ink status using a custom button-card and the IPP integration sensors that seems worth sharing.
To make this work, I have a template for each inkwell, and a main button-card to contain all the inkwells and show current printer status.
The inkwell template handles the ink level display, and will flash when below 10% to catch your attention. It expects an entity for the ink sensor and a color to show.
inkwell template
button_card_templates:
inkwell:
show_name: false
show_state: true
extra_styles: |
[[[ return `
@keyframes pulse {
5% {
background-color: ${variables.color};
}
}
`]]]
styles:
icon:
- opacity: 0.7
- color: '[[[ return variables.color ]]]'
- filter: drop-shadow( 0 0 2px rgba(0, 0, 0, .7))
state:
- font-size: 1.5em
- font-weight: bold
- text-shadow: 0 0 6px black
- overflow: visible
card:
- border: solid 3px gray
- border-top: none
- background: |
[[[
var level = entity.state;
var color = variables.color;
return `linear-gradient(to top, ${color}, ${color} ${level}%, rgba(255,255,255,0.12) ${level}%)`
]]]
- animation: |
[[[
return (0 + entity.state) < 10
? 'pulse ease-in-out 1s infinite'
: 'none'
]]]
The main card handles the layout and 5 different entities, one for the printer status and 4 for the ink status.
main button card
type: custom:button-card
entity: sensor.epson_wf_3540_series
name: WF-3540
color: gray
show_state: true
styles:
card:
- padding: 0 0 5px 0
icon:
- width: 100%
state:
- text-align: left
- width: 100%
grid:
- grid-template-areas: '"i c m y k" "n s s s s"'
- grid-template-columns: 1fr 1fr 1fr 1fr 1fr
- grid-template-rows: auto 1em
custom_fields:
k:
- width: 80%
- margin: auto
c:
- width: 80%
- margin: auto
m:
- width: 80%
- margin: auto
y:
- width: 80%
- margin: auto
custom_fields:
k:
card:
type: custom:button-card
template: inkwell
entity: sensor.epson_wf_3540_series_black_ink
variables:
color: black
c:
card:
type: custom:button-card
template: inkwell
entity: sensor.epson_wf_3540_series_cyan_ink
variables:
color: cyan
m:
card:
type: custom:button-card
template: inkwell
entity: sensor.epson_wf_3540_series_magenta_ink
variables:
color: magenta
y:
card:
type: custom:button-card
template: inkwell
entity: sensor.epson_wf_3540_series_yellow_ink
variables:
color: yellow