Add CDM (JSON) API support for newer HP+ printers - #213
Open
HummelsTech wants to merge 2 commits into
Open
Conversation
Newer HP+ models (e.g. Envy 6020e/6420e/6520e "6500e series") no longer
expose the legacy LEDM XML endpoints (/DevMgmt/*.xml return 404) and
instead serve a JSON-based CDM API under /cdm/.
- Auto-detect API variant (LEDM vs CDM) during config flow and setup;
detected variant is stored in the config entry, existing LEDM
entries keep working unchanged
- New parameters/data_points_cdm.json mapping CDM resources onto the
existing property keys (identity, system status, suppliesPublic,
deviceUsage lifetimeCounters) so translations and entity naming are
reused as-is
- REST client: parse application/json responses, support root-level
("") data paths, variant-aware status/main endpoints and offline
payload
- New device_status states (idle, initializing, starting,
shuttingdown, error, down) with EN/NL translations
- utils/api_test.py: variant-aware main endpoint, print extracted
data, Windows selector event loop fix
Tested end-to-end against an HP Envy 6520e (auto-detect cdm, status,
both cartridges incl. levels, print/copy/scan counters).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reorder CDM data points so the Printer device exists before consumable devices reference it as via_device (fixes HA warning about a non-existing via_device, which becomes an error in HA 2025.12). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Good news! |
Author
Glad to know thanks for your feedback |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Newer HP+ models (e.g. Envy 6020e/6420e/6520e — reported as "HP Envy 6500e series") no longer expose the legacy LEDM XML endpoints: every
/DevMgmt/*.xmlrequest returns 404, so the config flow fails with "Unsupported API". These printers instead serve a JSON-based CDM API under/cdm/(HTTPS; port 80 redirects to 443).This PR adds CDM support while keeping LEDM fully intact:
api_variant); existing LEDM entries have no such key and keep working unchanged (variant is re-detected at setup when missing).parameters/data_points_cdm.jsonmapping CDM resources onto the same property keys as the LEDM data points, so all existing translations, entity descriptions and device naming are reused as-is:/cdm/system/v1/identity→ Main (model, SKU, serial, product number)/cdm/system/v1/status→device_status(10s interval, same enum sensor; new statesidle,initializing,starting,shuttingdown,error,downadded with EN/NL translations)/cdm/supply/v1/suppliesPublic→ Consumables (level %, level state, brand, slot, install/manufacture dates, selectability number, serial, unique id), identified bysupplyColorCode(K/CMY) matching the LEDM label codes/cdm/deviceUsage/v1/lifetimeCounters→ Printer / Copy / Scanner page countersapplication/jsonresponses next toapplication/javascript/XML, support root-level ("") data paths, and use variant-aware status/main endpoints and offline payload (via newHAConfigManagerproperties instead of the hardcoded constants).via_deviceexists when cartridge devices are created (avoids the HA "non existing via_device" warning that becomes an error in HA 2025.12).utils/api_test.py: variant-aware main endpoint, prints extracted data, and a Windows selector-event-loop fix.Probably helps with #176 and similar "Unsupported API" reports for devices that expose the CDM API.
Testing
Tested end-to-end against a live HP Envy 6520e (firmware 6.22.5.27):
utils/api_test.pywith noapi_variantset → detectscdm, extracts Main/Status/Consumables/Printer/Copy/Scanner data correctlyinPowerSave→ translated), both cartridges incl. levels/dates, print/copy/scan counters_get_data_sectiononly short-circuits on empty paths, which LEDM never uses)The manifest version bump to 2.1.0 and the CHANGELOG entry are included for completeness — happy to drop or adjust those if you prefer to manage versioning yourself.
🤖 Generated with Claude Code