-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Open
Labels
Description
The problem
Trying to create a template switch entity with a blueprint using template domain and variables results in error.
Skipping using variables and statically defining what would be the contents of the variable in the blueprint definition works. Reproducible code in example YAML snippet section.
What version of Home Assistant Core has the issue?
core-2025.5.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
blueprint or template?
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
Reproducing the issue:
**Requirements**: A light entity called `light.light_group_demo`
**Working Demo *without* variable definition using a static entity defined:**
**File**: `blueprint_demo_light_to_switch_1_no_variable.yaml` (path: `/config/blueprints/template/switchdemo`)
# Demo to show how to create a Blueprint Template for a switch
blueprint:
name: Light to Switch No Variable
description: Creates a switch from a light entity (No Variable version)
domain: template
homeassistant:
min_version: "2025.5.0"
input:
e_light_group:
name: Light Group Entity
description: The entity for the Light Group
selector:
entity:
switch:
availability: "{{ states('light.light_group_demo') not in ('unknown', 'unavailable') }}"
state: "{{ is_state('light.light_group_demo','on') }}"
turn_on:
action: light.turn_on
target:
entity_id: light.light_group_demo
turn_off:
action: light.turn_off
target:
entity_id: light.light_group_demo
Using the blueprint creating the template switch from package include file definition:
template:
- use_blueprint:
path: switchdemo/blueprint_demo_light_to_switch_1_no_variable.yaml # relative to config/blueprints/template/
input:
e_light_group: light.light_group_demo
name: "Light to Switch Demo No Variable"
unique_id: "light_to_switch_blueprint_demo_no_variable"
:white_check_mark: **Result**: This creates a switch entity that works
**Broken Demo *with* variable definition:**
**File**: `blueprint_demo_light_to_switch_2_with_variable.yaml` (path: `/config/blueprints/template/switchdemo`)
# Demo to show how to create a Blueprint Template for a switch
blueprint:
name: Light to Switch
description: Creates a switch from a light entity
domain: template
homeassistant:
min_version: "2025.5.0"
input:
e_light_group:
name: Light Group Entity
description: The entity for the Light Group
selector:
entity:
variables:
e_light_group: !input e_light_group
switch:
availability: "{{ states(e_light_group) not in ('unknown', 'unavailable') }}"
state: "{{ is_state(e_light_group,'on') }}"
turn_on:
action: light.turn_on
target:
entity_id: "{{ e_light_group }}"
turn_off:
action: light.turn_off
target:
entity_id: "{{ e_light_group }}"
Using the blueprint creating the template switch from package include file definition:
template:
- use_blueprint:
path: switchdemo/blueprint_demo_light_to_switch_2_with_variable.yaml # relative to config/blueprints/template/
input:
e_light_group: light.light_group_demo
name: "Light to Switch Demo With Variable"
unique_id: "light_to_switch_blueprint_demo_with_variable"
:x: **Result**: This do not work, following error message is seen in logs:
> Invalid config for 'template' at switch_light_to_switch_blueprint_demo_2_with_variable.yaml, line 2: 'variables' is an inval
617A
id option for 'template', check: switch->0->variables
Anything in the logs that might be useful for us?
> Logger: homeassistant.config
> Source: config.py:357
> First occurred: 22:33:33 (4 occurrences)
> Last logged: 22:33:54
> Invalid config for 'template' at integrations_custom/switch_light_to_switch_blueprint_demo_2_with_variable.yaml, line 2: 'variables' is an invalid option for 'template', check: switch->0->variables
Additional information
Thanks to petro for responding fast in the community forum and telling me to write this issue
davux and dhottinger