Now you can have different timers when the lights should turn of depending on if it is day mode or night mode, set by two input helpers. π«‘
The user can also set a dimmable timer, that will dim the lights when they soon will turn off. This mimics the way Hue does it out of the box, but with more flexibility as you can set this yourself!
I use it in my hallway and bathrooms, to only turn on the hallway lights when it is dark enough. So the lights will only turn on when they are needed. The day and night mode is nice, because you generally want the lights to turn of pretty quickly during the night and not stay on for so long.
The dimming is also a nice addition as it signals that the light is soon to turn of, so if you want it to stay on, wave to the sensor!
Hey mate, I tried all evening to get the Night time helper to work.
It does not matter what I try, I always get this error:
Error: ValueError: could not convert str to datetime: '2023-08-10 08:10:19'
I tried changing my time format of home assistant but it seems to only change how time is displayed.
Have you had that before or got any clue why this could happen?
Running HomeAssistant 2023.7.2 on docker on a synology nas.
small edit
I was wondering if it was possible to instead use sensor.sun_next_rising / sensor_sun_next_setting values for the night time start and stop datetime.
So ive tweaked this to my needs if its useful to anyone else. Ive added in a condition that will allow it to skip. I use it for a togglable night mode so the lights donβt come on in the bedroom when sleeping. Ive also change it to use sunrise and sunset as the night time/day time change.
blueprint:
name: Motion-activated Light with illuminance, nightmode and dimmable
description:
Turn on a light when motion is detected and illuminance is below a
set Lux level. The light will dim before it is turned off to signal that it has
not detected motion in quite a while. There is also two timers, on for daytime
and one for nighttime.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain:
- binary_sensor
device_class:
- motion
multiple: false
lux_entity:
name: Illuminance Sensor
selector:
entity:
domain:
- sensor
device_class:
- illuminance
multiple: false
lux_level:
name: Illuminance level
description:
If lux is below this value and motion is detected, the light will
turn on.
default: 100
selector:
number:
min: 0.0
max: 1000.0
step: 1.0
mode: slider
light_target:
name: Light
selector:
target:
entity:
- domain:
- light
dim_time:
name: Dim light
description:
The light will start dim this many seconds before it is turned
off if no motion has been detected to signal that the light will soon turn
off.
default: 30
selector:
number:
min: 0.0
max: 120.0
unit_of_measurement: seconds
step: 1.0
mode: slider
no_motion_wait_day:
name: Wait time (day)
description:
Time to leave the light on after last motion is detected during
the day.
default: 300
selector:
number:
min: 0.0
max: 600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
no_motion_wait_night:
name: Wait time (night)
description:
Time to leave the light on after last motion is detected during
the night.
default: 120
selector:
number:
min: 0.0
max: 600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
skip_condition:
name: Skip Condition
description: Enter an entity that should be used to disable this automation.
selector:
entity: {}
default: ""
source_url: https://gist.github.com/Danielbook/ad8dacabb8dc01e7cf062cbd8c1a00ed
mode: restart
max_exceeded: silent
variables:
local_motion_delay_day: !input no_motion_wait_day
local_motion_delay_night: !input no_motion_wait_night
local_motion_dim_time: !input dim_time
local_skip_condition: !input skip_condition
sun_entity: sun.sun
trigger:
platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: !input lux_entity
below: !input lux_level
- condition: template
value_template: >
{{ local_skip_condition == '' or is_state(local_skip_condition, 'off') }}
action:
- service: light.turn_on
target: !input light_target
- wait_for_trigger:
platform: state
entity_id: !input motion_entity
from: "on"
- delay: " {% if is_state('sun.sun', 'above_horizon') %}
{{ local_motion_delay_day - local_motion_dim_time }} {% else %} {{ local_motion_delay_night
- local_motion_dim_time }} {% endif %} "
- service: light.turn_off
target: !input light_target
data:
transition: !input dim_time