Introducing a new way to review your PRs.

Read the announcement

basnijholt / adaptive-lighting

Adaptive Lighting custom component for Home Assistant

View on GitHub

13 documents · Updated Oct 21, 2026

docs / adaptive-lighting-development-delivery

Adaptive Lighting development and delivery

Adaptive Lighting uses a small set of support systems to keep its Home Assistant integration reliable and ready to share. The systems check the lighting rules across Home Assistant versions, let engineers see a full-day result, and turn one set of integration descriptions into the metadata that Home Assistant and HACS use.

Supporting system boundary

The support systems sit around the integration rather than replace it. The lighting model in custom_components/…/color_and_brightness.py is the shared behavior that the preview app illustrates and the tests check.

The main outputs have different users:

OutputMain userPurpose
Preview plotsEngineers and usersShow how brightness and color change through a day.
Test resultsMaintainersShow that the integration still works with supported Home Assistant Core versions.
Generated integration metadataHome Assistant and HACSDescribe setup options, services, translations, and package support.
Documentation site and release artifactsUsers and maintainersPublish guidance and deliver the integration and its test image.

This diagram shows how the behavior model moves through preview, checks, metadata generation, and delivery.

flowchart LR
    B[Lighting behavior model]
    B --> P[Preview app]
    B --> T[Home Assistant test suite]
    D[Integration descriptions and validation rules] --> G[Generated metadata]
    T --> V[Validation checks]
    P --> S[Documentation site]
    G --> H[Home Assistant and HACS]
    V --> R[Release and delivery checks]
    R --> A[Published integration and test image]

References: custom_components/…/color_and_brightness.py• L204-401 webapp/app.py• L60-193 .github/…/pytest.yaml• L53-78

Behavior preview

The Adaptive Lighting Simulator is an interactive web app that turns lighting settings into plots. It lets a person change day-night limits, sleep settings, sun times, and brightness ramp times, then compare brightness modes and view the color result across the day.

The app presents two views. One shows brightness over time for the default, linear, and smooth ramp modes. The other shows the RGB color band with the sun position and sunrise or sunset markers. This gives a quick way to inspect a setting before using it in Home Assistant.

The app uses the integration's lighting calculation model instead of a separate approximation. When it runs, it copies the model into the web app's small standalone environment so the preview can run without the full Home Assistant package. Its pinned astronomy and time-zone dependencies are recorded in webapp/requirements.txt for a repeatable preview environment.

See the child page Color and brightness preview app for the preview workflow and its user-facing behavior.

References: webapp/app.py• L32-57 webapp/app.py• L60-193 webapp/app.py• L217-344 webapp/requirements.txt• L1-6 webapp/README.md• L1-10

Behavior verification

Continuous integration (CI) checks the integration as a Home Assistant component. The test job links the repository's component and tests into a checkout of Home Assistant Core, then runs the tests against a version matrix that includes the oldest supported Core line, recent releases, and the development version.

The checks cover more than runtime behavior. HACS validation checks the integration package shape, hassfest checks Home Assistant metadata, and pre-commit checks code and file format rules. The project also keeps generated documentation and integration metadata in sync through a separate check.

The HACS validation workflow runs for pull requests, pushes to master, and a daily schedule in the canonical repository. It does not run on forked repositories, so fork validation depends on the other checks or on a local run.

The Home Assistant Core matrix is maintained by a scheduled job. That job finds stable Core releases, keeps the newest patch for each supported minor release, maps each release to a Python version, and opens a pull request when the matrix changes.

See the child page Validation and release automation for the checks, matrix updates, and delivery jobs.

References: .github/…/pytest.yaml• L1-78 .github/…/action.yml• L13-41 .github/…/validate.yml• L1-19 .github/…/hassfest.yaml• L1-15 .github/…/pre-commit.yaml• L1-14 .github/…/update-test-matrix.yaml• L1-59 scripts/update-test-matrix.py• L18-105

Integration metadata

Integration metadata is the shared description of how Adaptive Lighting is named, configured, called, translated, and packaged. The source descriptions and validation rules are kept with the integration so the Home Assistant service schema and configuration screens use the same terms.

The metadata path has one source and several outputs:

Source or outputRole
const.py descriptions and validation dataDefines option meaning and accepted configuration shape.
services.yamlDescribes the services and their fields to Home Assistant.
strings.json and the English translationDescribes configuration screens and service labels.
manifest.jsonIdentifies the integration, its Home Assistant dependency, version, and runtime requirement.
hacs.jsonTells HACS how to treat the repository and the minimum Home Assistant version.

The metadata update tools rebuild service descriptions and configuration strings from the source descriptions. The generated-content job checks these results in pull requests and updates them after changes land on the main branch. This prevents a new option or service field from having different names or help text in different user interfaces.

References: custom_components/…/const.py• L18-35 custom_components/…/const.py• L37-57 custom_components/…/services.yaml• L1-6 custom_components/…/strings.json• L23-67 .github/update-services.py• L10-27 .github/update-strings.py• L12-70 custom_components/…/manifest.json• L1-12 hacs.json• L1-5

Documentation and release delivery

The documentation workflow builds the Zensical site and exports the simulator as a browser app. It places the simulator below the documentation site at /simulator/, so the written guides and the interactive preview are published as one site.

Delivery also includes the package and its test environment. Release Drafter keeps a release note draft from changes on the main branch, while the Docker workflow builds multi-platform test images and publishes them to GitHub Container Registry for branch, pull request, and version-tag use. A separate sync job copies changes from main to master, which matters because validation and release jobs use both branch names.

References: .github/…/docs.yml• L18-64 .github/…/release-drafter.yml• L1-24 .github/release-drafter.yml• L1-6 .github/…/docker-build.yml• L14-50 .github/…/main-to-master-sync.yml• L1-22

Change checklist

When these files or sections are changed, remember to consider these:

  • When option or service descriptions change in const.py, regenerate services.yaml, strings.json, and the English translation. The generated-content check compares these outputs.
  • When the supported Home Assistant range changes, update the minimum version in hacs.json, the test matrix source rule in scripts/update-test-matrix.py, and the matching workflow matrix.
  • When the lighting calculation contract changes, check both the preview plots and the Home Assistant tests. The preview copies the calculation model into its own runtime.
  • When the site path or simulator export changes, keep the documentation build, simulator integration path, and links to the preview page aligned.
  • When branch or tag delivery rules change, check the main to master sync, release draft trigger, and Docker image tag rules together.

Important failure modes

TriggerConsequenceGuard
Generated service or string files are not rebuilt after source descriptions changeHome Assistant can show old labels or field help even though the source rules changedThe generated-content workflow runs the update tools and fails pull requests when the tree changes.
A new Home Assistant Core change is not represented in the test matrixA supported Core release or the development release can fail after merge without an early signalThe scheduled matrix job refreshes stable release entries and includes dev.
The lighting model and preview copy do not matchThe plotted result can differ from the behavior used by the integrationThe preview copies the model at app start, and behavior changes should be checked in both preview and tests.
The simulator export is not placed at the site pathDocumentation can publish without its interactive previewThe documentation workflow exports the app, copies it to /simulator/, and uploads the combined site.
A delivery workflow expects a branch that is not synchronizedRelease or validation results can differ between main and masterThe branch sync workflow pushes main changes to master.

Key files

FileWhy to read it
custom_components/…/color_and_brightness.pyDefines the lighting behavior that the preview and behavior tests use as their common reference.
webapp/app.pyShows how settings become full-day brightness and color plots and how the preview is exposed.
.github/…/pytest.yamlShows the Home Assistant Core and Python compatibility checks that protect runtime behavior.
scripts/update-test-matrix.pyShows how the supported Core test range stays current.
custom_components/…/const.pyHolds the shared option meanings and validation data that feed user-facing metadata.
.github/update-services.py and .github/update-strings.pyShow how source descriptions become Home Assistant service and configuration metadata.
custom_components/…/manifest.json and hacs.jsonDefine the package identity and the metadata used for distribution.
.github/…/docs.ymlShows how the written documentation and simulator become one published site.
.github/…/docker-build.yml and .github/…/release-drafter.ymlShow the main container and release-note delivery paths.