HP OfficeJet Printer Binding

I’ll need to get in some sleep now but if that doesn’t work the Things documentation does seem to point to another way of manually adding things.

Things Documentation

You could try using the following syntax in a .things file:
Thing hpprinter:deskjet2620:djprinter "Printer" @ "Office" [ ipAddress="192.168.1.1", refreshInterval="30" ]

Replace the IP address 192.168.1.1 with your printers IP address.

Channel names for .items files:

colourLevel (Number)
blackLevel (Number)
status (String)

I’ll try adding my printer using the above method when I have a chance.

Thanks for giving this a go and assisting me in this endeavour.

It worked.
Printer added. Thanks

I had to remove the jar after switching of the printer as it was flooding the logs with:

2019-01-06 16:17:59.628 [ERROR] [er.internal.handler.HPPrinterHandler] - Problem parsing status
java.net.NoRouteToHostException: No route to host (Host unreachable)
	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 java.net.Socket.connect(Socket.java:538) ~[?:?]
	at sun.net.NetworkClient.doConnect(NetworkClient.java:180) ~[?:?]
	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.HPPrinterHandler.checkStatus(HPPrinterHandler.java:263) ~[?:?]
	at org.openhab.binding.hpprinter.internal.handler.HPPrinterHandler.lambda$1(HPPrinterHandler.java:211) ~[?:?]
	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) [?:?]

Awesome glad to hear it worked. Thank you for testing it out and providing information about your printer model; much appreciated.

I’ll get it fixed up regarding when the printer is turned off so your logs don’t get spammed, I’ll try to get to this in the next day or two - I’ll let you know when that’s done so you can grab the updated version for testing.

@Cossey
I tried with both versions of the jar above. Neither worked for me and my HP OfficeJet Pro 8730 on wifi connection… I tried the 8710 but also the two models you added to the second jar.

The output of DevMgmt/ProductUsageDyn.xml was too big to embed:

And this from DevMgmt/ProductStatusDyn.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- THIS DATA SUBJECT TO DISCLAIMER(S) INCLUDED WITH THE PRODUCT OF ORIGIN. -->
<psdyn:ProductStatusDyn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/" xmlns:ad="http://www.hp.com/schemas/imaging/con/ledm/alertdetails/2007/10/31" xmlns:pscat="http://www.hp.com/schemas/imaging/con/ledm/productstatuscategories/2007/10/31" xmlns:locid="http://www.hp.com/schemas/imaging/con/ledm/localizationids/2007/10/31" xmlns:psdyn="http://www.hp.com/schemas/imaging/con/ledm/productstatusdyn/2007/10/31" xsi:schemaLocation="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/ ../schemas/dd/DataDictionaryMasterLEDM.xsd http://www.hp.com/schemas/imaging/con/ledm/alertdetails/2007/10/31 ../schemas/AlertDetails.xsd http://www.hp.com/schemas/imaging/con/ledm/productstatuscategories/2007/10/31 ../schemas/ProductStatusCategories.xsd http://www.hp.com/schemas/imaging/con/ledm/localizationids/2007/10/31 ../schemas/LocalizationIds.xsd http://www.hp.com/schemas/imaging/con/ledm/productstatusdyn/2007/10/31 ../schemas/ProductStatusDyn.xsd">
	<dd:Version>
		<dd:Revision>SVN-IPG-LEDM.216</dd:Revision>
		<dd:Date>2011-02-08</dd:Date>
	</dd:Version>
	<psdyn:Status>
		<pscat:StatusCategory>inPowerSave</pscat:StatusCategory>
		<locid:StringId>65640</locid:StringId>
	</psdyn:Status>
	<psdyn:AlertTable>
		<dd:ModificationNumber>12</dd:ModificationNumber>
	</psdyn:AlertTable>
</psdyn:ProductStatusDyn>

Cheers!

1 Like

Thanks for taking the time to test @marklavercombe. Firstly, can you clarify if your EWS uses http or https?

Second, did you manually configure the Thing? At the moment this binding does not support auto-detection.

Sorry. Yes, added Thing via paper UI. Shows in paper UI. No data in logs (other than initialising the Thing).

OH 2.3- would that be an issue?

EWS is http://ip

Please use karaf to set log level to TRACE for the binding. At the moment nothing gets recorded at any other log level aside from DEBUG. I just don’t know if openHAB 2.3 would be the issue as I am building against the 2.5 repos, but I do know it works in 2.4

The 8710 is configured to use HTTPS so you probably will get failed connections when trying to use it since it is specifically looking for HTTPS://IP vs HTTP://IP

Do you have the latest firmware installed for your printer?
Does your EWS have an admin password set?

I would have thought the 8730 would be on HTTPS since my 8710 is… I’ll add in your model printer and add configure the model for HTTP to see how it works. Please give me about 10 minutes; I’ll update this post.

Hi again.
I updated my printer to latest firmware.
Am now seeing correct status updates in paper ui. No ink levels though??

I guess this means it is using https, sorry.

Awesome news, seems like the latest firmware for these printers uses HTTPS. I will have to change how the configuration works regarding an option for SSL. I’m looking into the printer ink levels now to see what might be going on. Have you set your logging level to debug and are you seeing any ink values in the logs?

Sorry, have just gone to bed. I’ll have to get that to you tomorrow. Thanks for your work on this, really looking forward to seeing the finished product!

More updates!

First off, you will have to remove any already added Things as I have changed the way the configuration works!

When configuring the binding there is now a useSSL option, which defaults to true. You must set this to false if your EWS uses http, if it uses https make sure it is set to true.

Remember you will still have to manully add the Thing, still no auto-detection, that’s a bit lower on the priority list at the moment.

@marklavercombe I’ve fixed the issue with ink levels not displaying on your model. Thanks for your feedback. I had the function processing other values which don’t exist in your xml and was causing it to error before it was updating the ink values.

@vzorglub I’ve updated the Binding now so that it should gracefully handle whenever the printer is turned off, it should update the Thing to Offline and show Offline in the status channel. This should stop it from spamming your logs. However if you do catch it doing this still, let me know. This should be in an acceptable state for you to use it now.

@ljsquare I suspect this should also work for you now too let me know if you run into problems.

The download link is the same as before - LINK NO LONGER AVAILABLE

Manual Thing config if you cannot use Paper UI to add it:
Thing hpprinter:deskjet2620:djprinter "Printer" @ "Office" [ ipAddress="192.168.1.1", refreshInterval="30", useSSL = true ]

useSSL = false if using http
Use one of deskjet2620 or officejet8710 or officejet8730 or envyphoto6200 values for the Thing type.

If someone new is trying this Binding and your model isn’t listed, try using one of the existing Things nearest to your model first and see how you go with that, otherwise try each of the Things and see what works.

1 Like

Confirmed now working for 8730! Thanks @Cossey

From null

Hello -

I have an HP OfficeJet 8600 and would like to test.

Here are the results of the two urls…

HP8600_ProductUsageDyn.xml (33.9 KB)
HP8600_ProductStatusDyn.xml (1.5 KB)

What else do I need to provide?

I also have a HP Laser Printer but received 404 file not found errors when trying the urls provided.

Thanks,

Squid

1 Like

Hey @KidSquid, you should be able to use the Binding with your OfficeJet , you can just use either the OfficeJet 8710 or 8730 Thing. If you go to the web interface of your printer, you’ll be able to see if it goes to http or https, so you’ll know what to set useSSL to (http, set to off, https, set to on). Just follow the instructions from my previous post and use Paper UI to add the binding if you are able to.

If you do get http:// instead of https:// it probably means that you have a firmware update to install on your printer as we discovered previously in this thread.

For the Laser printer, can you go to its web interface and find if there’s a page that shows it’s toner levels and/or printer status then save the web page to file and link it here? (in Google Chome, the 3 vertical dots menu > More Tools > Save Webpage As…). I’ll look through it and see if it goes off and tries to pull down information from a different file; it may just display the information right in the page instead (which is still fine as I should be able to “scrape” that page for information). I may need to get further files from you if it goes off to another location to get that information.

On an unrelated note: Did you get a chance to try the Onkyo TX-NR545 Binding that I posted to Issue #2922? If that works for you can you let me know? Even if it still requires to be manually added? Thanks!

@marklavercombe Pro! Now I need to figure out how to get the reboot channel to work (when clicking on it in Paper UI it doesn’t stay checked so probably something I need to do in code for it).

Works great, thanks
This logging

2019-01-08 08:02:20.399 [INFO ] [er.internal.handler.HPPrinterHandler] - HP Printer hpprinter:deskjet2620:Printer has gone offline

Could be removed though, a bit unnecessary

Thanks a lot!

Little bug…

I turned off the printer - No more log spamming - Thing goes OFFLINE perfect
I turn on the printer:

2019-01-08 08:15:02.197 [hingStatusInfoChangedEvent] - 'hpprinter:deskjet2620:Printer' changed from OFFLINE to ONLINE
==> /var/log/openhab2/openhab.log <==
2019-01-08 08:15:02.192 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
java.lang.NullPointerException: null
	at org.openhab.binding.hpprinter.internal.handler.HPPrinterHandler.lambda$1(HPPrinterHandler.java:262) ~[?:?]
	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-08 08:15:02.242 [vent.ItemStateChangedEvent] - Printer_Status changed from Offline to Idle

Hmmmm I thought I removed that, I’ll make sure that’s gone in the next release.

Odd, I didn’t get that issue in my logs, I’ll look into it, that’s probably due to my Java noobness because I set that scheduler to null when I cancel it. Does it only happen once when the Thing comes back online or does it happen every 15 seconds after it comes back?

Thanks!

Only once,

And this logging:

2019-01-08 10:03:31.950 [INFO ] [er.internal.handler.HPPrinterHandler] - HP Printer hpprinter:deskjet2620:Printer has gone offline
2019-01-08 10:04:11.886 [INFO ] [er.internal.handler.HPPrinterHandler] - HP Printer hpprinter:deskjet2620:Printer has gone offline

Repeats every two minutes or so but not regular

Hi

I was wanting to test this binding against my printer, so I downloaded the jar file a few days ago and dropped it in my addons directory. All was good and I could create a thing.

After doing some testing, I’ve gone to update to the latest download. I’ve removed the old jar file from the addons directory, but the option to create a thing from the binding still exists in PaperUI and still shows on a bundle:list in karaf… I’ve tried restarting OpenHAB and rebooting the server but there’s no change.

Any ideas why the system seems to think the binding is installed even though the jar file is no longer present?