Wrote a blueprint to auto turn on/off a light/switch based on motion/light_sensor. Getting this error, but couldn’t figure out reason:
Message malformed: Entity entity_id is neither a valid entity ID nor a valid UUID for dictionary value @ data[‘action’][0][‘choose’][0][‘conditions’][2][‘entity_id’]
blueprint:
name: Motion Light New
description: Turn on a light when motion is detected with a condition
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_condition:
name: Light Condition (off)
selector:
entity:
domain: binary_sensor
device_class: light
light_target:
name: Light/Switch
selector:
target:
entity:
domain:
- light
- switch
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
trigger:
- platform: state
entity_id: !input motion_entity
from: 'off'
to: 'on'
- platform: state
entity_id: !input motion_entity
to: 'off'
for: !input no_motion_wait
action:
- choose:
- conditions:
- condition: state
entity_id: !input motion_entity
state: "on"
- condition: state
entity_id: !input light_condition
state: "off"
- condition: state
entity_id: !input light_target
state: "off"
sequence:
- service: turn_on
entity_id: !input light_target
- conditions:
- condition: state
entity_id: !input motion_entity
state: "off"
- condition: state
entity_id: !input light_target
state: "on"
sequence:
- service: turn_off
entity_id: !input light_target
default: []
mode: single
If I read the docs, a target selector is to be used with a target in an action, not in a condition. But I never used them before, so I cannot be sure. See the important block in the docs below:
Also see this (rather old) post:
Either way, the service call should also use target: and not entity_id:
I tried to write it in a different style, still got errors:
Message malformed: Unexpected value for condition: ‘None’. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone @ data[‘condition’][0]
blueprint:
name: Motion Light New
description: Turn on a light when motion is detected with a condition
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_condition:
name: Light Condition (off)
selector:
entity:
domain: binary_sensor
device_class: light
light_target:
name: Light/Switch
selector:
target:
entity:
domain:
- light
- switch
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
trigger:
- platform: state
entity_id: !input motion_entity
from: 'off'
to: 'on'
- platform: state
entity_id: !input motion_entity
to: 'off'
for: !input no_motion_wait
condition:
or:
- and:
- condition: state
entity_id: !input motion_entity
state: "on"
- condition: state
entity_id: !input light_target
state: "off"
- condition: state
entity_id: !input light_condition
state: "off"
- and:
- condition: state
entity_id: !input motion_entity
state: "off"
- condition: state
entity_id: !input light_target
state: "on"
action:
- service: "homeassistant.turn_{{trigger.to_state.state}}"
target:
entiry_id: !input light_target
You haven’t corrected the use of the target selector that Edwin pointed out. Generally, if you are limiting the target selector to entities, I would suggest not using target selectors… just use an entity selector.
Other issues:
The Entity selectors that you have are missing the filter key
There were a few other typos.
blueprint:
name: Motion Light New
description: Turn on a light when motion is detected with a condition
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
filter:
- domain: binary_sensor
device_class: motion
light_condition:
name: Light Condition (off)
selector:
entity:
filter:
- domain: binary_sensor
device_class: light
light_target:
name: Light/Switch
selector:
entity:
filter:
- domain:
- light
- switch
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
trigger:
- platform: state
entity_id: !input motion_entity
from: 'off'
to: 'on'
- platform: state
entity_id: !input motion_entity
to: 'off'
for: !input no_motion_wait
condition:
- or:
- and:
- condition: state
entity_id: !input motion_entity
state: "on"
- condition: state
entity_id: !input light_target
state: "off"
- condition: state
entity_id: !input light_condition
state: "off"
- and:
- condition: state
entity_id: !input motion_entity
state: "off"
- condition: state
entity_id: !input light_target
state: "on"
action:
- service: "homeassistant.turn_{{trigger.to_state.state}}"
target:
entity_id: !input light_target