Hello,
I’m dipping my toes into blueprints and my first good use case is to avoid config duplication of reoccurring template switches I have in my home.
Background/Goal
For each area/room I group all lights into one Light group, then I make scenes and a script to set lights after conditions. Sometimes very simple, sometimes more complex conditions but it’s nice to have that logic all wrapped in a script when lights are turned on.
Then this script is called from automations, smart buttons, motion detection etc.
To simplify it in the GUI and for physical switches/buttons (a toggle is available!) I make a switch entity that also calls this script. If it’s turned off I just turn off the light group.
Issue
I tried to recreate the base of these switches with a Blueprint Template (domain). Including Entity Selector and Action Selector but fell short.
I have simplified it to just use the Light Group Entity but even that throws error about variable definitions.
Recreating the issue
Version: 2025.05.3
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"
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"
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 invalid option for ‘template’, check: switch->0->variables
–
Some general questions from me:
- Am I messing up the formatting of the blueprint template for the switch causing the error?
- Is there any way of yaml templating the entity selector in the blueprint?
- Are blueprint templates limited to using variables in only binary_sensor and sensor entities?
Need help going forward with this issue, any insights very welcomed. Thanks!