I changed the default motion sensor blueprint to match any switch!
Turn on switch when motion is detected. Leave it on for X seconds after motion is detected.
Edit 2020-12-17: Added time conditions, hope it works.
Get started
Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
blueprint:
name: Motion-activated Switch
description: Turn on a switch when motion is detected.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
lightsensor_entity:
name: Illuminance Sensor
selector:
entity:
domain: sensor
device_class: illuminance
illuminace_level:
name: Max Illuminance
description: Maximal immuminance level in lux. If illuminance is higher, light
will not be enabled
default: 300
selector:
number:
min: 0.0
max: 5000.0
unit_of_measurement: lux
mode: slider
step: 1.0
switch_target:
name: Switch
selector:
target:
entity:
domain: switch
time_from:
name: Active from
description: A time input which defines the time from which motion is detected
selector:
time: {}
time_to:
name: Active to
description: A time input which defines the time to which motion is detected
selector:
time: {}
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
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input 'motion_entity'
from: "off"
to: "on"
condition:
- condition: and
conditions:
- condition: time
after: !input 'time_from'
before: !input 'time_to'
- condition: numeric_state
entity_id: !input 'lightsensor_entity'
below: !input 'illuminace_level'
action:
- service: switch.turn_on
target: !input 'switch_target'
- wait_for_trigger:
platform: state
entity_id: !input 'motion_entity'
from: "on"
to: "off"
- delay: !input 'no_motion_wait'
- service: switch.turn_off
target: !input 'switch_target'
Perhaps consider adding a time condition, so the trigger only happens during specific hours of the day?
i.e. If I use this for light switches, I donât want this executing during âdaylightâ, so I might want to limit to âdarkâ hours or between sunset/sunrise etc.
I created a config with that, but also struggle with the missing condition feature like sun state or time. Even the room has enough light, it always triggers the lights. I also use tuya wifi switches and canât use them here, only my lightify via services or Philips via device config are selectable. I have some lights controlled with power plugs, they also wonât appear to select.
Would be cool if you could extend it to define/use dependencies and more devices like power plugs and wall switches.
I donât believe more features will be added. Itâs just an exact copy of the original, but it uses switch instead of light. Try asking in #configuration:blueprints and see if anyone will help you.
Iâm the first to admit that Iâm not a programmer, I try to learn but donât have much time to spare.
I tried with this, tell me if it donât work!
blueprint:
name: Motion-activated Switch
description: Turn on a switch when motion is detected.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
lightsensor_entity:
name: Illuminance Sensor
selector:
entity:
domain: sensor
device_class: illuminance
illuminace_level:
name: Max Illuminance
description: Maximal immuminance level in lux. If illuminance is higher, light
will not be enabled
default: 300
selector:
number:
min: 0.0
max: 5000.0
unit_of_measurement: lux
mode: slider
step: 1.0
switch_target:
name: Switch
selector:
target:
entity:
domain: switch
time_from:
name: Active from
description: A time input which defines the time from which motion is detected
selector:
time: {}
time_to:
name: Active to
description: A time input which defines the time to which motion is detected
selector:
time: {}
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
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input 'motion_entity'
from: "off"
to: "on"
condition:
- condition: and
conditions:
- condition: time
after: !input 'time_from'
before: !input 'time_to'
- condition: numeric_state
entity_id: !input 'lightsensor_entity'
below: !input 'illuminace_level'
action:
- service: switch.turn_on
target: !input 'switch_target'
- wait_for_trigger:
platform: state
entity_id: !input 'motion_entity'
from: "on"
to: "off"
- delay: !input 'no_motion_wait'
- service: switch.turn_off
target: !input 'switch_target'
Not yet. I just imported the blueprint and went to the file editor and opened this blueprint and the error shows up instantly. Have not created the automation yet.