poudenes
(Poudenes)
1
Hi All,
I can read my printer ink level. But HP have no % but max level is equal to 100%
platform: snmp
name: 'Printer Ink - Yellow'
host: 192.168.100.28
baseoid: iso.3.6.1.2.1.43.11.1.1.8.1.3
accept_errors: true
scan_interval: 86400
output is 15
full value is:
Black 674 (equal 100%)
cyan 240 (equal 100%)
yellow 226 (equal 100%)
magenta 241 (equal 100%)
how can I convert this into % instead of the value.
I know its value/674*100 = percent
but how do I get this in my HA?
Are those four ink levels state attributes of the printer entity? If so, you could create a template sensor to display this information in the UI.
poudenes
(Poudenes)
3
And in the value_template the calculation?
Exactly. One sensor for each ink color.
poudenes
(Poudenes)
5
done… can you maybe help me with last part. How to keep the percent only with 2 decimals before ,
---
platform: template
sensors:
hp_magenta_ink:
friendly_name: 'HP Magenta Ink Level'
unit_of_measurement: '%'
value_template: "{{ states('sensor.printer_ink_magenta')|float / 226 * 100 }}"
Output is something like: 42.274643837 %
Sure thing! Try this:
"{{ (states('sensor.printer_ink_magenta')|float / 226 * 100) | round(2) }}"
1 Like
poudenes
(Poudenes)
7
great I saw this already in scripts I checked for some things. Now I know what it do! Thanks
poudenes
(Poudenes)
8
“{{ (states(‘sensor.printer_ink_black’)|float / 674 * 100) | round(0) }}”
this was the correct line ![:slight_smile: :slight_smile:](https://community.home-assistant.io/images/emoji/twitter/slight_smile.png?v=9)