Skip to content

Commit

Permalink
[hpprinter] Add additional data points and refactoring (openhab#7805)
Browse files Browse the repository at this point in the history
* Remove Binder Event and directly expose handler and move to same package.
Tidy up some code.
Add data points for Scanner function.
* Refactor some items.
* Add scanner and app groups and data points.
* Change HPType to HPProductUsageFeatures.
Add additional feature checks.
Add additional data points for the Scanner.
Additional check for status message in the ProductStatus data.
Only run the status checkers on when the relevant channels are linked.
Check if the tray is open or empty.
Code refactoring.
* Tidy up some warnings.
* Added Pages Remaining Data Points.
Adjust Channel names and also made more channels advanced.
* Add pages remaining data points.
* Make all channels dynamic.
Add scanner data points.
Add copy data points.
Tweaks to some of the channel groups and channel names.

Signed-off-by: Stewart Cossey <stewart.cossey@gmail.com>
  • Loading branch information
Cossey authored May 31, 2020
1 parent f0e8362 commit 6319a3b
Show file tree
Hide file tree
Showing 19 changed files with 1,758 additions and 693 deletions.
110 changes: 77 additions & 33 deletions bundles/org.openhab.binding.hpprinter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Get HP Printer statistics from an _Embedded Web Server_ over Network.

## Supported Things

There is only one thing named `printer`. Channels are added dynamically depending on the type of printer.
There is only one thing named `printer`. All channels are added dynamically depending on the type of printer and its capabilities.

## Discovery

Expand All @@ -27,49 +27,78 @@ Thing hpprinter:printer:djprinter "Printer" @ "Office" [ ipAddress="192.168.1.1"

## Channels

| Channel | Name | Data Type | Dynamic |
| ------------------------------------------ | -------------------- | -------------------- | ------- |
| Printer Status | status | String | no |
| Black Colour Level | blackLevel | Number:Dimensionless | no |
| Colour Level | colorLevel | Number:Dimensionless | yes |
| Cyan Colour Level | cyanLevel | Number:Dimensionless | yes |
| Magenta Colour Level | magentaLevel | Number:Dimensionless | yes |
| Yellow Colour Level | yellowLevel | Number:Dimensionless | yes |
| Black Marking Used | blackMarker | Number:Volume | yes |
| Colour Marking Used | colorMarker | Number:Volume | yes |
| Cyan Marking Used | cyanMarker | Number:Volume | yes |
| Magenta Marking Used | magentaMarker | Number:Volume | yes |
| Yellow Marking Used | yellowMarker | Number:Volume | yes |
| Total Number of Pages Printed | totalCount | Number | no |
| Total Number of Colour Pages Printed | totalColorCount | Number | yes |
| Total Number of Monochrome Pages Printed | totalMonochromeCount | Number | yes |
| Jam Events | jamEvents | Number | yes |
| Mispick Events | mispickEvents | Number | yes |
| Front Panel Cancel Count | fpCount | Number | yes |

> The `colorLevel` is used on Printers that have only a single colour cartridge instead of separate Cyan, Magenta and Yellow cartridges.
| Channel | Group | Name | Data Type |
| ------------------------------------------ | ----------- | --------------------- | -------------------- |
| Printer Status | status | status | String |
| Tray Empty/Open | status | trayEmptyOrOpen | Switch |
| Scanner Status | status | scannerStatus | String |
| ADF Loaded | status | scannerAdfLoaded | Switch |
| Black Colour Level | usage | blackLevel | Number:Dimensionless |
| Colour Level | usage | colorLevel | Number:Dimensionless |
| Cyan Colour Level | usage | cyanLevel | Number:Dimensionless |
| Magenta Colour Level | usage | magentaLevel | Number:Dimensionless |
| Yellow Colour Level | usage | yellowLevel | Number:Dimensionless |
| Black Marking Used | usage | blackMarker | Number:Volume |
| Colour Marking Used | usage | colorMarker | Number:Volume |
| Cyan Marking Used | usage | cyanMarker | Number:Volume |
| Magenta Marking Used | usage | magentaMarker | Number:Volume |
| Yellow Marking Used | usage | yellowMarker | Number:Volume |
| Black Pages Remaining | usage | blackPagesRemaining | Number |
| Colour Pages Remaining | usage | colorPagesRemaining | Number |
| Cyan Pages Remaining | usage | cyanPagesRemaining | Number |
| Magenta Pages Remaining | usage | magentaPagesRemaining | Number |
| Yellow Pages Remaining | usage | yellowPagesRemaining | Number |
| Total Number of Pages Printed Lifetime | usage | totalCount | Number |
| Total Number of Colour Pages Printed | usage | totalColorCount | Number |
| Total Number of Monochrome Pages Printed | usage | totalMonochromeCount | Number |
| Paper Jams | usage | jamEvents | Number |
| Missed Pick Events | usage | mispickEvents | Number |
| Front Panel Cancel Count | usage | fpCancelCount | Number |
| Subscription Count | usage | subscriptionCount | Number |
| Scanner Document Feeder Count | scanner | totalAdf | Number |
| Scanner Flatbed Count | scanner | totalFlatbed | Number |
| Scanner Paper Jams | scanner | jamEvents | Number |
| Scanner Missed Picks | scanner | mispickEvents | Number |
| Scan Document Feeder Count | scan | totalAdf | Number |
| Scan Flatbed Count | scan | totalFlatbed | Number |
| Scan to Email Count | scan | totalToEmail | Number |
| Scan to Folder Count | scan | totalToFolder | Number |
| Scan to Host Count | scan | totalToHost | Number |
| Copy Document Feeder Count | copy | totalAdf | Number |
| Copy Flatbed Count | copy | totalFlatbed | Number |
| Copy Total Pages Count | copy | totalCount | Number |
| Copy Total Colour Pages Count | copy | totalColorCount | Number |
| Copy Total Monochrome Pages Count | copy | totalMonochromeCount | Number |
| Windows Page Count | app | totalWin | Number |
| Android Page Count | app | totalAndroid | Number |
| iOS Page Count | app | totalIos | Number |
| OSX Page Count | app | totalOsx | Number |
| Samsung Page Count | app | totalSamsung | Number |
| Chrome Page Count | app | totalChrome | Number |
| Google Cloud Print Count | other | cloudPrint | Number |

Note:

* All channels are dynamic and will not be added or visible in Paper UI if not supported.
* The word colour in channel names are American spelling ("color").
* The `colorLevel`, `colorMarkingUsed` and `colorPagesRemaining` channels are used on Printers that have only a single colour cartridge instead of separate Cyan, Magenta and Yellow cartridges.
* The `scanner` group is for the Scanning Engine which consists of Scan, Copy and other operations; the `scan` group is for scanner operations only.
* If no `status` group channels are selected, then those relevant data endpoints on the *Embedded Web Server* will not be polled for status information.
* Some channels are *Advanced channels* not selected by default in Paper UI. To add them, click the *Show More* button in the thing configuration.

### Sample Items

```
String PrinterStatus "Status" { channel="pprinter:printer:djprinter:status#status" }
Number PrinterTotalPages "Total Pages" { channel="hpprinter:printer:djprinter:usage#totalCount" }
Number:Volume PrinterBlackMarkingUsed "Black Marking Used" { channel="hpprinter:printer:djprinter:usage#blackMarker" }
Number:Volume PrinterCyanMarkingUsed "Cyan Marking Used" { channel="hpprinter:printer:djprinter:usage#cyanMarker" }
Number:Volume PrinterMagentaMarkingUsed "Magenta Marking Used" { channel="hpprinter:printer:djprinter:usage#magentaMarker" }
Number:Volume PrinterYellowMarkingUsed "Yellow Marking Used" { channel="hpprinter:printer:djprinter:usage#yellowMarker" }
Number:Dimensionless PrinterBlackLevel "Black Level" { channel="hpprinter:printer:djprinter:ink#blackLevel" }
Number:Dimensionless PrinterCyanLevel "Cyan Level" { channel="hpprinter:printer:djprinter:ink#cyanLevel" }
Number:Dimensionless PrinterMagentaLevel "Magenta Level" { channel="hpprinter:printer:djprinter:ink#magentaLevel" }
Number:Dimensionless PrinterYellowLevel "Yellow Level" { channel="hpprinter:printer:djprinter:ink#yellowLevel" }
Number PrinterTotalPages "Total Pages" { channel="hpprinter:printer:djprinter:usage#totalCount" }
Number PrinterTotalColourPages "Total Colour Pages" { channel="hpprinter:printer:djprinter:usage#totalColorCount" }
Number PrinterTotalMonochromePages "Total Monochrome Pages" { channel="hpprinter:printer:djprinter:usage#totalMonochromeCount" }
Number PrinterJamEvents "Jam Events" { channel="hpprinter:printer:djprinter:usage#jamEvents" }
Number PrinterMispickEvents "Mispick Events" { channel="hpprinter:printer:djprinter:usage#mispickEvents" }
Number PrinterSubscriptionCount "Subscription Count" { channel="hpprinter:printer:djprinter:usage#subsciptionCount" }
```

### Sample Sitemap Items
Expand All @@ -80,7 +109,8 @@ Black Ink displayed as a whole percentage - `60 %`
Text item=hpprinter_printer_djprinter_ink_blackLevel label="Black [%.0f %unit%]"
```

Black Marker displayed in millilitres - `21 ml`
Black Marker displayed in millilitres - `21 ml`
*Default*

```
Text item=hpprinter_printer_djprinter_usage_blackMarker label="Black Marker [%.0f %unit%]"
Expand All @@ -90,4 +120,18 @@ Black Marker displayed in litres - `0.021 l`

```
Text item=hpprinter_printer_djprinter_usage_blackMarker label="Black Marker [%.3f l]"
```
```

Black Marker displayed in microlitres - `21000 µl`

```
Text item=hpprinter_printer_djprinter_usage_blackMarker label="Black Marker [%.0f µl]"
```

Scanner Document Feeder loaded with text status display - `ON` or `OFF`

```
Text item=hpprinter_printer_djprinter_status_scannerAdfLoaded label="ADF Loaded [%s]"
```

> If you want the *Scanner Document Feeder* or *Tray Empty/Open* channels to display a different message, you can use the *Map Transformations*. Search for `Map Transformation Service` in the openHAB documentation for more information.
Loading

0 comments on commit 6319a3b

Please sign in to comment.