blueprint:
name: Motion-activated Light After Dark
description: Turn on a light when motion is detected after the sun is below the horizon.
domain: automation
source_url: https://github.com/home-assistant/core/blob/551fb449752e1c3f55eb688d24509876020852d1/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
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
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
condition:
- condition: state
entity_id: sun.sun
state: below_horizon
- condition: state
entity_id: !input light_target
state: "off"
action:
- service: light.turn_on
data:
transition: 4
brightness_pct: 60
kelvin: 3000
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target: !input light_target
The error is due to a modification you made to an existing blueprint. You added two State Conditions where the second one references the blueprint’s Target Selector. Target Selectors aren’t meant to be used with a State Condition.
I suggest you consider replacing the Target Selector with an Entity Selector. However, this will then require that you modify both service calls to work with an Entity Selector because they’re currently designed to work exclusively with a Target Selector.
Delete your existing automation and then change the blueprint to this (the Target Selector has beed replaced by an Entity Selector and both service calls have been adapted to use it).
blueprint:
name: Motion-activated Light After Dark
description: Turn on a light when motion is detected after the sun is below the horizon.
domain: automation
source_url: https://github.com/home-assistant/core/blob/551fb449752e1c3f55eb688d24509876020852d1/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
entity:
domain: light
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
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
condition:
- condition: state
entity_id: sun.sun
state: below_horizon
- condition: state
entity_id: !input light_target
state: "off"
action:
- service: light.turn_on
data:
transition: 4
brightness_pct: 60
kelvin: 3000
target:
entity_id: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target:
entity_id: !input light_target
After you have modified the blueprint, you’ll need to execute Reload Automations then use the blueprint to create a new automation. This new automation shouldn’t produce the same error message.
blueprint:
name: Motion-activated Light After Dark
description: Turn on a light when motion is detected after the sun is below the horizon.
domain: automation
source_url: https://github.com/home-assistant/core/blob/551fb449752e1c3f55eb688d24509876020852d1/homeassistant/components/automation/blueprints/motion_light.yaml
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
entity:
domain: light
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
after_time:
name: 'After: '
description: runs only after this time.
default: '23:59:59'
selector:
time:
before_time:
name: 'Before: '
description: runs only before this time.
default: '05:00:00'
selector:
time:
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
condition:
condition: time
after: !input 'after_time'
before: !input 'before_time'
action:
- service: light.turn_on
data:
transition: 4
brightness_pct: 60
kelvin: 3000
target:
entity_id: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target:
entity_id: !input light_target