Template helpers
The Template integration lets you make your own entities, whose state and actions come from templates. A template is a small piece of code that works out a value from other entities. Like a sensor that adds up three others, or a switch that runs a script.
A template gets nothing back when the entity it reads is gone, and no error tells you. The same goes for an attribute it reads: an extra detail on an entity, like the brightness of a light. A template that holds an entity to a state it is never in, like On for a light that is on or off, is never true. An action that no longer exists fails when it runs. And an area, floor, label or device that is gone finds nothing, in a template or as the target of an action. A template trigger or condition written so that it can never be true, like a template in quotes, never lets anything through. Spook reads your templates and raises a repair when they point at something Home Assistant does not have, or can never pass.
That goes for template helpers made in the UI, and for template entities set up in YAML, under template: in your configuration, trigger based ones included.
Repairs
Spook looks through your template helpers and template entities for things that can no longer work, and tells you in the repairs dashboard. Each repair names the helper or template entity and what is wrong with it.
Fixing a template helper goes the same way each time: open the helper from the repair, change its template, and save. For a template entity from YAML there is no editor: edit it under template: in your configuration, and reload your template entities. Spook looks again, and takes the repair away by itself. New to this? Follow Fix your first repair.
Unknown referenced entities
A template uses an entity that no longer exists, usually because it was renamed, replaced or removed. The template gets nothing back for it, and a trigger on it never fires.
Unknown referenced entities
A template uses an entity that no longer exists, usually because it was renamed, replaced or removed. The template gets nothing back for it, and a trigger on it never fires.
How to fix it: Open the helper from the repair, and in its template, use the right entity. Or take it out. For a template entity from YAML, the repair names it and its entity ID: change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks in the templates of Template helpers for entity IDs that do not exist. The repair lists the helper and the missing entity IDs.
Template entities from YAML are checked 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. For a trigger based template entity, the triggers, conditions, actions and variables of its section are checked as well. A trigger on an entity that does not exist never fires, so the template entity never updates.
Each template entity gets a repair of its own. When the triggers of a section name an entity that does not exist, every template entity in that section gets a repair, 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.
Unknown referenced actions
A template helper or template entity runs an action that does not exist, usually because the integration or script that provided it was removed. Like the press of a template button, or the turn_on of a template switch. That action fails when it runs.
Unknown referenced actions
A template helper or template entity runs an action that does not exist, usually because the integration or script that provided it was removed. Like the press of a template button, or the turn_on of a template switch. That action fails when it runs.
How to fix it: Open the helper from the repair, and change the action to one that exists. Or bring back the integration or script it came from. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at the action sequences of Template helpers, such as the press action of a Template Button or the turn_on and turn_off actions of a Template Switch. When an action does not exist, the repair lists the helper and the missing action.
Template entities from YAML are checked 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 a repair of its own, naming the template entity and its entity ID.
Templated action names are not checked, because what they end up as is only known while running. Actions of an integration you disabled are not reported either: switched off on purpose is not gone. Once you enable the integration again, they are checked as usual. Actions of an integration Home Assistant keeps retrying to set up are left out too: it is installed, and its actions come back once it loads. The outage itself shows on the failed integrations card. Once Home Assistant gives up on it with an error, its actions are reported as usual.
Unknown referenced attributes
A template reads an attribute its entity does not have, like state_attr('light.kitchen', 'brightnes'). It gets nothing back, and you get no error.
Unknown referenced attributes
A template reads an attribute its entity does not have, like state_attr('light.kitchen', 'brightnes'). It gets nothing back, and you get no error.
How to fix it: Open the helper from the repair, and use an attribute the entity has. When Spook is nearly certain what you meant, the repair says so. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at the attributes Template helpers and template entities from YAML 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. When a helper or template entity uses an attribute its entity does not have, Spook raises a repair. It lists the helper, the attribute and 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 back. You get no error.
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.
Unknown referenced areas
A template uses an area that no longer exists, usually because it was removed or merged into another. A template looking it up, like area_entities('living_room'), gets an empty list, and an action targeting it skips it. Home Assistant logs a warning about the action at most, and does not say which template entity it came from.
Unknown referenced areas
A template uses an area that no longer exists, usually because it was removed or merged into another. A template looking it up, like area_entities('living_room'), gets an empty list, and an action targeting it skips it. Home Assistant logs a warning about the action at most, and does not say which template entity it came from.
How to fix it: Open the helper from the repair, and use an area that exists. Or take it out. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at every area a template helper or template entity targets in its actions, and at what its templates hand area_entities and area_devices, called or as a filter. It looks the value up the way Home Assistant does: an area ID, or the name or an alias of an area, in any case. When that finds no area, the repair names the helper or template entity and the missing area.
Spook reads the same places as for entities: every template a template helper or template entity has, like the state, availability, the values of its attributes, icon and picture, their variables, and their own actions, like the turn_on of a template switch. For a trigger based template entity, the triggers, conditions, actions and variables of its section are read as well. The names of its attributes are left alone: they are yours, so an attribute called area_id is no target.
What only a disabled trigger or step names is not reported, and neither is a step a blueprint switches off with a template, since whoever uses the blueprint cannot change it. Only a value written out is checked. One worked out while running, from a variable or by joining pieces, is not.
Unknown referenced floors
A template uses a floor that no longer exists. A template looking it up, like floor_areas('upstairs'), gets an empty list, and an action targeting it skips it, without telling you.
Unknown referenced floors
A template uses a floor that no longer exists. A template looking it up, like floor_areas('upstairs'), gets an empty list, and an action targeting it skips it, without telling you.
How to fix it: Open the helper from the repair, and use a floor that exists. Or take it out. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at every floor a template helper or template entity targets in its actions, and at what its templates hand floor_areas and floor_entities, called or as a filter. A floor ID, or the name or an alias of a floor, in any case, finds the floor, the same way as for automations.
Spook reads the same places as for entities: every template a template helper or template entity has, like the state, availability, the values of its attributes, icon and picture, their variables, and their own actions, like the turn_on of a template switch. For a trigger based template entity, the triggers, conditions, actions and variables of its section are read as well. The names of its attributes are left alone: they are yours, so an attribute called area_id is no target.
What only a disabled trigger or step names is not reported, and neither is a step a blueprint switches off with a template, since whoever uses the blueprint cannot change it. Only a value written out is checked. One worked out while running, from a variable or by joining pieces, is not.
Unknown referenced labels
A template uses a label that no longer exists. A template looking it up, like label_entities('christmas'), gets an empty list, and an action targeting it skips it, without telling you.
Unknown referenced labels
A template uses a label that no longer exists. A template looking it up, like label_entities('christmas'), gets an empty list, and an action targeting it skips it, without telling you.
How to fix it: Open the helper from the repair, and use a label that exists. Or take it out. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at every label a template helper or template entity targets in its actions, and at what its templates hand label_areas, label_devices and label_entities, called or as a filter. A label ID, or the name of a label, in any case, finds the label. Labels have no aliases.
Spook reads the same places as for entities: every template a template helper or template entity has, like the state, availability, the values of its attributes, icon and picture, their variables, and their own actions, like the turn_on of a template switch. For a trigger based template entity, the triggers, conditions, actions and variables of its section are read as well. The names of its attributes are left alone: they are yours, so an attribute called area_id is no target.
What only a disabled trigger or step names is not reported, and neither is a step a blueprint switches off with a template, since whoever uses the blueprint cannot change it. Only a value written out is checked. One worked out while running, from a variable or by joining pieces, is not.
Unknown referenced devices
A template helper or template entity uses a device that no longer exists, usually because it was removed. A template looking it up, like device_entities('0123456789abcdef0123456789abcdef'), gets an empty list, and an action targeting it skips it. Home Assistant logs a warning about the action at most, and does not say which template entity it came from.
Unknown referenced devices
A template helper or template entity uses a device that no longer exists, usually because it was removed. A template looking it up, like device_entities('0123456789abcdef0123456789abcdef'), gets an empty list, and an action targeting it skips it. Home Assistant logs a warning about the action at most, and does not say which template entity it came from.
A device trigger, condition or action is worse. It keeps working for now, but Home Assistant checks those when it loads your template entities. For a device action, the next reload or restart leaves that template entity out. For a device trigger or condition, the next reload of your template entities fails as a whole, so none of your changes to them take, and after a restart none of your template entities from YAML load.
A template helper can also be linked to a device, so it shows up with that device. When the device is gone, the helper keeps working, without the link.
How to fix it: Open the helper from the repair, and use a device that exists. Or take it out. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at every device a template helper or template entity targets in its actions, every device trigger, condition and action, the device a template helper is linked to, and the device IDs its templates hand the device functions, like device_entities and device_attr. When Home Assistant has no device by that ID, the repair names the helper or template entity and the missing device.
Spook reads the same places as for entities: every template a template helper or template entity has, like the state, availability, the values of its attributes, icon and picture, their variables, and their own actions, like the turn_on of a template switch. For a trigger based template entity, the triggers, conditions, actions and variables of its section are read as well. The names of its attributes are left alone: they are yours, so an attribute called device_id is no device. Neither is the device_id an event trigger filters its events on: that is whatever the integration firing the event puts there.
Spook only sees template entities Home Assistant loaded. One it already refused, for a device that was gone when it loaded, is not there to look at: Home Assistant says so in its log itself. Spook catches the device that goes away while Home Assistant runs, before the next reload or restart.
A device Home Assistant split into one device per integration still works by the ID it had, so it is not reported here. Home Assistant raises a repair of its own for a helper linked to one.
What only a disabled trigger or step names is not reported, and neither is a step a blueprint switches off with a template, since whoever uses the blueprint cannot change it. Only a device ID written out is checked. One worked out while running, from a variable or by joining pieces, is not.
Unknown referenced states
A template helper or template entity waits for, or checks, a state its entity is never in, like is_state('light.kitchen', 'On') for a light that is on or off. That template is never true, a trigger waiting for that state never fires, and a condition checking for it never passes. You get no error.
Unknown referenced states
A template helper or template entity waits for, or checks, a state its entity is never in, like is_state('light.kitchen', 'On') for a light that is on or off. That template is never true, a trigger waiting for that state never fires, and a condition checking for it never passes. You get no error.
How to fix it: Open the helper from the repair, and use a state the entity can be in. When Spook is nearly certain what you meant, the repair says so. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook looks at the states Template helpers and template entities from YAML wait for and check: in templates is_state('light.kitchen', 'on') and a state compared to text, like states('light.kitchen') == 'on', and in their actions the state of state conditions and the to, from, not_to and not_from of a wait for a trigger. For a trigger based template entity from YAML, that includes the state triggers and conditions of its section. When a helper or template entity uses a state its entity is never in, Spook raises a repair. It lists the helper, the state and the entity, and what was most likely meant when Spook is near certain of it.
Spook reads the same places as for entities: every template a template helper or template entity has, like the state, availability, the values of its attributes, icon and picture, their variables, and their own actions, like the turn_on of a template switch. The names of its attributes are left alone: they are yours, so an attribute called state or condition is no condition. What only a disabled trigger or step names is not reported, and neither is a step a blueprint switches off with a template, since whoever uses the blueprint cannot change it.
Which states count as never possible works exactly as for automations: only entities whose states are a fixed set are checked, a state named as what the entity must not be is a guard, and everything the entity was in, right now and in the recorder, counts. With an attribute, a state trigger or condition waits for a value of that attribute instead, and those are checked the same way too, in the same repair. A state or entity that is only worked out while running, from a variable for example, is not checked.
Spook looks at the same moments as for unknown attributes: ten minutes after Home Assistant starts, after that 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. It also looks again once an entity offers or is in a state it was reported for, like a select that got a new option.
Templates that can never pass
A template helper or template entity has a template in a trigger, condition or action that, the way it is written, can never be true. Its trigger never fires, so it never updates the template entity. Its condition always fails, so the template entity never updates, its action stops right there, or an if always takes its else. Its wait only ends on a timeout. You get no error.
Templates that can never pass
A template helper or template entity has a template in a trigger, condition or action that, the way it is written, can never be true. Its trigger never fires, so it never updates the template entity. Its condition always fails, so the template entity never updates, its action stops right there, or an if always takes its else. Its wait only ends on a timeout. You get no error.
How to fix it: Open the helper from the repair and correct the template. The usual causes: quotes around the template, missing {{ }}, something pasted around it, a template that gives on where true is needed, and a template in the to, from or state of a state trigger or condition, which Home Assistant never renders. For a template entity from YAML, change it under template: in your configuration, and reload your template entities. The repair disappears by itself once it is fixed.
Spook reads the templates that have to pass, exactly the way it reads them in automations: the value_template of template triggers and template conditions, shorthand template conditions, wait_template, and templates in the to, from, not_to or not_from of a state trigger or the state of a state condition. Wherever they are: in the triggers and conditions of a trigger based section, and anywhere in its actions or in the template entity's own actions, like the turn_on of a template switch or the press of a template button (an if, a choose, the while or until of a repeat, a condition step, nested in and, or or not, a wait_for_trigger). For a Template helper, that is its own actions. When one can never pass, Spook raises a repair that names the helper or template entity and the templates that can never pass.
The template of the entity itself, like its state, availability, icon, picture or the values of its attributes, is not read: it works out a value, and nothing there has to pass. Neither are the names of its attributes: they are yours, so an attribute called condition is no condition. A repeat that runs until a template saying false and nothing else is left alone, since that is how a loop is told to go on until something inside it stops. What a disabled trigger, condition or step holds is not reported, and neither is a step a blueprint switches off with a template, since whoever uses the blueprint cannot change it.
Only the text of the template is read, so Spook looks again when a Template helper is added, changed or removed, when template entities are reloaded, and when an integration loads.
Missing something here?
An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.
Switch as X
The Switch as X helper turns a Home Assistant switch into a light, cover, fan, lock, siren or valve. Spook tells you when the switch behind one is gone.
Timer
Spook adds actions to create, change and delete timer helpers, to change how long a timer runs, and to set the time a running timer has left, from your automations and scripts.
