HP OfficeJet Printer Binding

Small issue:
When starting the ink level are initialised to 0:

2019-01-12 10:02:54.739 [vent.ItemStateChangedEvent] - Printer_BlackRemaining changed from NULL to 0.0 %
2019-01-12 10:02:54.754 [vent.ItemStateChangedEvent] - Printer_ColorRemaining changed from NULL to 0.0 %

They should be set at UNDEF

Thanks

Hi @Cossey,

Interesting! I always used the rounded values.
Meaning: I havenā€™t been aware of the actual values. Even better I guess since only one file needs to be consideredā€¦

The new update now supports displaying this information.

There were a few bugs regarding the unsupported printer Thing, they have been fixed and the Thing has been renamed to Unsupported HP Printer. Additionally I have added your printer in, however it may not be auto-discovered depending on the name of the device. If you set your logging to trace for the binding it should tell you the data that it finds after the Found unsupported HP device identified as text in the log.

Done, that one should auto-discover now.

That was a bug with processing a couple of the Thing s, that has now been fixed.

Not quite sure how I set the values to ā€˜UNDEFā€™ so for now I have removed them from being set to 0, I figure if I set them to 0 it would cause issues with persistence.

Enjoy.

1 Like

Yes it wouldā€¦

Hi there,
I just updated the binding to the latest version as of 2019/01/12.

  1. My printer has now been correctly discovered as a HPColorLaserJetMFPM277dw.
    Thanks for including its definition! Great!
  2. There are no channels regarding page counts exposed?! (Only status,the toner levels and reboot)
  3. And my log shows two anomalies:
    3a) They level of my currently empty CYAN cartridge has dropped to -2% :slight_smile:

2019-01-12 16:36:35.130 [vent.ItemStateChangedEvent] - HPColorLaserJetMFPM277dw9F474D_Ink_CyanLevel changed from NULL to -2

The WebUI shows the cartridge as empty, i.e. ā€“% .

3b) Immedietely afterwards in the log, it also says:

2019-01-12 16:36:35.130 [ERROR] [hpprinter.internal.handler.Type1Info] - Error reading Impressions
java.lang.NullPointerException: null
at org.openhab.binding.hpprinter.internal.handler.Type1Info.CheckUsage(Type1Info.java:179) ~[?:?]
at org.openhab.binding.hpprinter.internal.handler.HPPrinterHandler.lambda$3(HPPrinterHandler.java:230) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]

I have this in my log several times. Maybe there is something to fix here?!
Thanks again

Hi Stewart,
may I suggest adding two important channels - if possible:

  1. EstimatedPagesRemaining for each colour channelā€¦ that should give a nice hint on how long the cartridge will last.
  2. JamEvents for the printer unit (and maybe on the scan unit, too) - assuming an increase by 1 if a jam occurs this would allow for alerting jams on an UI.

Kind regards! Stephen

Ooops, just turned off the printer and:

2019-01-12 20:44:49.042 [ERROR] [er.internal.handler.HPPrinterHandler] - WebRequest Error
java.net.SocketTimeoutException: connect timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
	at java.net.Socket.connect(Socket.java:589) ~[?:?]
	at sun.net.NetworkClient.doConnect(NetworkClient.java:175) ~[?:?]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) ~[?:?]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) ~[?:?]
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) ~[?:?]
	at sun.net.www.http.HttpClient.New(HttpClient.java:339) ~[?:?]
	at sun.net.www.http.HttpClient.New(HttpClient.java:357) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1040) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1038) ~[?:?]
	at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
	at java.security.AccessController.doPrivilegedWithCombiner(AccessController.java:782) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1037) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984) ~[?:?]
	at org.openhab.binding.hpprinter.internal.handler.WebRequester.Do(WebRequester.java:111) ~[?:?]
	at org.openhab.binding.hpprinter.internal.handler.Type1Info.CheckStatus(Type1Info.java:74) ~[?:?]
	at org.openhab.binding.hpprinter.internal.handler.HPPrinterHandler.lambda$2(HPPrinterHandler.java:226) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
==> /var/log/openhab2/events.log <==
2019-01-12 20:44:49.064 [hingStatusInfoChangedEvent] - 'hpprinter:deskjet2620:HPDesket2620' changed from ONLINE to OFFLINE
2019-01-12 20:44:49.071 [vent.ItemStateChangedEvent] - Printer_Status changed from Power Save to Offline

Thank you so much - just tested and it works like a charm!

Hi

Attached are the files for an HP Envy 4520 All-in-One printer.

Thought these might be useful as it doesnā€™t currently get discoverd.

Thanks

ProductStatusDyn.xml (1.5 KB)
ProductUsageDyn.xml (25.8 KB)

Hi @Cossey,

I have 2 additional printers I would love to see in this binding:

HP LaserJet 200 color M251nw
ProductStatusDyn.xml (1.4 KB)
ProductUsageDyn.xml (9.2 KB)

HP Officejet 6600 e-All-in-One
ProductStatusDyn.xml (1.5 KB)
ProductUsageDyn.xml (30.5 KB)

Thank you!

At the moment, these havenā€™t been implemented for all models, I now have 9 models of printer and it appears that their page counts differ slightly in where they are in the usage xml file. I will get around to adding this support in eventually.

That is very interesting! Iā€™ll have to do a check of the value and if its <0 then set it to 0 in the UI. I havenā€™t drained my ink carts yet so I wasnā€™t exactly sure what status this would show when empty, but your note here will help heaps!

Thatā€™s the code trying to read the page counts for the printer, but it appears that they arenā€™t in the same spot as the OfficeJet printers in the xml. I will try and work on handling this error better.

Whoops, I missed that when I added the page count stuff into the system. Will add this data point since itā€™s grouped in the same area as the other page counts.

This set of information I was intending on right after Ink channels but others found the page counts more useful, youā€™ll have to wait a bit until I have the other channels all stable and working for the printer models Iā€™ve been given before I feel comfortable adding this in (it will exponentially add more work for me).

Sorry about this, Iā€™ve made some code changes with the last update to make future changes more managable, however such a change had made some of the errors creep back in and get reported back to the console again. Ill prioritise getting those fixed.

Okay, Ill add this one, if the Binding doesnā€™t specifically have the Printer model support it wonā€™t auto-discover at the moment. I intend on the Generic Model in the Binding to handle situations like these and work with only the simple channels (colour ink level and status) - like the way the Onkyo Binding operates but have not gotten to this just yet, for now itā€™s easier for me to add support for specific models.

Okay, Iā€™ll get those added too.

Note
Thanks everyone for your feed back and help in testing this Binding. I now have 9 models of printers reported in this forum that I am going to try my best to support.

Ill try my best to get everything reported here resolved in due time. Fortunately, the Ink levels and status all seem to be in the same sections in the xml file which make adding support for new models not too difficult but since the Page count stuff is in different spots adding support for those for new models/non-OfficeJet Pros will be a bit delayed.

I am now tracking all error reports and feature requests here: https://github.com/Cossey/openhab2-addons/issues

1 Like

Regarding the issue " They level of my currently empty CYAN cartridge has dropped to -2%" on my HP Color LaserJet MFP M277dw:

  1. I already got myself a new CYAN cartridge but I will to try to refrain from installing it until after getting to test your next version. Just keep us updated on your progress regarding this issueā€¦
  2. Additionally (just to let you know): The ProductStatusDyn[1].xml submitted in my first post for this binding includes this situation for the CYAN ink level

New update! You can follow the issues here regarding progress of requests: Issue Tracker

  • Added support for LaserJet 200
  • Added support for OfficeJet 6600
  • Added support for ENVY 4520
  • Added JamEvents channel
  • Fixed SocketTimeoutException error from displaying when printer powered off
  • Fixed Impression read error being displayed as an error (it is still mentioned in debug, will evetually disappear in later updates when all devices get proper impression support)

Feel free to go ahead and install it - since youā€™ve given me the file with this situation in it I can test it on my end here. I have a simple node web server running (to simulate the EWS) that serves up these xml files into so I can test with my binding how it works with the snapshots of these files.

Wow, that was fast!
I receive an error though when trying to add the LaserJet 200 manually:

2019-01-13 14:28:30.491 [WARN ] [ore.thing.internal.ThingRegistryImpl] - Cannot create thing. No binding found that supports creating a thing of type 'hpprinter:laserjetpro200colorm251mw'.

For the OfficeJet 6600 only one channel ā€œColour Levelā€ is available, but this printer has 4 different color cartridges.

Also added that as a comment to github.

Thanks, ill track all issues through GitHub just to help me keep on top of everything.

Hi

Thanks for taking the time to create this binding. :slight_smile:

Iā€™ve got two different HP printers (MFDs) here, a Deskjet 3520 and an OfficeJet 7500_E910

Iā€™ve put all the XML files into a zip for you to have a look at.

HP XML files

Iā€™ve got the ā€˜latestā€™ firmware in my OfficeJet, but I think it has a small bug.
It seems to go into a really deep sleep, where it can only be woken up from the front panel etc, but the (cabled) network connection remains asleep.
(Only a power cycle brings it back up)

A small part of me is thinking that if I ran your binding, it might stop the network connection from going into a coma.

Have you tried adding it to the network binding
Maybe a regular ping would achieve that?

Excellent suggestion, Iā€™ll give it a try :smile: thanks.

Hi MDAR,

You can track progress regarding your printer support via the issues linked below. I will also post in this thread when new update is released with a note regarding the fixes/supported printers.

I havenā€™t had the chance to do any fixes the past few days and I do have to sort out Issues 1, 2 and 3 before I can focus on the ones below.

Thanks for including your xml files, they will allow me to test locally here to make sure they work as expected, you should expect all channels for the OfficeJet but only Ink Levels and Status for the DeskJet for now as adding in more than the simple channels for other models is a WIP.

1 Like

New Update!

  • All supported models now display the Usage channels
  • Removed the subscription channel
  • Unsupported HP printers that are auto-discovered now show up as Unsupported HP Printer
  • Fixes to some Models not working

Possible issues:

  • The laser jets may auto-discover as an unsupported HP device; I will need to get the model name that is displayed via UPNP from users (this is displayed in the when the logging is set to DEBUG level for the Add-on).

Changes upcoming:

  • Adding support for two new printers mentioned above, issue 12 and 13.
  • Trying to get that Reboot channel to reboot the printer, issue 10. for supported models only

You can track current progress at the issue tracker. This should now bring every model in line with one another, presently supporting 10 models!

3 Likes