Epson Expression Inket printer using HTTP Binding

While learning the new OH3 HTTP Binding I have managed to pull some of the details across from my Epson XP-352 printer web UI and thought it might be of use to others.

I expect it would work for other Epson Expression printers. Feedback good or bad appricated. Enjoy :slight_smile:

epson.things

Thing http:url:epson352 [ 
        baseURL="http://X.X.X.X/PRESENTATION/HTML/TOP/PRTINFO.HTML", 
        refresh=300,
        commandMethod="GET" ] 
{
// Other local URLs that could be used for additional details
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_PRTINFO/TOP
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_NWINFO/TOP
    
    Channels:    
       Type string : status           [ mode = "READONLY", stateTransformation = "REGEX:.*PRTSCN_STATUS.+?ce\">(.*?)<\\/div>.*" ]
       Type number : inkLevelC        [ mode = "READONLY", stateTransformation = "REGEX:.*Ink_C.+?='(.*?)'.*" ]
       Type number : inkLevelM        [ mode = "READONLY", stateTransformation = "REGEX:.*Ink_M.+?='(.*?)'.*" ]
       Type number : inkLevelY        [ mode = "READONLY", stateTransformation = "REGEX:.*Ink_Y.+?='(.*?)'.*" ]
       Type number : inkLevelK        [ mode = "READONLY", stateTransformation = "REGEX:.*Ink_K.+?='(.*?)'.*" ]
       Type string : deviceName       [ mode = "READONLY", stateTransformation = "REGEX:.*Device Name.+?\">(.*?)<\\/td>.*" ]
       Type string : connectionStatus [ mode = "READONLY", stateTransformation = "REGEX:.*Connection Status.+?\">(.*?)<\\/td>.*" ]
       Type string : signalStrength   [ mode = "READONLY", stateTransformation = "REGEX:.*Signal Strength.+?\">(.*?)<\\/td>.*" ]
       Type string : macAddress       [ mode = "READONLY", stateTransformation = "REGEX:.*MAC Address.+?\">(.*?)<\\/td>.*" ]
       Type string : ipAddress        [ mode = "READONLY", stateTransformation = "REGEX:.*IP Address.+?\">(.*?)<\\/td>.*" ]
       // There is a lot more network information that could be scraped from the prtinfo.html page if requred.     
}

epson.items

String   Epson352Status           "Status [%s]"              <status>   {channel="http:url:epson352:status", expire="301s,state=Offline"}
Number   Epson352InkLevelC        "Cyan Ink Level [%.0f/50]"    <rgb>   {channel="http:url:epson352:inkLevelC"}
Number   Epson352InkLevelM        "Magenta Ink Level [%.0f/50]" <rgb>   {channel="http:url:epson352:inkLevelM"}
Number   Epson352InkLevelY        "Yellow Ink Level [%.0f/50]"  <rgb>   {channel="http:url:epson352:inkLevelY"}
Number   Epson352InkLevelK        "Black Ink Level [%.0f/50]"   <rgb>   {channel="http:url:epson352:inkLevelK"}
String   Epson352DeviceName       "Device name [%s]"         <keyring>  {channel="http:url:epson352:deviceName"}
String   Epson352ConnectionStatus "Connection status [%s]"   <network>  {channel="http:url:epson352:connectionStatus", expire="301s,state=Offline"}
String   Epson352SignalStrength   "Signal Strength [%s]" <qualityofservice> {channel="http:url:epson352:signalStrength", expire="301s,state=Offline"}
String   Epson352IpAddress       "IP address [%s]"         <network>  {channel="http:url:epson352:ipAddress"}
String   Epson352MacAddress       "MAC address [%s]"         <network>  {channel="http:url:epson352:macAddress"}

DateTime Epson352LastUpdated "Last updated [%1$td/%1$tm/%1$ty %1$tH:%1$tM]" <time> {channel="http:url:epson352:status" [profile="timestamp-update"] }

.sitemap

Frame label="Printer" {
 Default item=Epson352Status
 Slider item=Epson352InkLevelC maxValue=50
 Slider item=Epson352InkLevelM maxValue=50
 Slider item=Epson352InkLevelY maxValue=50
 Slider item=Epson352InkLevelK maxValue=50 
 Default item=Epson352DeviceName
 Default item=Epson352ConnectionStatus  
 Default item=Epson352SignalStrength 
 Default item=Epson352IpAddress 
 Default item=Epson352MacAddress 
 Default item=Epson352LastUpdated   			
}		
2 Likes

Exactly what im looking for!

I use it with Pushover to inform about collorlevel at low level…

refresh=300 mean 5 Minutes?

This is realy nice!
I already managed to grab the ink levels (most important), but I’m struggeling with the other things.
eg, the device name

<td class="item-key"><bdi>Device Name</bdi>&nbsp;:</td>
<td class="item-value">EPSON2CD0CB</td>

I don’t get any vaues with this transformation:
REGEX:.*Device Name.+?\">(.*?)<\\/td>.*

300 seconds indeed

Hi,

I do’nt realy understand that REGEX ?\">(.*?)<\\/td>.* hieroglyph :rofl:. My Epson have 2 black cartridges and i did’nt get it with REGEX.

When i’m home i will show my solution…

ok, my HTML looks like this. Because it includes 2times “/Ink_K.PNG” i had problems using REGEX

<li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_K.PNG' height='3' style=''>
</div>
<div class='clrname'>BK</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_C.PNG' height='2' style=''>
<img class='inkst' src='../../IMAGE/Icn_low.PNG' height='22' width='22'>
</div>
<div class='clrname'>C</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_Y.PNG' height='4' style=''>
</div>
<div class='clrname'>Y</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_M.PNG' height='4' style=''>
</div>
<div class='clrname'>M</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_K.PNG' height='5' style=''>
</div>
<div class='clrname'>PBK</div>
</li>

what have i done… using JS!
For evey Item i put a little FILE.JS in transform Folder.

to get Black epsonBK.js

(function(html) {
    return html.split("Ink_K.PNG' height='")[1].split("'")[0] * 2; 
})(input)

to get PhotoBlack epsonPBK.js

(function(html) {
    return html.split("Ink_K.PNG' height='")[2].split("'")[0] * 2;  
})(input)

Because of “DeviceName”
my html looks like this, language depending its “Printer Name”
for engl → baseURL=“http://xxx.xxx.xxx.xxx/PRESENTATION/HTML/TOP/PRTINFO.HTML?SEL_LANGB=1”,

<table style="border-collapse: collapse; width: 100%;">
<tr class="item clearfix"><td class="item-key"><bdi>Printer Name</bdi>&nbsp;:</td><td class="item-value">EPSON8130AB</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Connection Status</bdi>&nbsp;:</td><td class="item-value">100BASE-TX Full Duplex</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Obtain IP Address</bdi>&nbsp;:</td><td class="item-value">Auto</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>IP Address</bdi>&nbsp;:</td><td class="item-value">192.168.188.26</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Subnet Mask</bdi>&nbsp;:</td><td class="item-value">255.255.255.0</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Default Gateway</bdi>&nbsp;:</td><td class="item-value">192.168.188.1</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>DNS Server Setting</bdi>&nbsp;:</td><td class="item-value">Auto</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Primary DNS Server</bdi>&nbsp;:</td><td class="item-value">192.168.188.1</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Secondary DNS Server</bdi>&nbsp;:</td><td class="item-value">&nbsp;</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>Proxy Server</bdi>&nbsp;:</td><td class="item-value">Do Not Use
</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>File Sharing</bdi>&nbsp;:</td><td class="item-value">Enable</td></tr>
<tr class="item clearfix"><td class="item-key"><bdi>File Sharing Mode</bdi>&nbsp;:</td><td class="item-value">Read/Write</td></tr>
<tr class="item-last clearfix"><td class="item-key"><bdi>MAC Address</bdi>&nbsp;:</td><td class="item-value">9C:AE:D3:81:30:AB</td></tr>
</table>

and JS for DeviceName is epsonName.js

(function(html) {
    return html.split("<bdi>Printer Name</bdi>")[1].split("item-value")[1].split(">")[1].split("<")[0] ; 
})(input)

the File.things

Thing http:url:epson [ 
        baseURL="http://xxx.xxx.xxx.xxx/PRESENTATION/HTML/TOP/PRTINFO.HTML?SEL_LANGB=1", 
        refresh=280,
        commandMethod="GET" ] 
{
// Other local URLs that could be used for additional details
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_PRTINFO/TOP
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_NWINFO/TOP
    
    Channels:    
       Type number : inkLevelC		[ mode = "READONLY", stateTransformation = "JS:epsonC.js" ]
       Type number : inkLevelM      [ mode = "READONLY", stateTransformation = "JS:epsonM.js" ]
       Type number : inkLevelY      [ mode = "READONLY", stateTransformation = "JS:epsonY.js" ]
       Type number : inkLevelBK     [ mode = "READONLY", stateTransformation = "JS:epsonBK.js" ] 
	   Type number : inkLevelPBK    [ mode = "READONLY", stateTransformation = "JS:epsonPBK.js" ]
       Type string : deviceName     [ mode = "READONLY", stateTransformation = "JS:epsonName.js" ]
//       Type string : connectionStatus [ mode = "READONLY", stateTransformation = "REGEX:.*Connection Status.+?\">(.*?)<\\/td>.*" ]
//       Type string : signalStrength   [ mode = "READONLY", stateTransformation = "REGEX:.*Signal Strength.+?\">(.*?)<\\/td>.*" ]
//       Type string : macAddress       [ mode = "READONLY", stateTransformation = "REGEX:.*MAC Address.+?\">(.*?)<\\/td>.*" ]
//       Type string : ipAddress        [ mode = "READONLY", stateTransformation = "REGEX:.*IP Address.+?\">(.*?)<\\/td>.*" ]
       // There is a lot more network information that could be scraped from the prtinfo.html page if requred.     
}

just works…

Hello,

I am new to the forum, but have read quite a lot so far. I am from Germany and still quite new and inexperienced with Openhab.

About my problem. I have an Epson Ecotank printer and want to read out the basic durucker data via Openhab. I use the following configuration:

  • Openhab 3.4.4 via Docker on Qnap NAS.
  • Bindings HTTP as well as javascript transformation as well as others are installed.

The printer status page is accessible via the browser, the source code is as described in Ronny’s post. I created the Things and JS files as described in Ronny’s post and created corresponding Items. In Openhab, the Things and Items are also displayed as online, but there are no values for all, only ‘NULL’ is output.

The source code from the browser:

<li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_K.PNG' height='45' style=''>
</div>
<div class='clrname'>BK</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_C.PNG' height='43' style=''>
</div>
<div class='clrname'>C</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_Y.PNG' height='43' style=''>
</div>
<div class='clrname'>Y</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_M.PNG' height='43' style=''>
</div>
<div class='clrname'>M</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_K.PNG' height='45' style=''>
</div>
<div class='clrname'>PB</div>
</li><!--
--><li class='tank'>
<div class='tank'>
<img class='color' src='../../IMAGE/Ink_Waste.PNG' height='6' style=''>
</div>
<div class='mbicn'><img src='../../IMAGE/Icn_Mb.PNG' height='18' width='18'></div>

My Epson_Printer.things file:

Thing http:url:epson [ 
        baseURL="192.168.178.44/PRESENTATION/HTML/TOP/PRTINFO.HTML?SEL_LANGB=1",
        refresh=60,
        commandMethod="GET" ] 
{
// Other local URLs that could be used for additional details
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_PRTINFO/TOP
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_NWINFO/TOP
    
    Channels:    
       Type number : inkLevelC	 [ mode = "READONLY", stateTransformation = "JS:epsonC.js" ]
       Type number : inkLevelM      [ mode = "READONLY", stateTransformation = "JS:epsonM.js" ]
       Type number : inkLevelY      [ mode = "READONLY", stateTransformation = "JS:epsonY.js" ]
       Type number : inkLevelBK     [ mode = "READONLY", stateTransformation = "JS:epsonBK.js" ] 
	Type number : inkLevelPBK    [ mode = "READONLY", stateTransformation = "JS:epsonPBK.js" ]
       Type string : deviceName     [ mode = "READONLY", stateTransformation = "JS:epsonName.js" ]
	Type number : inkLevelWaste  [ mode = "READONLY", stateTransformation = "JS:epsonW.js" ]
//       Type string : connectionStatus [ mode = "READONLY", stateTransformation = "REGEX:.*Connection Status.+?\">(.*?)<\\/td>.*" ]
//       Type string : signalStrength   [ mode = "READONLY", stateTransformation = "REGEX:.*Signal Strength.+?\">(.*?)<\\/td>.*" ]
//       Type string : macAddress       [ mode = "READONLY", stateTransformation = "REGEX:.*MAC Address.+?\">(.*?)<\\/td>.*" ]
//       Type string : ipAddress        [ mode = "READONLY", stateTransformation = "REGEX:.*IP Address.+?\">(.*?)<\\/td>.*" ]
       // There is a lot more network information that could be scraped from the prtinfo.html page if requred.     
}

As an an example a JS File for Black Color (epsonBK.js):

(function(html) {
    return html.split("Ink_K.PNG' height='")[1].split("'")[0] * 2; 
})(input)

My Items for the colors and printer name

Number   HTTPURLThingInkLevelC       "Epson ET7750 - Füllstand Cyan"            {channel="http:url:epson:inkLevelC"}
Number   HTTPURLThingInkLevelM       "Epson ET7750 - Füllstand Magenta"         {channel="http:url:epson:inkLevelM"}
Number   HTTPURLThingInkLevelY       "Epson ET7750 - Füllstand Gelb"            {channel="http:url:epson:inkLevelY"}
Number   HTTPURLThingInkLevelBK      "Epson ET7750 - Füllstand Schwarz"         {channel="http:url:epson:inkLevelBK"}
Number   HTTPURLThingInkLevelPBK     "Epson ET7750 - Füllstand Foto-Schwarz"    {channel="http:url:epson:inkLevelPBK"}
Number   HTTPURLThingInkLevelWaste   "Epson ET7750 - Waste Tank "               {channel="http:url:epson:inkLevelWaste"}
String   HTTPURLThingDeviceName      "Epson ET7750 - Druckername"               {channel="http:url:epson:deviceName"}

My things and items in Openhab:

Does anyone have an idea what the error could be. I’ve been trying for days to get this to work, unfortunately without success.

Many thanks and greetings

Hoasi

This might help

Hi Allan,

Thanks for the quick reply.

I also tried it as you described. Unfortunately the result is the same. All values remain empty and are displayed as ‘NULL’.

Also, I have two black ink tanks as well, so I also tried Ronny’s way.

Thanks Hoasi

Hi,

here is a short update on the topic.

After a long time of trying, I finally managed to read the printer data. The problem was that I tried to retrieve the data via a secure connection. But since it was an unsecured connection, that didn’t work. After I put a ‘http://xxx.xxx.xxx.xxx…’ in front of the address it worked.

hing http:url:epson [ 
        baseURL="http://xxx.xxx.xxx.xxx/PRESENTATION/HTML/TOP/PRTINFO.HTML?SEL_LANGB=1",
        refresh=60,
        commandMethod="GET" ] 

Maybe it helps one or the other who has the same problem.

Greetings

Hoasi

Hi All

Hope you can assist me i am trying to get information from my Epson Workforce 630 printer but not mater what i try i cannot get it to work

First of all i am using Openhab 4
HTTP Binding
Configuring the binding through the gui panel
The printer is online
Using the Base URL as described baseURL=“http://xxx.xxx.xxx.xxx/PRESENTATION/HTML/TOP/PRTINFO.HTML?SEL_LANGB=1

But i cannot receive any data
I can access the printers web interface
I am thinking that the URL is incorrect for my printer
any help would be greatly appreciated

Thanks

Geoff

In my case (I have Epson L4160) I modified REGEX by changing

\\/

into

\/

, since the

"\\"

seems not to be a correct escape character for forward slash.
Also I had to change PRTSCN_STATUS into PRT_STATUS in REGEX for “status” channel.
So, for example my status channel looks like this:

Type string : status           [ mode = "READONLY", stateTransformation = "REGEX:.*PRT_STATUS.+?ce\">(.*?)<\/div>.*" ]

Thanks for the reply
I am still having issues not getting any information back from the printer
Just a question if i place this address(http://10.0.2.199/PRESENTATION/HTML/TOP/PRTINFO.HTML) in a web browser will it return any values ??
I have tried and i get this page cant be found

Thanks for your help

I guess It depends on which printer model you have.
Check the other links if any of them works in your case and also make sure your printer IP address and if this IP is accessible within the same LAN network.

// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_PRTINFO/TOP
// http://X.X.X.X/PRESENTATION/ADVANCED/INFO_NWINFO/TOP

With the original link to HTML file, I get web page with the Product Status where you can see status of inks and other information regarding the printer such as device name, mac address etc.
If you can’t reach the above links, perhaps your printer provides some other web UI. You may try to go there manually and then look for the page address that is providing similar information. You may need to modify REGEX in order to get appropriately formatted information into OH items.

Hi Again

I have managed to get some information from my printer using this (http://10.0.2.199/PRESENTATION/HTML/TOP/INDEX.HTML) but i am now struggling with REGEX Transformation for what ever reason some of the output is in Unicode (

IP Address : 10.0.2.199
)
I am by no means an expert and i came up with this expression (Type string : ipAddress [ mode = “READONLY”, stateTransformation = “REGEX:.IP Address='(.?)'.” ]
Where the Unicode is Ip Address
can you help or point me in the right direction

Many thanks

It appears that this web site converted the unicode(“

IP Address : 10.0.2.199
”)

(‘Type string : ipAddress [ mode = “READONLY”, stateTransformation = "REGEX:.IP Address=’(.?)'." ]")

("<table><tbody><tr><td>&#x49;&#x50;&#x20;&#x41;&#x64;&#x64;&#x72;&#x65;&#x73;&#x73;&nbsp;:&nbsp;</td><td>10.0.2.199</td></tr></tbody></table>")

('Type string : ipAddress        [ mode = "READONLY", stateTransformation = "REGEX:.&#x49;&#x50;&#x20;&#x41;&#x64;&#x64;&#x72;&#x65;&#x73;&#x73;=</td><td>'(.*?)'.*" ]")