šŸ’” Smart lux dimmer - Adjust light brightness depending on light sensor value

Hi, I presume the light will default to its standard temperature value when you donā€™t specify one.
Iā€™ve created a version 2.1, which adds fixed color and temperature values.

Iā€™m working on making color and temperature variable too, so that the lights can not only dim, but change color depending on the sensor value as well, but thatā€™ll probably take some time.

New Release

09/01/2023 - Version 2.1

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

From this version onwards, there will be added complexity in order to control light temperature and color settings. If you donā€™t need this, I recommend staying on version 2.0 as that will be much simpler and thus more user-friendly.

New Release

10/01/2023 - Version 3.0

  • 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.

Version 3.0 of the blueprint as added features in order to control the behavior of the light when over the maximum and under the minimum values.

Using version 3, I am getting this error msg:

Message malformed: expected float for dictionary value @ data[ā€˜actionā€™][0][ā€˜chooseā€™][0][ā€˜conditionsā€™][0][ā€˜aboveā€™]

wie follow YAML:

description: ""
alias: Licht - Test Dimmer
use_blueprint:
  path: Twanne/smart_dimmer_version_3.yaml
  input:
    schedule_start: "09:00:00"
    schedule_stop: "21:00:00"
    schedule_days: mon, tue, wed, thu, fri
    light_sensor_entity: sensor.bewegungssensor_wohnzimmer_illuminance_lux
    max_brightness_value: 280
    light_value_2: 72
    min_brightness_value: 30
    light_brightness_under_min: 85
    light_color_over_max:
      - 248
      - 250
      - 219
    light_color_under_min:
      - 255
      - 216
      - 119
    light_color:
      - 255
      - 251
      - 185
    target_light:
      entity_id: light.bett_stehlampe
    light_brightness_over_max: 2
    light_value_1: 2
    light_temp_over_max: 489
    light_temp_under_min: 487
    light_temp: 479

There was a typo: light.turn_un instead of light.turn_on.

Thatā€™s corrected now, can you try again?

same issue.

I deleted the blueprint and added it again and tried to set up different automations with different configs.

Example:

description: ""
alias: Licht - Test
use_blueprint:
  path: Twanne/smart_dimmer_version_3.yaml
  input:
    schedule_start: "14:00:00"
    schedule_stop: "22:00:00"
    schedule_days: fri
    light_sensor_entity: sensor.bewegungssensor_wohnzimmer_illuminance_lux
    target_light:
      entity_id: light.esstisch
    light_color:
      - 255
      - 255
      - 255
    light_color_under_min:
      - 255
      - 255
      - 255
    light_color_over_max:
      - 255
      - 255
      - 255
    min_brightness_value: 20
    light_value_1: 2
    light_brightness_over_max: 2

Thanks for the feedback.
For now, Iā€™ve added a BETA warning to this version. Iā€™ll have to do some more testing to fix this issue.

1 Like

Let me know if I can help with testing.

1 Like

Unfortunately, I get an error and I don;t know how to solve this (running the latest release of HA).:
Stopped because an error was encountered at February 19, 2023 at 5:23:31 PM (runtime: 0.02 seconds)
two or more values in the same group of exclusion ā€˜Color descriptorsā€™ @ data[]

Does someone know how to solve this?

1 Like

Same thing was happening to me until I switched to this version: 28/03/2022 - Version 2.0

1 Like

Hi There, I also run into this issue.

Hope this will be solved but cause it seems quiet in this thread :flushed: :stuck_out_tongue_winking_eye:

Iā€™ll try @sbcale solution.

1 Like

Unfortunately it does not work (please see comments below).
I am searching for ages for a script that simply measures:

  1. Lux measurement
  2. Increase/decrease lights based on the lux value
  3. Smooth transition between the stages of in/decrease light value

Nothing more or less. But every script is overcomplicated/over engineerd (motion detection, ambi light, et cetera).

Any thoughts please? Thank you in advance. :slight_smile: :slight_smile: :slight_smile:

In release Smart Light Dimmer V2.1, I get the following error:

Stopped because an error was encountered at June 22, 2023 at 9:12:06 PM (runtime: 0.02 seconds)
two or more values in the same group of exclusion ā€˜Color descriptorsā€™ @ data[]

Because I am not a HomeAssistant specialist, I couldnā€™t get an easy way to fix this problem. :frowning:

Anybody good suggestions please?

1 Like

Hi Hanske,

I had the same problem. Try v2.0 it works flawlessly and is really cool.

The one think I like to see changed in the blueprint though is the trigger. I.s.o a time bracket I would like to be able to use other triggers as well.

Edit: I use this for my garden lights. as it gets darker outside the tree need less light to have a nice effect.

1 Like

Hi 330chauf,

You are absolutely right, but there is just one thing that I would like to change.
At the moment of writing the lights do not change smoothly from state to state (smooth transistion).
This is the only thing I would like to have changed. The rest is okay.
Do you maybe know how to do this within the YAML script of this automation?

alias: Smart Light Dimmer V2.0 (25_06_2023)
description: ""
use_blueprint:
  path: Twanne/smart_dimmer_V2.yaml
  input:
    schedule_start: "16:00:00"
    schedule_stop: "22:00:00"
    schedule_days: mon, tue, wed, thu, fri, sat, sun
    light_sensor_entity: sensor.xiaomi_lumi_sen_ill_mgl01_illuminance
    target_light:
      entity_id: light.dimbare_lampen_huiskamer

Hi Hanske,

I have absolutely no idea of how to do that. I guess itā€™s in the mathematical calculation. For lights inside the house I would guess thatā€™s it a bit annoying thatā€™s is not gradual but I use this for my garden lights so itā€™s not so noticeable.

1 Like

No problem. Thanks for the reply :slight_smile:

Hi @Hanske, sorry for the slow support in this thread. Iā€™ve been very busy with work over the last months and no guarantee that Iā€™ll be able to pick this up very actively in the future.

Anyways: there are 3 possible options I can think of that can help smooth our the transitions.

  1. There is a transition value that you could add to the light.turn_on function, which allows your lights to transition smoothly from one value to the next in a set number of seconds. This should smooth out the shift from the set value to the newly input value. However, your lights need to support this transition (think: philips Hue etcā€¦).

You can copy the blueprint code and add the transition value as below:

action:
  - service: light.turn_on
    data:
      transition: 10
      brightness_pct: >
        {% if states(light_sensor)|int > maxB %}
          0
        {% else %}
          {{ (( slope * states(light_sensor)|int ) + constant)|round }}
        {% endif %}

    target: !input target_light
  1. The script updates every time your lux value from the light sensor is updated. If the lux value updates more frequently, the steps will be smaller and so the shift in brightness will become smaller as well, creating a perceived smoothing effect.

  2. External control: My lights are controlled through my KNX system in the background. using light.turn_on combined with a % value (what this blueprint does as standard) will send it to the dimming function in KNX, which then in turn will dim from the set value to the new one.

NEW RELEASE

  • 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.)