Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Enhanced integrations

Template helpers

Keep template helpers and template entities free of ghosts. 👻

The Template integration lets you create helpers whose values and actions are based on templates. Spook inspects Template helpers created in the Home Assistant user interface and raises repair issues when it finds references that are no longer available.

Template entities set up in YAML, under template: in your configuration, are inspected for unknown entities, actions and attributes too. That includes trigger based template entities, with the triggers, conditions, actions and variables of their section.

Devices & entities

Spook does not provide any new devices or entities for this integration.

Actions

Spook does not provide action enhancements for this integration.

Repairs

While Spook is floating around in your Home Assistant instance, it raises a repair issue when it finds something that is not right.

Unknown referenced entities

Spook inspects templates in Template helpers for entity IDs that do not exist. The repair issue lists the helper and the unavailable entity IDs. To resolve the issue, open the linked helper, update the reference to an existing entity, or remove it. Spook automatically removes the repair issue once it is fixed.

Template entities from YAML are inspected the same way: every template they have, like the state, availability, attributes, icon and picture, their variables, and their own actions, like the turn_on of a template switch. A trigger based template entity is also inspected for the triggers, conditions, actions and variables of its section. A trigger on an entity that does not exist never fires, so the template entity never updates.

Each template entity gets an issue of its own. When the triggers of a section name an entity that does not exist, every template entity in that section gets an issue, since none of them updates. What only a disabled trigger or step names is listed as such. this and trigger are only known while running, so whatever they point at is not checked.

An entity spelled out after states, like states.light.kitchen.state, is not checked when that states is not Home Assistant’s: when a template defines its own with a macro or {% set %}, or a template entity has a variable of that name. Used as a filter, like 'light.kitchen' | states, it still is Home Assistant’s, and still checked. An entity ID in quotes is checked wherever it is, whatever it is handed to.

There is no editor for YAML, so the repair issue names the template entity and its entity ID. To resolve the issue, edit it under template: in your configuration and reload your template entities. Spook removes the repair issue once it is fixed.

Unknown referenced actions

Spook inspects action sequences configured in Template helpers, such as the press action of a Template Button or the turn_on and turn_off actions of a Template Switch. If an action is unavailable, the repair issue lists the helper and the unavailable action.

To resolve the issue, open the linked helper, update the action to one provided by Home Assistant, or restore the integration or script that provided it. Templated action names are ignored because their value is determined at runtime. Actions of an integration you disabled are ignored too, until you enable it again. Spook automatically removes the repair issue once it is fixed.

Template entities from YAML are inspected the same way: every action of their own, like the turn_on and turn_off of a template switch, the press of a template button or the set_value of a template number, and for a trigger based template entity the actions of its section. Each template entity gets an issue of its own. There is no editor for YAML, so the repair issue names the template entity and its entity ID. To resolve the issue, edit it under template: in your configuration and reload your template entities. Spook removes the repair issue once it is fixed.

Unknown referenced attributes

Spook inspects Template helpers and template entities from YAML for the attributes they use: attributes named in their templates, like state_attr('light.kitchen', 'brightness'), and the attribute of state and numeric state conditions and triggers in their actions. For a trigger based template entity from YAML, that includes the triggers and conditions of its section. If a helper or template entity uses an attribute its entity does not have, Spook raises a repair issue. The repair issue lists the helper, the attribute, the entity, and what was most likely meant when Spook is near certain of it.

A template reading an attribute that never shows up gets nothing, and nothing tells you. That is the ghost this catches.

Many attributes only show up some of the time: a media player that is off drops most of its own, and integrations add their own that come and go. So an attribute is only reported when Spook cannot find it anywhere: not on the entity right now, not as something that kind of entity offers in Home Assistant, and not in anything the recorder remembers the entity having. An entity the recorder does not record is only checked for attributes that differ from a real one in upper and lower case alone, like Brightness. An attribute or entity that is only worked out while running, from a variable for example, is not checked.

Spook does not look right after Home Assistant starts, when the recorder is busy, but ten minutes later. After that it looks again when a Template helper is added, changed or removed, when template entities are reloaded, when an entity is added or removed, when the entity registry changes, when an integration loads, and once a day.

To resolve the issue, open the linked helper and use an attribute the entity has. For a template entity from YAML, edit it under template: in your configuration and reload your template entities. Spook automatically removes the repair issue once it is fixed.

Feature requests, ideas, and support

If you have an idea for a new action, entity, or repair detection, let us know in the discussion forums.

Are you stuck? See the Support page for where to get help.