Posted by
ads' corner
on
Thursday, 2020-06-18 Posted in [Linux][Openhab]
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
- name:Get list of available and installed extensionsuri:url:"http://{{ ansible_host }}:8080/rest/extensions"register:oh2_extensionschanged_when:false- name:Install extensionsuri:url:"http://{{ ansible_host }}:8080/rest/extensions/{{ item }}/install"method:POSTwhen:"not (oh2_extensions.json|byattr('id', item))[0].installed"with_items:- binding-hpprinterregister: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:
1
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.
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.