I’m trying to use the new Blueprint Templates via Yaml but no matter what I do they either don’t work (with nothing in the logs) or cause errors.
The examples assume they are in configuration.yaml and not a sub file.
Is it possible to actually make use of Blueprint Template sensors without moving all template sensors into the configuration.yaml file?
I’ve tried the following:-
Current configuration.yaml (extract)
wake_on_lan:
notify: !include notify.yaml
rest_command: !include rest_command.yaml
google_assistant: !include google_assistant.yaml
template: !include template.yaml
Then in template.yaml I currently have
sensor:
- unique_id: "sun_elevation"
state: >
{{ state_attr('sun.sun','elevation')|float }}
attributes:
category: outside_world
friendly_name: "The Sun's Elevation"
unit_of_measurement: '°'
- unique_id: "sun_azimuth"
state: >
{{ state_attr('sun.sun','azimuth')|float }}
attributes:
category: outside_world
friendly_name: "The Sun's Azimuth"
unit_of_measurement: '°'
binary_sensor:
- unique_id: "consider_it_after_sundown_for_lamps"
state: >
{%- if(states('sensor.template_sun_elevation')|float < states('input_number.consider_it_dark_when_elevation_below')|float) -%}on{% else %}off{% endif %}
attributes:
category: outside_world
friendly_name: "Sun's Elevation is low enough to consider it after sundown"
blueprints/template/access_point_name.yaml is as follows (SSID and BSSID blanked out)
blueprint:
name: Current Connected Access Point Name
description: Creates a sensor which holds displays the connected SSID followed by a location name when known
domain: template
min_version: 2024.6.0
input:
bssid:
name: Device's BSSID
description: Sensor which contains the devices currently connected BSSID (MAC Address)
selector:
entity:
domain: sensor
ssid:
name: Device's SSID
description: Sensor which contains the devices currently connected SSID (Network Name)
selector:
entity:
domain: sensor
variables:
bssid: !input bssid
ssid: !input ssid
sensor:
state: >
{% if bssid == 'xx:xx:xx:xx:xx:xx' %}SSID (Bedroom 5GHz)
{% elif bssid == 'xx:xx:xx:xx:xx:xx' %}SSID (Bedroom 2.4GHz)
{% elif bssid == 'xx:xx:xx:xx:xx:xx' %}SSID (Lounge 5GHz)
{% elif bssid == 'xx:xx:xx:xx:xx:xx' %}SSID (Bedroom 2.4GHz)
{% else %}{{ states(ssid) }}
{% endif %}
Simply adding the following to the bottom of the template.yaml file
use_blueprint:
path: access_point_name.yaml
name: Tab S9 Connected Access Point
unique_id: "kev_s_tab_s9_wifi_access_point"
input:
bssid: sensor.kev_s_tab_s9_wifi_bssid
ssid: sensor.kev_s_tab_s9_wifi_connection
generates the following error message in the logs when you run check Configuration
Invalid config for 'template' at template.yaml, line 154: 'binary_sensor' is an invalid option for 'template', check: binary_sensor Invalid config for 'template' at template.yaml, line 1: 'sensor' is an invalid option for 'template', check: sensor Invalid config for 'template' at template.yaml, line 206: 'input' is an invalid option for 'template', check: input
If you instead you add a - before it so -
- use_blueprint:
path: access_point_name.yaml # relative to config/blueprints/template/
name: Tab S9 Connected Access Point
unique_id: "kev_s_tab_s9_wifi_access_point"
input:
bssid: sensor.kev_s_tab_s9_wifi_bssid
ssid: sensor.kev_s_tab_s9_wifi_connection
You immediately get the following error shown:-
Configuration errors
Error loading /config/configuration.yaml: while parsing a block mapping
in "/config/template.yaml", line 1, column 1
expected <block end>, but found '-'
in "/config/template.yaml", line 202, column 1
If you indent it under sensor the following error
Invalid config for 'template' at template.yaml, line 154: 'use_blueprint' is an invalid option for 'template', check: sensor->14->use_blueprint Invalid config for 'template' at template.yaml, line 154: required key 'state' not provided Invalid config for 'template' at template.yaml, line 158: 'input' is an invalid option for 'template', check: sensor->14->input
Changing configation.yaml to have an additional line (as I previously used for scripts before you could edit in the UI)
template blueprint: !include template_blueprint.yaml
with template_blueprint.yaml as follows
use_blueprint:
path: access_point_name.yaml # relative to config/blueprints/template/
name: Tab S9 Connected Access Point
unique_id: "kev_s_tab_s9_wifi_access_point"
input:
bssid: sensor.kev_s_tab_s9_wifi_bssid
ssid: sensor.kev_s_tab_s9_wifi_connection
Neither works or generates an error.
Adding to configuration.yaml as
template: !include template.yaml
template:
- use_blueprint:
path: access_point_name.yaml # relative to config/blueprints/template/
name: Tab S9 Connected Access Point
unique_id: "kev_s_tab_s9_wifi_access_point"
input:
bssid: sensor.kev_s_tab_s9_wifi_bssid
ssid: sensor.kev_s_tab_s9_wifi_connection
generates an error about template being duplicated
while
template: !include template.yaml
template blueprint:
- use_blueprint:
path: access_point_name.yaml # relative to config/blueprints/template/
name: Tab S9 Connected Access Point
unique_id: "kev_s_tab_s9_wifi_access_point"
input:
bssid: sensor.kev_s_tab_s9_wifi_bssid
ssid: sensor.kev_s_tab_s9_wifi_connection
generates neither an error or loads the sensor.