Well, I’ll look into this, but no promise Even if the template is used, somehow last values need to be stored somehow… so another set of variables to hold these values and some automations to record for future use… Since this is interesting ‘generic’ problem I’ll try to investigate though…
Thank you for this excellent setup, @mirekmal! I was able to follow your instructions and now can integrate my HP P2055dn into HA. I like your printer card, too, and decided to use it with my already-integrated Brother printers as well.
One issue I had that took me awhile to track down: because the printer uptime updates frequently, my history page started slowing down to the point where it would take 10 or more minutes to load. I excluded the p2055dn sensors from the history, and now the history page loads almost instantly. I’m not positive, but from the number of lines in the history graph, I think it updates the uptime every second. That’s 10,800 updates in the 3-hour bar graph of the history chart, and it was hogging all of my resources to display the page. Thank you again for the great addition to HA!
Thanks for feedback, @tanderson1992, glad you like the setup!
Well, I did not noticed issue you reported, since I’m running my recorder already in the way that I explicitly specify entities I want to track the history. If I recall properly, the reason I do not record everything was actually SNMP sensor for bandwidth monitoring for my router, that cause exactly the same issue as you reported!
Now, it is possible to get this easily fixed by changing scan_interval parameter from 1 to for eample 60 inside cp1515n_uptime sensor definition. Actually it would make a lot of sense, since this level of accuracy for such sensor does not make too much sense…
Good call. I changed it to 60 but will still keep it excluded from History.
I also updated definition of cp1515n_printer_uptime sensor to reflect fact that seconds value changes only once a minute, so there is no sense to display these. So now it display only something like Uptime: 6d 23h 13m:
cp1515n_printer_uptime:
friendly_name: "Printer Uptime"
value_template: >-
{% set t = states('sensor.cp1515n_uptime') | int %}
{% set t = (t/10) | int %}
{{ '{:d}d {:02d}h {:02d}m'.format(t // 86400, (t // 3600) % 24, (t % 3600) // 60, (t % 3600) % 60) }}
Interestingly, I found with my MFP MF477FDW that the uptime calculation was out by a factor of 10, so needed to do a t/100 rather than 1/10…
I couldn’t work out initially why the uptime was jumping so fast!
For those that want to know the usuable oid…
snmpwalk -v 1 -c public 192.168.1.100 (whatever IP your printer has)
And there is also a GUI-tool. Just adding ip and ‘walk’ from 1 gives you all the OID nicely listed
Debug your SNMP configuration with SNMP Tester (paessler.com)
Hi,
Just found this project and I think is wonderful.
Can somebody show me what is oid for scanned pages. I want to have also that and didn’t found a proper oid for that.
For now I know that the information is obtained for my Office8022 Printer through a custom integration, so the information exists, but I scanned all available oid’s on my printer and didn’t find the value shown in integration for scanned pages.
According to HP OID documentation it should be something there:
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.1.16.2.1.5
scanned-media-total-charge OBJECT-TYPE
SYNTAX OCTET STRING
ACCESS read-only
STATUS optional
DESCRIPTION "The total charge for pages scanned, for this media size.
"
::= { scanned-media-usage 5 }
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.1.16.2.1.1
scanned-media-simplex-count OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS optional
DESCRIPTION "Total number of simplex pages scanned, for this media size.
"
::= { scanned-media-usage 1 }
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.1.16.2.1.2
scanned-media-simplex-charge OBJECT-TYPE
SYNTAX OCTET STRING
ACCESS read-write
STATUS optional
DESCRIPTION "Charge for each simplex page printed in this media size.
"
::= { scanned-media-usage 2 }
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.1.16.2.1.3
scanned-media-duplex-count OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS optional
DESCRIPTION "Total number of duplex pages scanned, for this media size.
"
::= { scanned-media-usage 3 }
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.1.16.2.1.4
scanned-media-duplex-charge OBJECT-TYPE
SYNTAX OCTET STRING
ACCESS read-write
STATUS optional
DESCRIPTION "Charge for each duplex page scanned, for this media size.
"
::= { scanned-media-usage 4 }
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.1.16.2.2
usage-scanner-total-charge OBJECT-TYPE
SYNTAX OCTET STRING
ACCESS read-only
STATUS optional
DESCRIPTION "Total scanner charge or cost for all paper sizes scanned.
"
::= { scanner-accounting 2 }
-- 1.3.6.1.4.1.11.2.3.9.4.2.1.2.2.1.62
scanner-accessory-send-job-scan-count OBJECT-TYPE
SYNTAX INTEGER
ACCESS read-only
STATUS optional
DESCRIPTION "This relates to the number of pages scanned for fax/send. This
item is incremented by 2 for each sheet scanned through the ADF
in 2-sided scan mode, and it is incremented by 1 for flatbed
scans. Scanning for testing and calibration purposes are NOT TO
BE INCLUDED in this count.
"
::= { settings-scanner 62 }
Cannot check this myself, as my printer does not have scanning functionality…
Thank you for effort, but for every oid is returning value “null2” . I’m sure that something is there , but still hidden
L.E.
For everybody wanting OfficeJet Hp printer OID I found main attributes, but still have some things to bring togeter, so:
- found a bit of info and followed path:
c# - snmp oid for scanner detail(HP LaserJet 3055) - Stack Overflow
arrived here:
https://mibs.observium.org/mib/HP-OFFICEJET-PRO-X576DW-MIB/
Noticed that from OID provided i had to bring another .0 at the end and all (almost good) like:
1.3.6.1.4.1.11.2.3.9.4.2.1.2.2.1.20.0 - adf scanned
1.3.6.1.4.1.11.2.3.9.4.2.1.2.2.1.21.0 - flatbed scanned
Started comparing with what I have from the current sensors, and I have main values: ADF and Flatbed scanned pages, but now I wonder how to get a sensor to show errors for scanning, because I cannot find sum of all scanned pages. I have 28 + 83, but total OID for scanned pages shows me…107
On the forum it says:
1.3.6.1.2.1.25.3.5.1.2 . It returns an octet string and you need to interpret it as
Condition Bit # hrDeviceStatus
lowPaper 0 warning(3)
noPaper 1 down(5)
lowToner 2 warning(3)
noToner 3 down(5)
doorOpen 4 down(5)
jammed 5 down(5)
offline 6 down(5)
serviceRequested 7 warning(3)
but cannot find how to query in Passler or to do the sensor in HA based on that info to find errors.
Hi folks,
I use a HP Color LaserJet CM1312nfi MFP and some of the OIDs don’t fit.
I made a walk with a SNMP Scanner and found lots of OIDs but I don’t know the meaning of all of them.
The HP-LASERJET-COMMON-MIB
from observium.org seems not to be the right explanation.
How can I find out what I need?
For example, the error.codes do not fit
I am trying to adapt this to my HA.
Code below is running as a package. I am trying to mirrow the setup for the HP Printer over SNMP by the original code poster @mirekmal. If you had a moment and could take a look and offer suggestions. Realizing this is not complete, but trying to mimic what you have. thanks.
# Printer information via SNMP
# Black toner
- platform: snmp
name: 'e120n_black_capacity'
host: 192.168.2.6
baseoid: 1.3.6.1.2.1.43.11.1.1.6.1.1
accept_errors: true
scan_interval: 90
# unit_of_measurement: '%'
- platform: snmp
name: 'e120n_black_remaining'
host: 192.168.2.6
baseoid: 1.3.6.1.2.1.43.11.1.1.9.1.1
accept_errors: true
scan_interval: 90
# unit_of_measurement: '%'
- platform: template
sensors:
cp1515n_black_level:
friendly_name: "Black Toner Level"
unit_of_measurement: '%'
value_template: "{{ (states('sensor.cp1515n_black_remaining')|float / states('sensor.cp1515n_black_capacity')|float * 100) | round(0) }}"
e120n_printer_error:
friendly_name: "Printer Error"
value_template: >-
{% if is_state('sensor.e120n_printer_error_code', '0') %}
Paper Jam
{% elif is_state('sensor.e120n_printer_error_code', '1') %}
Cover Open
{% elif is_state('sensor.e120n_printer_error_code', '2') %}
Toner Status
{% else %}
Unknown
{% endif %}
I was brought here to help.
For Lexmark printers
Print count:
.1.3.6.1.2.1.43.10.2.1.4.1.1
Consumables:
(you need to find out the number of consumables you have in the printer, snmpwalk can help here. n is an integer between 1 and 30-40)
item type/name:
.1.3.6.1.2.1.43.11.1.1.6.1. + n
item capacity:
.1.3.6.1.2.1.43.11.1.1.8.1. + n
item left (of capacity):
.1.3.6.1.2.1.43.11.1.1.9.1. + n
If item left == -1 "OK"
If item left == -2 "unknown"
If item left == -3 "some left" # unknown amount/less than you can detect.
Warning messages:
.1.3.6.1.2.1.43.18.1.1.8.1.29
.1.3.6.1.2.1.43.18.1.1.8.1.31
.1.3.6.1.2.1.43.18.1.1.8.1.518
.1.3.6.1.2.1.43.18.1.1.8.1.305
Basic information:
Printer:
.1.3.6.1.4.1.641.2.1.2.1.2.1
Printer name:
.1.3.6.1.2.1.1.5.0
Serial #:
.1.3.6.1.4.1.641.2.1.2.1.6.1
Date of installation:
.1.3.6.1.4.1.641.6.2.3.1.7.1
I have the same OIDs for HP and Nashuatec also if anyone is interested.
@Hellis81 - Does item capacity and item left both refer to the black toner? What about individual warning messages. Can you tell me what each refers to? I am not at home and would have to do another snmpwalk to see if what I get is the same what your getting.
Yes
.1.3.6.1.2.1.43.11.1.1.6.1.1
Is probably “Black toner”
.1.3.6.1.2.1.43.11.1.1.8.1.1
Could be 10000
.1.3.6.1.2.1.43.11.1.1.9.1.1
Might be 5000
And the three above then means the Black toner is at 50%.
If you replace the last digit to a 2
you might get a color toner, or rollers, service kit, staples, image unit or anything else that it reports.
The warning messages is kind of a mess.
In my Excel file I just group them all in to one string and add a new line in between.
Sometimes they are all the same or sometimes they show the same thing differently or different things all together.
I have not really understood it. But for my use case, I just need all warning messages
Even from the original poster and from searching google I don’t see OID’s start with a ‘.’ When you reference them you begin with the dot. Is that correct?
I believe it depends on the language you use to get the data.
Some require the dot some don’t.
I haven’t put much thought to it, but I do know that VBA requires the dot.
@Hellis81 Just curious how did you setup your SNMP printer? I ask because I setup mine as a package and it seemed to be fine until an update for HA came out yesterday which forced me to revert back to a older backup.
I don’t have a printer at home or connected to HA.
I just manage all printers at work using Excel VBA script.
Can’t help you