Skip to content

openHAB and HP printer

Recent openHAB versions come with a new HP Printer Binding, which is a big improvement over the more general IPP Binding for printers.

The new binding reads the data from two files which are provided by the printer:

  • http://<printer>/DevMgmt/ProductUsageDyn.xml
  • http://<printer>/DevMgmt/ProductStatusDyn.xml

Let's install that ...

 

First the binding must be installed, I use an Ansible Playbook which can do that for me:

- name: Get list of available and installed extensions
  uri:
    url: "http://{{ ansible_host }}:8080/rest/extensions"
  register: oh2_extensions
  changed_when: false

- name: Install extensions
  uri:
    url: "http://{{ ansible_host }}:8080/rest/extensions/{{ item }}/install"
    method: POST
  when: "not (oh2_extensions.json|byattr('id', item))[0].installed"
  with_items:
    - binding-hpprinter
  register: oh2_install_extensions

$ansible_host holds my IP address for the Raspberry Pi running the openHAB system. The two Tasks first fetch existing and installed extensions, and then install any missing extension from the list (here it's only one extension for this case).

After that's done, one can either use the Paper UI to configure the binding - or deploy Things and Items again using Ansible. Which has the advantage that I can reinstall the entire system at any time.

First things first, the "printers.things" file:

Thing		hpprinter:printer:laserjet_pro "HP Color LaserJet" @ "Office" [ ipAddress="<ip>", usageInterval="30", statusInterval="4" ]

"laserjet_pro" can be changed to any name, the only requirement is that the same name must be used for the Items later on. And replace "<ip>" with the IP-address of the printer.

Then the "printers.items" file:

String			HPLJStatus			"Status"				{ channel="pprinter:printer:laserjet_pro:status#status" }

Switch			HPLJTrayOpen			"Tray Open"				{ channel="pprinter:printer:laserjet_pro:status#trayEmptyOrOpen" }
Switch			HPLJScannerStatus		"Scanner Status"			{ channel="pprinter:printer:laserjet_pro:status#scannerStatus" }
Switch			HPLJADFLoaded			"ADF Loaded"				{ channel="pprinter:printer:laserjet_pro:status#scannerAdfLoaded" }

Number:Dimensionless	HPLJBlackLevel			"Black Level"				{ channel="hpprinter:printer:laserjet_pro:ink#blackLevel" }
Number:Dimensionless	HPLJColorLevel			"Color Level"				{ channel="hpprinter:printer:laserjet_pro:ink#colorLevel" }
Number:Dimensionless	HPLJCyanLevel			"Cyan Level"				{ channel="hpprinter:printer:laserjet_pro:ink#cyanLevel" }
Number:Dimensionless	HPLJMagentaLevel		"Magenta Level"				{ channel="hpprinter:printer:laserjet_pro:ink#magentaLevel" }
Number:Dimensionless	HPLJYellowLevel			"Yellow Level"				{ channel="hpprinter:printer:laserjet_pro:ink#yellowLevel" }

Number			HPLJTotalPages			"Total Pages"				{ channel="hpprinter:printer:laserjet_pro:usage#totalCount" }

...

The documentation for the Binding lists a number of additional channels, but not every of them will work for every printer.

The channel name must include the same name chosen for the Thing in printers.things. After sending everything to the openHAB installation, the event.log will show that the available channels come online and can be used.

  • Twitter
  • Bookmark openHAB and HP printer at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg openHAB and HP printer
  • Bloglines openHAB and HP printer
  • Technorati openHAB and HP printer
  • Fark this: openHAB and HP printer
  • Bookmark openHAB and HP printer at YahooMyWeb
  • Bookmark openHAB and HP printer at Furl.net
  • Bookmark openHAB and HP printer at reddit.com
  • Bookmark openHAB and HP printer at blinklist.com
  • Bookmark openHAB and HP printer at Spurl.net
  • Bookmark openHAB and HP printer at Simpy.com
  • Bookmark openHAB and HP printer at blogmarks
  • Bookmark openHAB and HP printer with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options