I am trying to create a Blueprint with an optional !input motion trigger.
But I haven’t got this to work by using “platform: state” & putting the “!input” in “entity_id:” for the “trigger:”
E.g.
blueprint:
name: test 1
domain: automation
input:
motion_sensor:
name: Motion sensor
default:
selector:
entity:
domain: binary_sensor
device_class: motion
trigger:
- platform: state
entity_id: !input motion_sensor
to: "on"
id: motion_detected
- platform: state
entity_id: !input motion_sensor
to: "off"
id: motion_cleared
action:
- service: logbook.log
data:
name: test
message: trigger.id
The script doesn’t load if an entity isn’t selected, So I assume it needs to be done with A template trigger.
E.g.
blueprint:
name: test 2
domain: automation
input:
motion_sensor:
name: Motion sensor
default:
selector:
entity:
domain: binary_sensor
device_class: motion
variables:
motion_sensor: !input motion_sensor
trigger:
- platform: template
value_template: "{{ is_state ( motion_sensor , 'on' ) }}"
id: motion_detected
- platform: template
value_template: "{{ is_state ( motion_sensor , 'off' ) }}"
id: motion_cleared
action:
- service: logbook.log
data:
name: test
message: trigger.id
Tho this will load, it doesn’t trigger the automation when a sensor state changes to detect/clear motion.
What am I doing wrong?
I know this blue print has no point, i’m just trying to figure out optional !input’s in Blueprints particularly A motion sensor.