Hello. I am just coming to HA from SmartThings. I’m trying to set up my first blueprint to use with some IKEA sensors/lights. I have an estimated illuminance sensor added and working.
I copied motion_light.yaml
and based mine on it, but I’m getting some errors I cannot successfully diagnose. I had some other errors I was able to figure out, but I’m stuck and I’d appreciate some help.
Goal: Motion-activated lights, but only when it’s dark outside (for the turning on part).
Error when trying to create automation (via GUI) from blueprint:
Blueprint Motion-activated Light When Dark generated invalid automation with inputs OrderedDict([(‘luxe_threshhold’, 20000), (‘luxe_entity’, ‘sensor.estimated_illuminance’), (‘light_target’, OrderedDict([(‘entity_id’, ‘light.redacted_office_lamp’)])), (‘motion_entity’, ‘binary_sensor.test_motion_occupancy’), (‘dont_turn_on_again_wait’, 2), (‘no_motion_wait’, 2)]): Entity entity_id is neither a valid entity ID nor a valid UUID for dictionary value @ data[‘action’][0][‘choose’][0][‘conditions’][1][‘entity_id’]. Got None extra keys not allowed @ data[‘conditions’]. Got None
Blueprint:
blueprint:
name: Motion-activated Light When Dark
description: >
Turn on a light when motion is detected and it's dark.
Forked from: https://github.com/home-assistant/core/blob/b56d332c26d2d4feba696d74785df4625044e08e/homeassistant/components/automation/blueprints/motion_light.yaml
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
selector:
target:
entity:
domain: light
luxe_entity:
name: Illuminance Sensor
selector:
entity:
domain: sensor
luxe_threshhold:
name: Darkness threshold
description: Luxe value of darkness threshold
default: 5000
selector:
number:
min: 0
max: 20000
unit_of_measurement: lx
dont_turn_on_again_wait:
name: Don't turn on again wait time
description: Time to wait for light to be off before turning it on again
default: 240
selector:
number:
min: 0
max: 1140
unit_of_measurement: minutes
no_motion_wait:
name: No motion shut off wait time
description: Time to leave the light on after last motion is detected.
default: 20
selector:
number:
min: 0
max: 1140
unit_of_measurement: minutes
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input motion_entity
conditions:
- or:
- and:
# Turn on when motion is detected and dark
- condition: state
alias: "Motion was detected"
entity_id: !input motion_entity
state: "on"
- condition: state
alias: "Light was off for required time"
entity_id: !input light_target
state: "off"
for:
minutes: !input dont_turn_on_again_wait
- condition: numeric_state
alias: "Light was below threshold"
entity_id: !input luxe_entity
below: !input luxe_threshhold
# Turn off when no motion detected
- and:
- condition: state
alias: "Light was on"
entity_id: !input light_target
state: "on"
- condition: state
alias: "Motion was not detected for required time"
entity_id: !input motion_entity
state: "off"
for:
minutes: !input no_motion_wait
action:
- choose:
- conditions:
# Turn on when motion is detected and dark
- condition: state
alias: "Motion was detected"
entity_id: !input motion_entity
state: "on"
- condition: state
alias: "Light was off for required time"
entity_id: !input light_target
state: "off"
for:
minutes: !input dont_turn_on_again_wait
- condition: numeric_state
alias: "Light was below threshold"
entity_id: !input luxe_entity
below: !input luxe_threshhold
sequence:
- alias: "Turn on the light"
service: light.turn_on
target: !input light_target
# Turn off when no motion detected
- conditions:
- condition: state
alias: "Light was on"
entity_id: !input light_target
state: "on"
- condition: state
alias: "Motion was not detected for required time"
entity_id: !input motion_entity
state: "off"
for:
minutes: !input no_motion_wait
sequence:
- alias: "Turn off the light"
service: light.turn_off
target: !input light_target
Automation it created via the GUI in automations.yaml
:
- id: '1666651165176'
alias: Motion-activated Light When Dark
description: ''
use_blueprint:
path: strawberryfig/motion_light_when_dark.yaml
input:
luxe_threshhold: 20000
luxe_entity: sensor.estimated_illuminance
light_target:
entity_id: light.redacted_office_lamp
motion_entity: binary_sensor.test_motion_occupancy
dont_turn_on_again_wait: 2
no_motion_wait: 2
I feel like I’m almost there, if someone can help get me across the finish line. Thanks!