I want to allow for both a input_boolean and binary_sensor in my blueprint. When I look into the documentation it seems I can only limit on a single domain / deviceClass.
Would be nice if we can define a list of entity definitions like:
I was just running into the same issue, playing around with modifying some blueprints… got the idea to actually go even more flexible as a solution, and I like how it seems to be working.
Pretty sure this should work easily for anything bouncing between a handful of discrete states, without adding to the eternal pileup of template-sensor helpers. Almost all of my use cases for this sort of selector in an automation are covered by binary_sensor or input_boolean, and those that aren’t are still mostly using ‘on’/‘off’ states in the backend, but the exceptions (e.g. cover, person) are still common enough that I like this as a general-purpose approach.
Doesn’t help actually narrow down your selector list though.
Maybe also worth noting that you can’t use a selector like that optionally/with a null default if it’s going to be one of your Triggers… but this does seem to still allow optional conditionals without throwing any errors/warnings on the latest updates.
blueprint:
name: Selector Example
description: Trigger or condition on (non-)boolean entities/states
domain: automation
input:
sensor_input:
name: Sensor
description: Trigger or condition for the automation.
default:
selector:
entity:
set_on:
name: "'On' states"
description: Comma-separated list of strings to consider as 'true' for state-matching conditions.
default: "'on', 'true', 'home', 'open'"
selector:
text:
trigger:
platform: state
entity_id: !input sensor_input
to: !input set_on
variables:
sensor_input: !input sensor_input
set_on: !input set_on
condition:
- "{{ states(sensor_input) in set_on if sensor_input }}" # Run automation if set and true
action:
- choose: # Run sequence if set and true
- conditions: "{{ states(sensor_input) in set_on if sensor_input }}"
sequence:
-
default: []
- condition: template # Only continue sequence if set
value_template: "{{ true if sensor_input }}"