Skip to main content

ha-franklin

License Code style: black GitHub last commit (branch) Downloads

Table of Contents

Background

I wanted a non-toy test example of using the ha-mqtt-discoverable module.

ha-franklin will monitor CUPSD print queues, and present a binary sensor to Home Assistant over MQTT showing whether the printer is printing.

I use this to turn the smart switch for the HP 4050N in the basement on and off so that by the time I walk downstairs from my office after printing something, Home Assistant has turned on the power to the printer and the job has at least started printing.

Usage

Configuration

Create a config file (yaml) with a list of dictionaries in it. Each dictionary should have the following keys:

  • mqtt_server: DNS name or a raw IP.
  • mqtt_user: the_mqtt_user
  • mqtt_password: the_mqtt_password
  • name: Franklin@cupsd
  • unique_id: printername-cupsd
  • cupsd_queue_name: Queue_name_on_cupsd_server
  • cupsd_server: cupsd.example.com
  • check_interval: 10

The easiest way to create a configuration file is to start by copying config/config-example.yaml and editing it to fit.

Running the Monitor

I recommend using docker, nerdctl or podman to run the tooling in a container.

docker run -v "$(pwd)/config":/config --rm unixorn/ha-franklin ha-cupsd-monitor-queues --settings-file /config/config.yaml

Home Assistant

The container will create a set of MQTT topics using Home Assistant's MQTT discoverability protocol so that your print queue's printing status shows up in Home Assistant.

I set up two automations - one to turn on the peanut plug my HP 4050N is plugged into when jobs appear in the cupsd queue when the sensor turns to on, and a second that turns it off once the sensor switches back to off for ten minutes.

I give it ten minutes for a couple of reasons:

First, because CUPSD will report the queue as done printing when all the postscript has been spooled to the printer. Depending on the complexity of the print job, it may take a minute or two to print the last few pages of the job, even though cupsd considers it complete. If the power gets turned off too soon, you can lose the last page or two of the job, and more annoyingly, cause a printer jam if the power cuts off while a page is moving through the paper path.

Secondly, because although I print rarely, when I do, I typically print several things within a few minutes and I'd prefer to not toggle the printer on and off more than is strictly necessary.

Metadata

Release files for ha-franklin 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ha-franklin 0.1.2
File Size Uploaded Provenance
ha_franklin-0.1.2.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ha-franklin 0.1.2
File Interpreter ABI Platform
ha_franklin-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / ha_franklin-0.1.2.tar.gz

Download URL ha_franklin-0.1.2.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
529621a32f1facaeb923f50c3ee10e3e5ba2a83224203ef3bf8d80fcaa2718ff
BLAKE2b-256 checksum
How to use checksums
88c07b070696798886cc427799d8b20935a84597f86153b29fae8c7630a35e54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.6 Linux/5.15.0-1034-azure

Release files / ha_franklin-0.1.2-py3-none-any.whl

Download URL ha_franklin-0.1.2-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1601547f507f2e44e1597d85e8a971eb23bcdb8f2115a5f3a6e84bae102d01d
BLAKE2b-256 checksum
How to use checksums
2523d7471f86fb15f5295f62158d18de7c55516fcaa90c19d1c15a0c6fd4c63d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.6 Linux/5.15.0-1034-azure

Security for ha-franklin 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page