ENGINEERING NOTE / HOME ASSISTANT

Home Assistant dependencies and state changes

Before renaming an entity, I want to find its references. After an unexpected state change, I want the trace of that change. Home Assistant exposes different information for each job.

CONFIGURATION

Locate the reference.

An explicit entity ID gives a configuration scanner a concrete reference to report. For example, this action targets light.desk:

actions:
  - action: light.turn_on
    target:
      entity_id: light.desk

The report can retain the source automation, the action-target role and the location of the reference. A trigger watching the same light, a condition reading its state and a dashboard displaying it should retain their own roles. A list of matching entity IDs alone loses that distinction.

Script calls can be followed to their actions, and scene or group membership can reveal further references. HA Blast Radius reads loaded configuration for this analysis; its source-access documentation lists the supported sources and their limits. A reference establishes a possible dependency, without establishing that the action ran during an incident.

DYNAMIC TARGETS

Leave unresolved targets visible.

A target selected by a template can change at runtime. Parsing a literal entity ID inside Jinja can identify a reference, but it cannot always determine the value the expression will produce. Executing templates during analysis would change the task and still only give an answer for the state at that moment.

Device, area, floor and label selectors need similar care. A scanner may confirm that the selector exists while leaving its eventual entity targets unresolved. Registry membership, action eligibility and runtime state can affect which entities the action reaches.

The report should preserve the selector and its configuration location. Known references remain useful even when some targets need manual review; an unresolved target should not be turned into a guessed action on every entity in the area.

CONTEXT IDS

Follow the captured change.

For an unexpected state change, start with the recorded event and any retained automation trace. Home Assistant uses context.id to group related activity and context.parent_id to link a new context to its parent. Its context documentation explains how automations carry those links.

Illustrative events, with context IDs shortened to A and B.
Captured eventContextParent context
Button state changesA—
Automation startsBA
Light state changesBA

Here, the parent ID links the automation’s context to the button event’s context. The automation and light events also share a context. If several events belong to that parent context, choosing one as the display anchor does not prove it was the unique trigger. Events sharing a context can be ordered as captured without claiming that each caused the next.

Timestamp proximity alone cannot supply a missing context link. An event 200 milliseconds earlier may be relevant, but timing by itself is insufficient to label it as the cause.

RETENTION

Preserve the incident window.

A bounded recorder can retain normalized state changes, service calls, automation triggers and script starts. It also imposes a limit: the parent context may have aged out, been excluded from capture or never been present in the original event. Save the relevant window while it is available, including any gaps.

HA Forensic Lab’s context reconstruction distinguishes parent links, shared-context activity and missing evidence. A single captured event can still leave the cause unknown. Configuration references help identify where to investigate next, but they cannot fill in an event the recorder did not capture.