reinder83
(Reinder Reinders)
December 14, 2020, 9:39am
1
I have added an sun elevation check to the motion detect blueprint, so the lights only go on when it’s dark outside.
Gist URL: https://gist.github.com/reinder83/8c5838c16af8f6ec3d7cb5258444b8b8
Get started
Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
blueprint:
name: Motion-activated Light with Elevation
domain: automation
source_url: https://gist.github.com/reinder83/8c5838c16af8f6ec3d7cb5258444b8b8
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 wait until the light should be turned off.
default: 120
selector:
number:
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
below_elevation:
name: Below sun elevation
description: Solar elevation. This is the angle between the sun and the horizon.
Negative values mean the sun is below the horizon.
default: 3
selector:
number:
min: -90.0
max: 90.0
unit_of_measurement: degrees
step: 1.0
mode: slider
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input 'motion_entity'
from: 'off'
to: 'on'
variables:
below_elevation: !input 'below_elevation'
condition:
- '{{ state_attr(''sun.sun'',''elevation'') <= (below_elevation | float)}}'
action:
- service: light.turn_on
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'
10 Likes
gald33
(Gal)
December 17, 2020, 9:08pm
2
Awesome!
I have an upgrade suggestion that will be great (for me at least ).
At night I use a red light if I wake up because it has no blue so it’s easier to stay sleepy. It would be nice to be able to set a color (or to add data) in the blueprint.
Either way, thanks!
reinder83
(Reinder Reinders)
December 17, 2020, 9:28pm
3
Ah, my light is a simple on/off, but feel free to use this blueprint to create your own
goldbe4804
(jeff goldberg)
December 20, 2020, 4:02pm
4
sorry for my mix up — so if i have elevation at “0” this should turn the light on when the sun goes below horizon, right ?
reinder83
(Reinder Reinders)
December 20, 2020, 5:03pm
5
Yup, I have it set myself at 3, because it starts getting dark once it’s below 3
1 Like
r3mcos3
(R3mcos3)
December 20, 2020, 5:42pm
6
for me the blueprint is not working with this in the logs.
Logger: homeassistant.helpers.condition
Source: helpers/condition.py:458
First occurred: 5:20:40 PM (8 occurrences)
Last logged: 6:27:11 PM
Error during template condition: TypeError: '<=' not supported between instances of 'float' and 'str'
1 Like
reinder83
(Reinder Reinders)
December 20, 2020, 5:49pm
7
How did you add it, when I add through the UI it’s just fine, make sure it’s setup like this in the automation:
- id: '1608486330207'
alias: Motion-activated Light with Elevation
description: ''
use_blueprint:
path: reinder83/motion_light_with_elevation.yaml
input:
below_elevation: 3
motion_entity: binary_sensor.pir_driveway
light_target:
entity_id: light.driveway_light
below_elevation should be numeric
r3mcos3
(R3mcos3)
December 20, 2020, 5:53pm
8
- id: '1608481223494'
alias: Prullenbak
description: ''
use_blueprint:
path: reinder83/motion-detect-lights-with-elevation-check.yaml
input:
below_elevation: '3'
motion_entity: binary_sensor.kitchen_door_sensor
light_target:
entity_id:
- light.patio_led_1
- light.patio_led_2
the only thing i’ve changed is the device_class to opening to work with my door sensor
reinder83
(Reinder Reinders)
December 20, 2020, 6:14pm
9
I have done an update the to blueprint, could you try again?
1 Like
r3mcos3
(R3mcos3)
December 20, 2020, 6:23pm
10
Now it’s working, thnx for fixing
rajkedda
(Raj)
December 22, 2020, 1:26am
11
Is it possible to use multiple binary sensors for motion entity?
reinder83
(Reinder Reinders)
December 22, 2020, 9:27am
12
You can only select one motion sensor for this blueprint, but what you could do the following:
create an template binary sensor, I just tested with the sensor below and that seems to work:
- platform: template
sensors:
all_motion_sensors:
device_class: motion
friendly_name: "All motion sensors"
value_template: >-
{{ is_state('binary_sensor.hall_motion', 'on') or is_state('binary_sensor.pir_driveway', 'on') }}
Put that under binary_sensor: in your configuration.yaml
rajkedda
(Raj)
December 23, 2020, 5:07pm
13
Thank you. I setup the binary sensor template as suggested.
rajkedda
(Raj)
December 24, 2020, 1:47am
14
Its working great. Thanks again.
cnmarch6
(Cnmarch6)
December 24, 2020, 9:30am
15
I don’t use smart bulb but using a switch but it does not give me an option to select a switch. Please help
reinder83
(Reinder Reinders)
December 24, 2020, 10:39am
16
jwelter
(John Welter)
December 24, 2020, 3:26pm
18
One thing I am trying to understand with blueprints is why for some variables we pass to the blueprint we also define under variables?
Is this to just reduce having to specify !input if they are used multiple times in the blueprint?
reinder83
(Reinder Reinders)
December 24, 2020, 3:38pm
19
Because you need a variable in the template, the !input wont work there
jwelter
(John Welter)
December 24, 2020, 3:41pm
20
Yes, that makes sense but I see many who just set variables for all things passed to the blueprint.