Skip to content

Add HKSV 17.99 camera services and characteristics to the catalog - #531

Closed
RaHehl wants to merge 2 commits into
ikalchev:devfrom
RaHehl:hksv3-catalog
Closed

RaHehl wants to merge 2 commits into
ikalchev:devfrom
RaHehl:hksv3-catalog

Conversation

@RaHehl

@RaHehl RaHehl commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Adds the 8 services and 27 characteristics from Apple's HomeKit Secure Video Open Source Compatibility Guide (Developer Preview 1.0) to services.json / characteristics.json. Two of them, Contributing Sensors and Motion Enabled, also become optional on Motion Sensor. Admin-only writes are stored as "AdminOnlyAccess": ["write"] like HAP-NodeJS; not sent to controllers and not enforced yet.

Second commit fixes perms on three existing characteristics to match the guide and HAP-NodeJS: Third Party Camera Active is read/notify only, Night Vision and Camera Operating Mode Indicator get tw. pyhap's Camera doesn't use these three; accessories that add them now advertise the new perms.

Tests pin every entry to the guide's tables.

References:

Add the eight services and 27 characteristics of Apple's HomeKit Secure
Video Open Source Compatibility Guide (Developer Preview 1.0) to the
loader resources. Two of them, Contributing Sensors and Motion Enabled,
also become optional characteristics of the Motion Sensor service.

Timed write is advertised where the guide requires it. Writes to Motion
Enabled and Streaming Enabled are marked admin only with an
"AdminOnlyAccess": ["write"] catalog property. It is not part of the HAP
representation and not enforced yet.

Camera Recording Management keeps the characteristics classic recording
relies on.
Third Party Camera Active is state the camera reports, so controllers
read and subscribe to it but do not write it. Night Vision and Camera
Operating Mode Indicator are written with timed writes. The Camera
Global Operating Mode service of HKSV 17.99 uses all three. This
matches the definitions in HAP-NodeJS.
@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.38%. Comparing base (3a2c764) to head (207041c).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #531   +/-   ##
=======================================
  Coverage   90.38%   90.38%           
=======================================
  Files          26       26           
  Lines        3796     3796           
  Branches      458      458           
=======================================
  Hits         3431     3431           
  Misses        258      258           
  Partials      107      107           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ikalchev added a commit that referenced this pull request Nov 10, 2026
* Rewrite gen_hap_types.py to use macOS HomeKitDaemon metadata

Regenerates the characteristics/services catalog from Apple's
plain-metadata.config (ships with macOS, updated with every OS release)
instead of the Xcode HomeKit Accessory Simulator plist, which lags far
behind (163 chars / 48 services vs 242 / 69). Mirrors the approach of
HAP-NodeJS's generate-definitions.ts:

- plain-metadata.config is the primary source (no Xcode required)
- the simulator plist is used as an optional overlay (richer permission
  strings, ValidValues constraints) when installed
- scripts/hap_manual_overrides.json holds hand-maintained additions and
  overrides for things not yet in Apple's machine-readable metadata
  (seeded with the HKSV 17.99 definitions, incl. the PR #531 content)
- names and required/optional lists are stable across regenerations:
  UUID-based name resolution plus inheritance rules prevent Apple's
  description drift and required->optional demotions from breaking
  existing accessories; ValidValues suppress numeric min/max so invalid
  values are rejected instead of silently clamped
- dry-run by default with an add/remove/change report; --write to apply

The regenerated catalogs add 108 characteristics and 30 services
(AccessCode, Thread, Siri, WebRTC/HKSV 17.99, power management, etc.).

* gen_hap_types: require simulator plist, add --allow-missing-simulator

Error out when the HomeKit Accessory Simulator plist is missing instead
of silently degrading: without the overlay, ValidValues for newly added
characteristics would be missing and permissions fall back to the
coarser bitmask. --allow-missing-simulator proceeds explicitly with a
loud warning; existing characteristics remain covered by field
inheritance.

* loudly fail if simulator is missing

* gen_hap_types: simulator plist contributes ValidValues only

The Additional Tools simulator plist turned out to work differently
from the old Xcode-bundled one: its Permissions list holds auth flags
(securedRead/securedWrite) and the read/write/notify strings live in
Properties - so mapping Permissions to pr/pw/ev emptied every permission
list, and the plist no longer carries numeric constraints either.

Mirror HAP-NodeJS's generator: permissions and min/max/step come
exclusively from plain-metadata.config; the simulator plist is used
only for enumerated ValidValues ({value: state} reversed to
{state: value}), falling back to inheritance from the previous catalog
per characteristic. Also autodetect the simulator at both install
locations (with and without the Xcode nested Applications folder).

* Mirror HAP-NodeJS's corrections of Apple metadata quirks

Diffing the regenerated catalog against HAP-NodeJS's generated
definitions (V=889) surfaced deliberate fixes they carry in their
CharacteristicOverriding config, which our catalog needs too:

- WRITE_RESPONSE on the five control-point characteristics
  (AccessCodeControlPoint, NFCAccessControlPoint, TransitionControl,
  DataStreamHAPTransport, SetupDataStreamTransport)
- uint8 format for HomeKitCameraActive/EventSnapshotsActive/
  PeriodicSnapshotsActive - the HKSV 17.99 guide and HAP-NodeJS both
  define them as uint8 while plain-metadata.config says bool
- CurrentTemperature minValue -270 (spec minimum; metadata says 0 which
  clamps negative readings to 0)
- LockLastKnownAction values 9/10 from the newer HAP spec

Also regenerated with the simulator plist overlay now active.

* gen_hap_types: refresh docstrings for the ValidValues-only overlay

- the simulator overlay now contributes ValidValues only (permissions
  always come from the plain-metadata bitmask), so drop the stale
  'coarser bitmask fallback' wording
- field inheritance applies per characteristic, not only when the
  simulator is missing entirely
- document the three stability rules (UUID-based naming, required/optional
  service inheritance, ValidValues suppressing min/max) and the metadata
  corrections carried in characteristicOverrides

* Type-annotate gen_hap_types.py and bring it under ruff and ty

Add full type annotations (catalog/entry/Apple-metadata aliases) to the
generator and bring it into the lint scope:

- tox.ini: ruff check/format now also cover scripts/gen_hap_types.py
  (scripts/pickle_to_state.py keeps its pre-existing violations and
  stays out of scope)
- pyproject.toml: add "scripts" to [tool.ty.src]

Fixes surfaced by the tools: import sorting, long docstring/signature
lines, an overwritten loop variable in the ValidValues conversion, an
unused loop variable, and the untyped "_slug_to_name" hack - the slug
-> name table is now passed as a separate, properly typed parameter.
Generator output is unchanged (dry run reports 0/0/0).
@ikalchev

Copy link
Copy Markdown
Owner

@RaHehl this is superseded by #539 as it pull as new definitions + adds an override file with the contents of this change. Let me know if I messed something up.

@ikalchev ikalchev closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants