We have mostly Lutron Caseta light dimmers throughout our home, and they work great. Paired with the Lutron transition python script, it also gives us nice transition capability.
For our rooms with smart switches, I have “lights on” automation when motion is detected with additional conditions for weather (cloudy, rainy, etc), sun elevation, and time of day that control brightness and activation, and I have “lights off” if no motion within a specific time automations. Those work well most of the time, but occasionally I will be in a corner of the kitchen chopping vegetables without much movement and the lights will go out.
In our walk-in closets, we have Lutron Maestro “dumb” motion switches. They sense motion, turn on for a specific time, then dim to about half brightness near the end of the cycle, wait a few seconds, then turn off if no motion is detected. If motion is detected while dimmed, they ramp back to full brightness. It’s a nice method to avoid being left in a dark room – a blackout warning, I’d like to reproduce that effect.
If I could have the smart lights dim like the Lutron Maestro, I would know to move, and basically reset the light and cancel the lights from turning off.
I have some ideas on how to accomplish this that range from simple to complex, but curious if anyone has already done something like this and would be willing to share their automation code.
In case any else is interested in this, I have a simple way working now. With input_selects and tracking states, I’m sure something more elaborate could be done, but this works for now.
Here are the automations for the kitchen as an example:
Our dining room and kitchen are combined, so if the dining room light is on, we prevent the lights from turning off. In this example, the lights give a warning dim at 4 min 30 secs, and if no movement, will go off 30 secs later. If movement is detected within that 30 sec window, the lights will come back on.
#############################################################
# Kitchen Lights ON
#############################################################
- id: '20191218120003'
alias: Lights Kitchen On If Motion Detected and Dark
description: ''
trigger:
- platform: state
entity_id: binary_sensor.kitchen_motion
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: light.kitchen_main_lights
value_template: '{% if states.light.kitchen_main_lights.state == "on" %}{{ states.light.kitchen_main_lights.attributes.brightness }}{% else %}0{% endif %}'
below: 50
- condition: state
entity_id: sensor.low_light
state: 'True'
action:
- service: light.turn_on
entity_id:
- light.kitchen_main_lights
data_template:
brightness: >
{% if now().hour >= 23 %}150
{% elif now().hour < 7 %}50
{% else %}255
{% endif %}
#############################################################
# Kitchen Lights OFF Warning
#############################################################
- id: '20200118132100'
alias: Lights Kitchen Off Warning When No Motion
description: ''
trigger:
- platform: state
entity_id: binary_sensor.kitchen_motion
from: 'on'
to: 'off'
for: 00:04:30
condition:
- condition: state
entity_id: light.kitchen_main_lights
state: 'on'
- condition: state
entity_id: light.dining_room_chandelier
state: 'off'
action:
- service: light.turn_on
entity_id:
- light.kitchen_main_lights
data_template:
brightness: 20
#############################################################
# Kitchen Lights OFF
#############################################################
- id: '20191218120008'
alias: Lights Kitchen Off When No Motion
description: ''
trigger:
- platform: state
entity_id: binary_sensor.kitchen_motion
from: 'on'
to: 'off'
for: 00:05:00
condition:
- condition: state
entity_id: light.kitchen_main_lights
state: 'on'
- condition: state
entity_id: light.dining_room_chandelier
state: 'off'
action:
- service: light.turn_off
entity_id:
- light.kitchen_main_lights
And here are the sensors in use. We live in a heavily wooded forest, so our sun elevation settings are probably earlier than most. It gets darker sooner for us.
#===================================
#=== Weather Sensors from Dark Sky
#===================================
- platform: darksky
api_key: !secret darksky_api_key
monitored_conditions:
- cloud_cover
scan_interval:
# At least one of these must be specified:
days: 0
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
#===================================
#=== Low Light Sensor (Template)
#===================================
- platform: template
sensors:
low_light:
friendly_name: "Low Light"
value_template: '{{ (states.sensor.dark_sky_cloud_coverage.state|float > 50) or (state_attr("sun.sun", "elevation") < 20 )}}'