Integration diagnostics
Integration diagnostics gives Home Assistant a safe, on-demand snapshot of one configured Adaptive Lighting profile. It helps an engineer compare the profile's live control state with the current state and recent adaptation facts for its tracked lights without exposing names, entity IDs, entry IDs, or event context.
Diagnostic boundary
Diagnostics are exposed for one config entry at a time through Home Assistant's config-entry diagnostics interface. The request reads the active profile and the shared runtime manager, then returns a JSON-safe result for troubleshooting; it does not create entities, refresh light groups, or change adaptation behavior.
The page sits below Adaptive Lighting integration lifecycle, which explains when entry state and the shared manager exist. Integration setup and coordination explains how the profile and manager become available to the diagnostic request.
Entry availability
The diagnostic result reports loaded: true only when the entry has its profile switch and shared manager available. If the integration state is absent, incomplete, or already unloaded, the result is the small response { "loaded": false } rather than a partial or stale report.
This boundary matters during startup and teardown. A diagnostic request can safely run while an entry is not ready, and a request after unload does not recreate the entry or retain its old data.
References: custom_components/…/diagnostics.py• L76-93 custom_components/…/__init__.py• L103-140
Snapshot contents
The loaded result combines profile-level switch state with a per-light view. It uses short, fixed field names so a support report can show the important runtime facts without including the full saved configuration or raw Home Assistant objects.
Profile controls
The profile_switches object shows the live state of the four controls that shape one profile:
profile— whether the main Adaptive Lighting profile is on.adapt_brightness— whether brightness adaptation is enabled.adapt_color— whether color adaptation is enabled.sleep_mode— whether sleep mode is enabled.
These values describe current control state. They do not describe every saved option or explain why a light received a particular target.
References: custom_components/…/diagnostics.py• L121-129 custom_components/…/switch.py• L880-903
Light facts
The lights object gives each tracked target a numbered label such as light_1 or light_2. The labels are assigned from the profile's sorted light targets, so the report can remain useful without publishing the target entity IDs.
Each light record contains the following facts:
| Fact | Meaning |
|---|---|
state | Current Home Assistant state, limited to on, off, unavailable, unknown, or missing. |
global_manager_manual_control | Whether the shared manager has paused brightness and color adaptation for the target. |
global_manager_autoreset_seconds | Remaining time for an active manual-control reset timer, or null when no timer runs. |
global_manager_last_adaptation_values | The latest retained values for brightness, color temperature, RGB color, and transition when those values exist. |
The manual-control and last-adaptation fields come from the manager shared by all active profiles. The manager_fact_scope field states this as global_shared_across_profiles; those facts can therefore reflect activity that is not unique to the selected profile.
References: custom_components/…/diagnostics.py• L26-37 custom_components/…/diagnostics.py• L95-119 custom_components/…/diagnostics.py• L121-130
Collection flow
Diagnostics collect a point-in-time view from already active Home Assistant state. The collector uses the selected profile's tracked targets and reads the current state and shared manager facts for each target.
This diagram shows how the entry and shared runtime become a safe support snapshot.
sequenceDiagram
participant HA as Home Assistant
participant D as Diagnostics
participant E as Config entry state
participant M as Shared manager
participant S as Light state registry
HA->>D: Request diagnostics for one entry
D->>E: Check profile and manager availability
alt Entry not loaded
D-->>HA: loaded: false
else Entry loaded
D->>E: Read profile control states and tracked targets
loop Each sorted target
D->>S: Read current state
D->>M: Read manual-control and recent adaptation facts
end
D-->>HA: JSON-safe diagnostic snapshot
end
The collector does not expand a group during the request or update manager records. A target that is not present in Home Assistant is represented as missing, while an unrecognized state is normalized to unknown.
References: custom_components/…/diagnostics.py• L76-131 custom_components/…/switch.py• L625-648
Troubleshooting safety
The diagnostic payload is deliberately narrower than the live runtime. It keeps only allowlisted light attributes and converts values to JSON-safe forms, which makes the report suitable for transfer to support without copying raw service data or Home Assistant objects.
Identifier protection
Diagnostics do not return config-entry IDs, profile names, light entity IDs, friendly names, room names, or event context IDs. The numbered light labels preserve the order of the selected targets while hiding their identities.
The last adaptation view also filters its source to brightness, color temperature, RGB color, and transition. RGB tuples become lists so the complete result can be serialized as JSON. Other fields that the manager may retain are not included.
References: custom_components/…/diagnostics.py• L32-61 custom_components/…/diagnostics.py• L95-119 tests/test_diagnostics.py• L188-201
Runtime isolation
The collector only reads profile state, Home Assistant state, manager flags, timers, and retained adaptation values. It does not fire service or state events, alter manual-control records, start timers, refresh targets, or change switch states.
This read-only behavior is important when diagnostics are requested during a fault. The report can capture missing or unavailable targets without causing a new adaptation or changing the conditions being investigated.
References: custom_components/…/diagnostics.py• L64-119 tests/test_diagnostics.py• L311-368
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the diagnostic lookup aligned with the entry data written by integration setup and switch platform setup. A key change can turn a loaded entry into a false
loaded: falseresult. - Keep the output allowlist free of entry IDs, entity IDs, names, friendly names, room data, and context IDs when new manager facts are added.
- Keep every returned value JSON serializable. In particular, preserve the conversion of RGB values and timer values.
- Keep the light ordering and numbered labels stable when the tracked-target source changes. Support reports rely on the labels without seeing entity IDs.
- Keep diagnostics read-only. A new state lookup or manager fact must not expand groups, send light commands, create timers, or update live tracking.
- Keep the
global_shared_across_profilesscope label accurate when manager data is added or removed. Shared facts must not be read as profile-only facts.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The entry has not loaded or its profile switch is unavailable | Diagnostics return loaded: false and provide no partial snapshot | Treat the result as a lifecycle state, then inspect entry setup and unload behavior |
| A tracked light has no Home Assistant state | The light is shown as missing | Check the target registration and the light entity outside the diagnostic request |
| A light reports a state outside the supported set | The state is reported as unknown | Use the normalized state for support triage rather than assuming a new state is on or off |
| A manual-control reset timer is absent or no longer running | global_manager_autoreset_seconds is null | Compare the manual-control flags with the profile's reset setting and recent control activity |
| Raw manager service data is added to the report | Private identifiers or non-JSON values can leak into a support payload | Copy only the allowlisted adaptation attributes and convert compound values to JSON-safe forms |
| A diagnostic read starts a refresh or adaptation | The report changes the live conditions under investigation | Keep collection limited to read operations |
Key files
| File | Why to read it |
|---|---|
| custom_components/…/diagnostics.py | Defines the diagnostic contract, snapshot fields, state normalization, privacy filter, and unloaded-entry response. |
| tests/test_diagnostics.py | Shows the guarantees for current facts, partial adaptation history, missing states, privacy, JSON serialization, and no side effects. |
| custom_components/…/__init__.py | Shows when entry records and the shared manager are created and removed. |
| custom_components/…/switch.py | Shows the profile switch state, tracked light targets, and shared manager facts consumed by diagnostics. |
| custom_components/…/const.py | Defines the shared domain keys and control names that connect diagnostics to integration state. |
Adaptive Lighting integration lifecycle | Gives the parent view of entry setup, shared state, active profiles, and unload. |
Integration setup and coordination | Explains how platform setup creates the profile and shared runtime used by diagnostics. |