Help with automation using a light sensor to adjust the brightness of a bulb

Great, I am glad that it works for you :slight_smile:

I was reading your post @Bagoonga when you deleted it I hope you found a solution to your problem

Ah, sorry for that. I should’ve just edited the post.
I was having a problem with the light always turning on to 100%.
But I quickly remembered it was Adaptive lighting integration that was controlling it when turning from off to on. Now it works as intended! :slight_smile:

My ZooZ motion measures illuminance in percent (0 - 100%), as does the Zooz dimmer. I’m not quite sure how to adjust your code. I am assuming max_illuminance: 580 is for a unit that measures in integers?

The final code for my setup was

alias: Adjust brightness on the office bulb (faster)
description: “”
trigger:

  • platform: time_pattern
    seconds: /15
    condition:
  • condition: state
    entity_id: timer.office_occupancy
    state: active
    for:
    hours: 0
    minutes: 0
    seconds: 1
    action:
  • choose:
    • conditions:
      • condition: template
        value_template: >-
        {{ states(‘sensor.officelightlevel’)|float <
        states(‘input_number.office_light_target’)|float - range/2 }}
        sequence:
      • service: light.turn_on
        target:
        entity_id: light.office_bulb
        data:
        brightness_step: “{{ my_brightness_step }}”
    • conditions:
      • condition: template
        value_template: >-
        {{ states(‘sensor.officelightlevel’)|float >
        states(‘input_number.office_light_target’)|float + range/2 }}
        sequence:
      • service: light.turn_on
        target:
        entity_id: light.office_bulb
        data:
        brightness_step: “{{ -1 * my_brightness_step }}”
        default: []
        mode: single
        variables:
        range: 5
        my_brightness_step: 18

Looking at what you’re saying I would look at altering the range and my_brightness_step until you get the desired result.

@daknightuk What do you use for a illuminance sensor? The Zooz is reallllly slow.
I’ll try your final code and see if that works a bit better. What’s happening now is the dimmer starts out low, and just marches all the way up to 100% which is not what I want

@itcsburnett So my setup is an ESP8266 module with a light dependant resistor circuit and it uses ESP home.

I just remembered I had to use a “helper” to set the office_light_target value

image

Thanks @daknightuk That works now, although I need a better sensor. the ZooZ doesn’t update fast enough or constantly. I have a aqura on order- will see how that works

I am using the Xiaomi Mi light sensor and it is great, quick and reliable.

Great to hear. I ordered a few of them myself from AliExpress