I want to regulate the brightness of my HUE lamps based on the measured Lux from my Xiaomi light sensor. The light sensor is in a room where i want to keep constant light intensity between a certain time and sunset.
I have all sensors etc installed succesfully but need an example of how to configure the logic that takes said Lux value and adjusts the brightness attribute of several entities.
Does this belong in a script that is called using a time pattern of in a template?
I now have it working via an automation which calls a scene, but i rather have a function that in- or decreases brightness “seamless”.
Depending on your light device’s abilities and how you have set the maximum you may need to change the service call shown below. Not all light devices/integrations support setting by brightness percentage, so you would need to use the brightness value (0-255).
The gist of how to do it is the following automation:
alias: PID light
description: "Set light brightness based on PID sensor output"
trigger:
- platform: state
entity_id:
- sensor.pid_light_sensor
not_from:
- unknown
- unavailable
condition: []
action:
- service: light.turn_on
data:
brightness_pct: "{{ trigger.to_state.state | int }}"
target:
entity_id: light.your_light
mode: single