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

The max brightness value is set at 1000 lux becuase I figured there would be no need to go any higher. (I don’t think you’d need any light turned on if the ambient light value is already at 1000 lux)
Is there a specific use case you’re looking at?

This is amazing! I’m impressed with how natural this feels, I have not paid any attention to light levels for a long time :slight_smile:

But, I have a question. I have spots where the brightness is oversized so that I normally only use around 40% of the maximum brightness. However, when I have to do some work or cleaning, I would like to increase the intensity, but then smart lux overrides.

What is the best way to be able to override smart lux for a short time?

Think something like “if light intensity has been changed manually, set smart lux to pause for 30 minutes for the zone in question”

1 Like

Thank you!
Not particularly, I was just asking. I found the “Brightness when ambient light value over max setting” and i’m using this over 1000 lux.

1 Like

There are conditions that can be set.
I actually have a similar situation, where it dims my lights dynamically in the stairwell, but when we’re cleaning there you’d want the lights to be set at 100%.
We simply have a boolean helper that we set and it prevents the blueprint from running.

1 Like

I think that use case will be very limited, so I’m not modifying the blueprint for everyone.
However, should you feel the need to change it, you could just modify it yourself using the studio code server or a similar add-on.
If you change the max brightness value on line 166 that should allow you to set it to a higher value.
Don’t forget to refresh the automations afterwards: Developer Tools > YAML > YAML configuration reloading and click on ‘Automations’.

1 Like

Installed it yesterday. Works great with my HUE motion sensor. Thank you for your effort

1 Like

Great to hear!

1 Like

Your template works amazing for me as well. One thing, which I think might be missing is, that the automation is triggered automatically once movement is detected. Currently it does only seem to trigger the automation once the light detection sensor is changing, therefore I trigger the automation externally if movement is detected. How do you solve that?

1 Like

Hi @headless,

It’s not missing, it’s just not a feature of this blueprint. The goal here was to have dynamic light based on the light that’s available in the environment.

If you want to use other triggers, I would encourage you to look at my other blueprint: The Everything Light - Trigger a light any way and turn it on in any way
The dynamic lighting setting in that blueprint is based on the logic from this one, but it allows you to use any trigger, including a motion sensor.

This is such a great Blueprint, thank you very much!.
For one room, I’d like to use it “reverted” I use an outside light sensor and when it gets darker (clouds, thunderstorm, etc.), I’d like to get the Lights brighter and vice versa.
I took a look at your code (I can not code by myself) and I think it is not possible to swap the values from max. and min. brightness (so max. brightness is set e.g. to 5% and min. brightness to 45%), because it will result in a negative result of your calculation…
Can you help me with my requirement?

1 Like

Thanks for this blueprint.
I would like to include a feature, which adds a certain delay for the dimmer output.
For example: the light sensor (in my case direct sun light) is jumping because of fast moving clouds and the light output is correspondingly jumping. For such situations it would be great, if the dimmer output would only change in adjustable time intervalls with average values, f.e. the dimmer changes the light only after 60s with an value correspondig to the average light sensor value of the last 60s.

1 Like

Ah, I tested the basic variant only, I see your advanced one uses transition time.
I guess the transition time is doing what I requested? The dimmer changes the light only after the transition time you entered by the slider?

1 Like

hi, I am trying to setup this blueprint but facing a error that I cannot trace …

2024-06-03 20:03:23.378 ERROR (MainThread) [homeassistant.components.automation.gartenlich_smart_lux_dimmer] Gartenlich Smart Lux Dimmer: Choose at step 1: choice 1: Choose at step 1: choice 1: Error executing script. Invalid data for call_service at pos 1: value must be at most 100 for dictionary value @ data['brightness_pct']
2024-06-03 20:03:23.378 ERROR (MainThread) [homeassistant.components.automation.gartenlich_smart_lux_dimmer] Gartenlich Smart Lux Dimmer: Choose at step 1: choice 1: Error executing script. Invalid data for choose at pos 1: value must be at most 100 for dictionary value @ data['brightness_pct']
2024-06-03 20:03:23.378 ERROR (MainThread) [homeassistant.components.automation.gartenlich_smart_lux_dimmer] Gartenlich Smart Lux Dimmer: Error executing script. Invalid data for choose at pos 1: value must be at most 100 for dictionary value @ data['brightness_pct']
2024-06-03 20:03:23.378 ERROR (MainThread) [homeassistant.components.automation.gartenlich_smart_lux_dimmer] Error while executing automation automation.gartenlich_smart_lux_dimmer: value must be at most 100 for dictionary value @ data['brightness_pct']

the config looks like this:

alias: Gartenlich Smart Lux Dimmer
description: ""
use_blueprint:
  path: Twanne/smart_lux_dimmer.yaml
  input:
    light_value_1: 85
    light_value_2: 30
    light_sensor_entity: sensor.eg_lichtsensor_lux_2
    target_light:
      device_id: 72b4caf59271c2b93b77d21f2a53f841
    light_brightness_over_max: 100
    light_brightness_under_min: 29
    run_conditions:
      - condition: time
        after: "14:00:00"
        before: "01:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
    max_brightness_value: 1000
    min_brightness_value: 100

my idea was to dimm the light with less light outside … so not getting more light with less light outside but vice versa.
happy for any hint to solve the issue

1 Like

Sounds like a pretty basic use case. I use it like that as well: when it gets cloudy, the lights in my office turn up and vice versa.
The example configurations should help you out.

yes, to smooth out the changes you can adjust the transition time.
It will then transition from the set value to the next over that time, thus making the change more gradual.

I am getting this in my logs occasionally

First occurred: June 16, 2024 at 6:11:38 PM (6 occurrences) 
Last logged: 7:26:11 AM
Breakfast Area Ceiling Lights Smart Lux: Already running

My best guess is that the luminance sensor I have this tied to reports a changed value while the blueprint / automation is running. I’m using the Aqara Presence Sensors. Each instance of the blueprint I have does the same thing. Very occasionally. I don’t think this is a problem as the second run / lux change just doesn’t run.

Could the mode of the automation be changed to queued? Currently single. This might stop the errors I have in my logs for this blueprint.

mode: single

Thanks

Changing it to queued would introduce issues as it would delay these actions and actually run them. so it could change the light’s brightness to a value that doesn’t match the current light sensor value.
It’s just skipping the changes, so that’s fine. If you could change the frequency with which the sensor is outputting Lumen values that would work well, if not I’d just leave it.

Error while executing
I imported the Blueprint today, was using the old version 2.3 before, Set it up more or less the same. On execution I found this in the log:

Logger: homeassistant.components.automation.lights_new_smart_dimmer_wohnzimmer_weekend
Source: helpers/script.py:2026
integration: Automation (documentation, issues)
First occurred: 14:38:39 (192 occurrences)
Last logged: 15:47:07

Lights: New smart dimmer Wohnzimmer weekend: Choose at step 1: choice 1: Choose at step 1: choice 1: Error executing script. Invalid data for call_service at pos 1: value must be at least 0 for dictionary value @ data['brightness_pct']
Lights: New smart dimmer Wohnzimmer weekend: Choose at step 1: choice 1: Error executing script. Invalid data for choose at pos 1: value must be at least 0 for dictionary value @ data['brightness_pct']
Lights: New smart dimmer Wohnzimmer weekend: Error executing script. Invalid data for choose at pos 1: value must be at least 0 for dictionary value @ data['brightness_pct']

Here’s the config:

mode: single
variables:
  include_color_or_temp: include_no_color_temp
  include_brightness_over_under: false
  include_color_or_temp_over_under: include_no_color_temp_outside_range
  light_sensor: sensor.sauron_arbeitszimmer_illuminance_lux
  maxB: 150
  minB: 1
  light1: 1
  light2: 80
  slope: '{{ ( light1 - light2 ) / ( maxB - minB ) }}'
  constant: '{{ light1 - ( slope * maxB ) }}'
triggers:
  platform: state
  entity_id: sensor.sauron_arbeitszimmer_illuminance_lux
conditions:
  - condition:
      - condition: time
        weekday:
          - sat
          - sun
        after: '07:00:00'
        before: '22:00:00'
      - condition: zone
        entity_id: device_tracker.tapetenhobels_iphone
        zone: zone.home

help? :wink: