💡 Smart lux dimmer - Adjust light brightness depending on light sensor value

Get it now:

Smart Lux Dimmer (BASIC)
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Smart Lux Dimmer (ADVANCED)
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.


Introduction:

The Smart Lux Dimmer can turn on or dim a light variably, based on the value of a light sensor:
Turn your lights on gradually when the sun goes down? Turn on your desk lamp when the office gets too dark, or turn lights off when there is enough light available. It’s all possible.

How it works:

Set maximum and minimum ambient light values between which the automation will run. The light will vary brightness between the settings at maximum and minimum light value based on the sensor reading.
Optional values can be set for the brightness, color or temperature when the ambient light goes outside of set measuring range.

Example 1: (BASIC)

  • Max ambient: 400 lux (± sunset value)
  • Min ambient: 0 lux (nighttime)
  • Brightness at max ambient: 0%
  • Brightness at min ambient: 100%
  • No other options activated

→ The above example will start slowly turning up the light until full brightness when the ambient value drops from 400 to 0 (sunset to night).

Example 2: (ADVANCED)

  • Condition: I am home
  • Max ambient: 350 lux
  • Min ambient: 50 lux
  • Brightness at max ambient: 70%
  • Brightness at min ambient: 40%
  • Include values under min and over max: yes
  • Brightness over max ambient: 0%
  • Brightness under min ambient: 40%
  • Include color or temperature values when outside range: Include color
  • Color when ambient light value under min: [231,158,10] (warm orange)

→ This is how I use it in my office space.
It will turn on the light at 70% when the ambient light drops under 400 lux (for example when it’s cloudy outside during the day, or when the sun starts to set) and will actually dim the light down to 40% around late sunset-nighttime so that there is not too much light, which might cause eye fatigue.
When the ambient light goes over the maximum threshold, the light is turned off.
When it goes under the minimum it will remain at 40%, but will turn a warm orange color


Credits:


Most important versions:

SMART LUX DIMMER VERSION 4.1 (ADVANCED)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

:link: Source code (Github)
:gear: See code changes (Github)

SMART LUX DIMMER VERSION 2.0 (BASIC)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

:link: Source code (Github)


:memo:Changelog:

07/01/2024 - Version 4.1

  • Added a transition timer to smoothen out the dimming from the current brightness setting to the next
  • General code correction for uniformity
  • Spelling corrections
Open to see older changes.

18/12/2023 - Version 4.0:

  • Combined all functions of previous versions into 1 Blueprint:
    • Removed separate time and day conditions and added a condition selector instead (It’s pre-set with a ‘Time’ condition, but this can be removed if not needed)
    • Added selector to activate color or temperature values for the light (only 1 at a time is allowed by the light.turn service) - ( Only works if the light entity supports color or temperature values! )
    • Added boolean selector to activate brightness values outside of the measuring range
    • Added selector to activate color or temperature values outside of the measuring range - ( Only works if the light entity supports color or temperature values! )
  • General debugging of the code
  • Modified names and descriptions to improve usability.
  • The name of the blueprint has been updated to Smart Lux Dimmer

:warning: BREAKING :warning: - I’ve created a new Github Gist to bring everything together. This means that a re-import in Home Assistant of the older versions will not work. You need to import the latest version (4.0 and up) to be able to use the re-import function and stay up-to-date.

22/11/2023

  • Released Version 2.3:
    Added a conditions selector, so users can add their own conditions that prevent the automation from running.

  • Released Version 3.3:
    Added a conditions selector, so users can add their own conditions that prevent the automation from running.

18/11/2023

  • Split development in 2: Version 2.x and Version 3.x
    (Both versions will be maintained (when I have the time), but since they focus on different use cases, they will be viewed a separate projects.)

  • Released Version 2.2:
    (removed light temperature adjustments. This was a breaking change a while ago where no color values and temperature values could be sent to the light.turn_on service at the same time.)

  • Released Version 3.2 (BETA)
    (Removed light temperature adjustments. This was a breaking change a while ago where no color values and temperature values could be sent to the light.turn_on service at the same time.)

10/01/2023 - Version 3.0( Known issues)

  • BREAKING: Added feature to set light values when going over and under max and min measured light values.

Please download the newest version and recreate the automations if you experience issues.

09/01/2023 - Version 2.1 ( known issues)

  • BREAKING: Added color and temperature settings for the light. These are fixed values and are not affected when the light changes brightness values.

Please download the newest version and recreate the automations if you experience issues.

28/03/2022 - Version 2.0 → !! LAST SIMPLE VERSION !!

  • BREAKING: Updated brightness values to percentages to improve user experience.
    This version is not compatible with older ones. If you experience issues, please download the latest release and recreate the automations.

22/03/2022 - Version 1.3

  • Simplified the code for the day condition

22/03/2022 - Version 1.2

  • BREAKING: Added day condition support.
    Please download the newest version and recreate the automations if you experience issues.

21/03/2022 - Version 1.1

  • BREAKING: Added start & stop time conditions
    Please download the newest version and recreate the automations if you experience issues.
  • Added versioning
  • Added source url

19/03/2021 - Version 1.0

  • Original release
11 Likes

Lol I see from the date of the post you relied on that we were just in lockdown. No wonder I had time to post all that explanation. My usual response to “how did you work out that formula?” would be “I had a good maths teacher when I was 14”.

1 Like

Don’t be too humble, the explanation has helped a lot indeed.
I’ve added your teacher to the credits list :wink:

1 Like

That’s a super nice idea! My lux automation was way to complicated. Many thanks to AntonH for the great automation and to nickrout for the maths basics.

1 Like

New Release
21/03/2022 - Version 1.1

  • Added start & stop time conditions
  • Added versioning
  • Added source url

New Release
22/03/2022 - Version 1.2

  • BREAKING: Added day condition support.
    Please download version 1.2 and recreate the automations if you experience issues.

New Release
22/03/2022 - Version 1.3

  • Simplified the code for the day condition

New Release

28/03/2022 - Version 2.0

  • BREAKING: Updated brightness values to percentages to improve user experience.

This version is not compatible with older ones. If you experience issues, please download the latest release and recreate the automations.

Does this blueprint have function to deactivete when not home or no motion detected?

1 Like

Not yet, I’m testing that as we speak.
I run it in my home office space, so I don’t want it to run when i’m not home.

The problem with this is also that if you don’t want this condition, you cannot leave it blank because it will error out. So trial and error for now.

A non flexible solution would be to download the blueprint and then add the condition hardcoded if you want.
You could do something like this:

condition:
  - condition: state
    entity_id: input_boolean.PERSON_IS_HOME
    state: 'on'
1 Like

Super big thank you for publishing this blueprint!

I found it as a really great starting point for my own blueprint… I wanted to dim all the lights in the common areas of my main floor, but I wanted the automation to respect any lights that had been manually controlled.

To solve this, I allow the user to select to a list of light entities, and then the automation loops though them one at a time, checks that the brightness of each light matches the brightness of the previous automation run, and only then does the automation update the brightness of the light. It’s not an entirely foolproof solution, but it seems to work well with my usage.

You can check out my blueprint here.

I’m not done with the changes I intend to make; another thing I am considering is adding some kind of margin to the upper lux threshold, because I found the lux readings from my light sensor can fluctuate a little bit… for example, if I configure the automation to turn the lights on at 500lx - I might get readings like so: 540lx, 520lx, 490lx, 510lx, 475lx… causing the lights to turn on, off and on again. So I was thinking of adding a configurable margin so that when the lights are turned on at 500lx, they don’t turn off again until the lux reading reaches 550 or 600lx.

1 Like

You’re welcome.

The margin could be interesting in some use cases yes.
I have the maximum value set for my office around 350lx. So during a cloudy day it turn on and off regularly.
This is wanted behaviour for me, but I could see it being annoying to deal with for some.
The reason I don’t mind it is that my lights don’t actually switch on and off, but rather fade on and off (set as such in my KNX system), which makes the transitions smooth.

Thanks a lot for publishing this blueprint has worked well for me, one question on some of the lights I have this stops at 7PM if the lights are on they stay on I scheduled another automation to have it turn off after 7PM is there a way to just fit this in as an option? or does it already do this and I missed something? if not I understand either way thank you for your time!

1 Like

Hi,

The automation only turns on or off based on the light sensor value.
Time is not taken into account.

If you want to do this, it’s easiest to just add another automation to turn the light off.
You’ll need to add a condition to this blueprint that would prevent the automation from running after a specific time though, otherwise it might turn it back on.

I noticed you can use markdown in the description of a blueprint.

So I figured it’d be awesome to add a diagram to my blueprint so that the automation is easier to understand during configuration. I labelled the different points on the diagram, and then prefixed the input fields with those labels.

2 Likes

Is there a blueprint like this but to turn on light when motion is detected and then dim depending on light sensor value?

2 Likes

You could just modify the trigger in this blueprint to a motion sensor.

@AntonH thanks so much works great for me. It dimms all the lights in a certain are e.g. sleeping rooms. However the color of my lights changes from warm yellow to bright white using your template. It would be very cool if the color of the bulbs could be integrated to but I’m not sure how. Can anyone support here?

If I got you right, you want to automatically control color temperature. I’ve managed to use Adaptive Lightning integration in combination with smart light dimmer. You need to disable brightness control on Adaptive Lightning, as Smart dimmer takes care of it.

2 Likes

That is even one step further. It would be sufficient for me to set the color of the light to certain value. If I adjust the lights manually (over the light template) I set the color to be more yellowish. However using this automation the lights are automatically set to a color which is more white.

1 Like