If you set up different brightness levels in different scenes you can have those scenes called at certain times when there is motion detection
Hello @networkingcat ,
Thank you for this best blueprint. But I still have one wish. Can still come an extra option for the illuminance sensor? Have often in bad weather that it is already quite dark during the day. That would be a perfect extra option for this wonderful Blueprint.
Thanks
That sounds like a reasonable solutionā¦ But I still think that a blueprint of this nature should optionally include brightness and colour temperature as thatās a very common need in this type of automation.
EDIT: Also I have a sensor tracking the sun that I would rather use than the provided scene options. So if it were possible to use that as the trigger it would be even better.
EDIT2: Iāve set a scene for evening which starts at 6pm. I notice that it always triggersā¦ Is that because all the other scenes are set to none with time set at 00:00:00?
Feday I have the same setup and find it frustrating that the light doesnāt turn off when the ādark modeā (as input blocker) has changed in the meantime.
How did you changed the blueprint to disable this condition? Itās maybe my lack of knowledge but I donāt seem to change the installed blueprint in my HA
Hi there,
I have run into a problem with this automation. I turn the lights on when motion is detected and the sun is below 15Ā°, and I leave the lights on for 120 seconds. This works fine, for one exception. When the automation is triggered when the sun is at 14.9Ā°, the automation turns the lights on, But 2 minutes later the sun is at 15.1Ā° and the lights are not turned off. Is there a way to fix this? I tried finding a blueprint that turns off the lights at a particular sunrise elevation, but I couldnāt find it.
Frans
Hmm, exactly what I also is after. After years of using home assistant I finally bought my first motion sensor. Guess I need to update myself in blueprints / scripting as I up until now only had a rather simple HA setup.
Or does anyone know of a ready made blueprint that does this (ie, create a temporary scene when motion is triggered, set another scene for a specific time and then restore to the temporary scene?)
Hey Guys,
So this is a dumb question but basically if I want to be able to run this automation when sun is down aka at night time, what should the elevation setting be?
0ā?
Is it if itās the below-set angle, say 0 run automation, if its above, donāt run?
Is it possible to have multiple automation blocker entities?
I also would wish transition for scenes. Maybe just one input value to blue print, that is then used in all actions.
Made a quick fork to add transitions. You can try it out. I hope that @networkingcat includes this to main if good enough.
Iām still a beginner in home automation. Your script helped me a lot to understand yaml better. I use automation for several lights. I noticed some misconduct. If the motion detector triggers the automation to switch on before sunrise and then should trigger a little later, but after sunrise, to switch it off, the light will no longer go out.
I have an issue with the automation.
Because i set scene.none
for scene_day
the lights get triggered by the scene_morning
.
Is this a bug or i didnāt set the automation correct.
From my understanding, if I set scene.none
the motion should not trigger in that time frame any scene.
thx
alias: Lights Kitchen activated by motion
description: ''
use_blueprint:
path: networkingcat/yet_another_motion_automation.yaml
input:
motion_entity: group.kitchen_motion
light_target:
entity_id:
- light.dinning
- light.kitchen
no_motion_wait: 600
no_motion_blocker: input_boolean.scene_motion_detection_is
no_motion_blocker_boolean: false
scene_morning: scene.light_kitchen_brightness_100_2700k
time_scene_morning: '06:45:00'
time_scene_day: '09:00:00'
scene_evening: scene.light_kitchen_brightness_100_5600k
time_scene_evening: '16:00:00'
scene_night: scene.light_kitchen_brightness_10_2700k
time_scene_night: '23:00:00'
scene_no_motion: scene.light_kitchen_off
It can be controlled by this blueprint but you need to present your switch in HA as a light, see this documentation.
Thanks for sharing this!
I quickly went through the yaml and wanted to clarify one thing.
If I use the no motion blocker to block lights going off - will they go off when the blocker is turned back off? If thatās a yes, will the time from last detection motion affect this?
Example:
I turn on the lights with a switch on the wall.
If I do that I donāt want my motion sensor automations turning them off for at least 10 minutes after the motion stopped.
If itās the motion sensor that turns lights on I want them off 30 seconds after no motion is detected.
I would use the no motion blocker for the switch and set it myself for 10 minutes.
Will the automation still disable the lights in this case?
So wait time set to 30 seconds. Blocker set manually for 10 minutes after motions is no longer detected.
Since a condition for the blocker is used and not a wait_template Iād assume thatās a no but Iām a newbie when it comes to complex automations so wanted to confirm if I need to adapt it myself.
I do have the same issue, or i also donāt fully understand the automation setupā¦
I dont wont to trigger the light during the day.
to my understanding scene.none means lights off!?
I added a couple extra ones to my tweaked version of this. I think Iām posting this right for you.
blueprint:
name: My Personal Motion Activation Blueprint
description: >
# YAMA V10
Turn on lights or scenes when motion is detected.
Four different scenes can be defined depending on time of day.
For Details see this forum post:
https://community.home-assistant.io/t/yama-yet-another-motion-automation-scenes-ambient-light-and-some-conditions/257062?u=networkingcat
Capabilitys:
- Trigger on motion (in fact can be triggered by anything that switches between āonā and off")
- Wait time for turning off
- Only run if entity is in desired state (optional)
- Sun elevation check (optional)
- 4 Scenes for different times of day (optional)
- Ambient support with time frame (optional)
- Default scene when motion stops (optional)
- āno motion blockerā with user choosable state (optional)
domain: automation
# source_url: https://gist.github.com/networkingcat/a1876d7e706e07c8bdcf974113940fb8
input:
motion_entity:
name: Motion Sensor
description: Motion Sensor or a group with Motion Sensors (But can be anything switching between "on" and "off")
selector:
entity:
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
automation_blocker_01:
name: Automation Blocker 01 (Optional)
description: Only run if this boolean is in desired state (see next input)
default:
selector:
entity:
automation_blocker_boolean_01:
name: Automation Blocker Chooser 01 (Optional)
description: Desired state of automation blocker, choose on for on and off for off
default: false
selector:
boolean:
automation_blocker_02:
name: Automation Blocker 02 (Optional)
description: Only run if this boolean is in desired state (see next input)
default:
selector:
entity:
automation_blocker_boolean_02:
name: Automation Blocker Chooser 02 (Optional)
description: Desired state of automation blocker, choose on for on and off for off
default: false
selector:
boolean:
automation_blocker_03:
name: Automation Blocker 03 (Optional)
description: Only run if this boolean is in desired state (see next input)
default:
selector:
entity:
automation_blocker_boolean_03:
name: Automation Blocker Chooser 03 (Optional)
description: Desired state of automation blocker, choose on for on and off for off
default: false
selector:
boolean:
no_motion_blocker:
name: No Motion Blocker (Optional)
description: No motion sequence is not run if this boolean is in desired state (see next input)
default:
selector:
entity:
no_motion_blocker_boolean:
name: No Motion Chooser (Optional)
description: Desired state of no motion blocker, choose on for on and off for off
default: false
selector:
boolean:
elevation_check:
name: Sun elevation check (Optional)
description: This is the angle between the sun and the horizon. Negative values mean the sun is BELOW the horizon.
default: none
selector:
number:
min: -90
max: 90
unit_of_measurement: degrees
scene_ambient:
name: Ambient Scene (Optional)
description: Scene for ambient state. Will be activated when no motion is detected.
default: scene.none
selector:
entity:
domain: scene
time_scene_ambient_start:
name: Ambient time frame start (Optional)
description: Time from which on ambient scene will be activated
default: "00:00:00"
selector:
time:
time_scene_ambient_end:
name: Ambient time frame end (Optional)
description: Time from which on ambient scene will be not activated
default: "00:00:00"
selector:
time:
scene_morning:
name: Scene for the morning (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_morning:
name: Time for the morning scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_day:
name: Scene for the bright day (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_day:
name: Time for the day scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_evening:
name: Scene for the evening (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_evening:
name: Time for the evening scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detected.
default: "00:00:00"
selector:
time:
scene_night:
name: Scene for the dark night (Optional)
default: scene.none
selector:
entity:
domain: scene
time_scene_night:
name: Time for the night scene (Optional)
description: A time input which defines the time from which on the scene will be activated if motion is detectedd.
default: "00:00:00"
selector:
time:
scene_no_motion:
name: Default scene for no motion (Optional)
description: Set this Scene if you want to activate a scene if motion stops
default: scene.none
selector:
entity:
domain: scene
mode: restart
max_exceeded: silent
variables:
scene_ambient: !input scene_ambient
scene_morning: !input scene_morning
scene_day: !input scene_day
scene_evening: !input scene_evening
scene_night: !input scene_night
automation_blocker_01: !input automation_blocker_01
automation_blocker_boolean_01 : !input automation_blocker_boolean_01
automation_blocker_02: !input automation_blocker_02
automation_blocker_boolean_02 : !input automation_blocker_boolean_02
automation_blocker_03: !input automation_blocker_03
automation_blocker_boolean_03 : !input automation_blocker_boolean_03
no_motion_blocker: !input no_motion_blocker
no_motion_blocker_boolean: !input no_motion_blocker_boolean
elevation_check: !input elevation_check
scene_no_motion: !input scene_no_motion
motion_entity: !input motion_entity
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
- platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
for: !input no_motion_wait
# All Conditions must be true
condition:
# Check if automation blocker exist or is in desired state, otherwise do not run
- condition: or
conditions:
- "{{ automation_blocker_01 == none }}"
- "{{ automation_blocker_boolean_01 and states[automation_blocker_01].state == 'on' }}"
- "{{ not automation_blocker_boolean_01 and states[automation_blocker_01].state == 'off' }}"
# Check if automation blocker exist or is in desired state, otherwise do not run
- condition: or
conditions:
- "{{ automation_blocker_02 == none }}"
- "{{ automation_blocker_boolean_02 and states[automation_blocker_02].state == 'on' }}"
- "{{ not automation_blocker_boolean_02 and states[automation_blocker_02].state == 'off' }}"
- condition: or
conditions:
- "{{ automation_blocker_03 == none }}"
- "{{ automation_blocker_boolean_03 and states[automation_blocker_03].state == 'on' }}"
- "{{ not automation_blocker_boolean_03 and states[automation_blocker_03].state == 'off' }}"
# Check if elevation input exist or is below desired value, otherwise do not run
- condition: template
value_template: "{{ (elevation_check == none) or (state_attr('sun.sun','elevation') <= elevation_check | float(90)) }}"
action:
- choose:
# Trigger to state == "on"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
sequence:
- choose:
# Morning Scene
- conditions:
- "{{ scene_morning != 'scene.none'}}"
- condition: time
after: !input time_scene_morning
before: !input time_scene_day
sequence:
- scene: !input scene_morning
# Day Scene
- conditions:
- "{{ scene_day != 'scene.none'}}"
- condition: time
after: !input time_scene_day
before: !input time_scene_evening
sequence:
- scene: !input scene_day
# Evening Scene
- conditions:
- "{{ scene_evening != 'scene.none'}}"
- condition: time
after: !input time_scene_evening
before: !input time_scene_night
sequence:
- scene: !input scene_evening
# Night Scene
- conditions:
- "{{ scene_night != 'scene.none'}}"
- condition: time
after: !input time_scene_night
before: !input time_scene_morning
sequence:
- scene: !input scene_night
# If State -> "On" defaulting to turn light on
default:
- service: light.turn_on
target: !input light_target
# Trigger to state = "off"
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
# Check if no motion blocker exist or in in desired state, otherwise do not run any no motion action
- condition: or
conditions:
- "{{ no_motion_blocker == none }}"
- "{{ no_motion_blocker_boolean and states[no_motion_blocker].state == 'on' }}"
- "{{ not no_motion_blocker_boolean and states[no_motion_blocker].state == 'off' }}"
sequence:
- choose:
# Used if ambient scene is true and in ambient scene time frame
- conditions:
- "{{ scene_ambient != 'scene.none' }}"
- condition: time
after: !input time_scene_ambient_start
before: !input time_scene_ambient_end
sequence:
- scene: !input scene_ambient
# Used if default no motion scene is set
- conditions:
- "{{ scene_no_motion != 'scene.none' }}"
sequence:
- scene: !input scene_no_motion
# If State -> "off" default to turn lights off
default:
- service: light.turn_off
target: !input light_target
Hi,
big thanks for sharing the blueprintā¦i searched for that for a long time
Would it be possible to have a LUX check maybe also for a specific time period of the day e.g daytime?
Cheers
LUX check would be great!!
isnāt this that youāre searching?