Auto dim lights above sensor threshold

Some background behind this
The family of the household like to go around flipping off lights by the physical switches. This causes issues with automations and lighting. There’s also the problem with some lights where if you turn them off and back on, they are set to turn on to 100% brightness. I set up multiple sensors for my lights to determine if the lights are too bright and built the automations one by one for each light and area. I know there are better ways to go about building this but it works for now.

Inside of sensors.yaml, you will need to add the sensor for the entity. I’m sure there’s a way to set this programatically and would love to see improvements or suggestions on how to achieve that.

      brightlight_testbulb:
        friendly_name: Light TestBulb is Over Limit
        value_template: >-
          {% if state_attr('light.test', 'brightness') | float > 155 %}
            true
          {% else %}
            false
          {% endif %}

The blueprint allows to set the transition time and target brightness. I’m going to add a few more options later. Since this is my first blueprint, I thought it would be best to keep things simple.

blueprint:
  name: Light is too bright
  description: The target entity or group of lights is over the predetermined brightness as set in sensors.yaml
  domain: automation
  input:
    sensor:
      name: Brightlight Sensor
      description: Custom sensor in sensors.yaml
      selector:
        entity:
          domain: sensor
    target_light:
      name: Lights
      description: The lights to reduce brightness
      selector:
        target:
          entity:
            domain: light
    transition_time:
      name: Transition time in seconds
      default: 30
      selector:
        number:
          min: 0
          max: 300
          unit_of_measurement: seconds
    brightness_percent:
      name: Brightness Percentage
      default: 10
      selector:
        number:
          min: 1
          max: 100
          unit_of_measurement: "%"
          mode: slider

trigger:
  - platform: state
    entity_id: !input sensor

action:
  - service: light.turn_on
    target: !input target_light
    data:
      transition: !input transition_time
      brightness_pct: !input brightness_percent

I’m looking for something very similar to this but not sure if this blueprint will do.
Similar to your situation, everybody in this household uses the physical buttons to turn on/off the smart lightbulbs. I also want to avoid having 100% brightness when this happens. The main difference is that I won’t use a sensor but the time of day to set the default brightness.

Is the transition time required? I’m guessing this is the time it takes to go from 100% brightness to some default value (10%?). What I want to see is, as an example, set the brightness to 20% after 10 pm as soon as the lightbulb is turned on. I really want to avoid 100% brightness, especially if it’s the middle of the night.

I use Adaptive Lighting for those. I use the transition to adapt to a better brightness (not 100%) without the end user noticing the difference. So instead of 100%, over time it goes down to 75% or even possibly 40% without them noticing any difference. Adaptive lighting will do the same, but there is no control over the transition period. So if you turn on the lights at night, it will dim them rapidly (or instant once connected) down to the set amount by AL (adaptive lighting). I needed something quite a bit more subtle. I had a light that when left on at 100% for longer than 10 minutes would lose the RED value… but if kept under 75% it worked great. I used AL for a while, but the wife.unit() kept complaining it never stayed bright enough. When I used a 5 to 10 minute transition, I never heard a complaint once.

1 Like