Repository navigation
Conversation
First step towards a reusable AdaptiveLightingController (issue ikalchev#495): decode the TransitionControl TLV8 schedule the Home app writes, expose the parsed curve and interpolate the current colour temperature and brightness factor at any moment, and serialise the state so a consumer can persist it. No controller or HomeKit service wiring yet. - pyhap.tlv.decode_ordered: TLV8 decode preserving record order, duplicates and empty records (used as list delimiters), rejoining 255-byte chunks - pyhap.adaptive_lighting: variable-width uint codec, TLV helpers, CurveEntry/ActiveTransition model, parse_transition_control / parse_transition_update with injectable clock, interpolate / interpolate_point with hold-duration and brightness-factor interpolation, ActiveTransition.to_dict/from_dict - tests cover the real Home app payload, curve end, hold windows, brightness factor smoothness, malformed writes and state roundtrip Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parse_transition_update now looks up the configuration record by its TAG_CFG_IID tag instead of assuming it is the first record, so updates carrying extra records still parse. decode_ordered documents that rejoining same-tag chunks is a heuristic bounded by the 255-byte length rule and its inherent ambiguity. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
xDhii
marked this pull request as ready for review
December 2, 2026 03:46
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.
Part of #495. This is the first of two PRs: the protocol side of Adaptive Lighting, with no controller wiring yet.
What it adds
pyhap.tlv.decode_ordered: a TLV8 decode that keeps record order, duplicates and empty records. The Adaptive Lighting curve repeats the same tag separated by empty records, whichdecode()collapses into a dict.pyhap.adaptive_lighting: parsing of theTransitionControlwrite (curve points, update interval, notify threshold, multiplier range), interpolation of colour temperature and the brightness adjustment factor at a given time (including thedurationhold), andto_dict/from_dictso a consumer can persist an active transition. The clock is injectable.Not in this PR
The controller that wires this to a Lightbulb service, schedules the updates and persists state. It follows as a second PR once the shape here is agreed.
Where it comes from
The logic is ported from my Home Assistant HomeKit bridge change (home-assistant/core#182265), which has been driving real lights for weeks, with a few extra guards against malformed payloads. Together with the controller in the follow-up PR, this port has been running in my own Home Assistant since December 1st, driving real lights, without errors.
The full test suite and
ruff check/ruff formatpass locally.I used AI assistance (Devin and Claude) to port and test this.