I’m trying to get my hallway lights to adjust to the sun and weather conditions. Using the Buienradar integration there is a sensor for solar strength. I’m hopeing to use this value to calculate an approptiate brightness level. With the calculation below I would have a 50 brightness nightlight and as long as the irradiation doesn’t go over 1000kW I should be fine (255 is max brightness).
- id: '1581631610216'
alias: Lampen - Gang movement
description: ''
trigger:
- entity_id: binary_sensor.motion_sensor_158d0001b19074
platform: state
to: 'on'
- data:
brightness: '{{ ((states.sensor.br_irradiance.state | int) / 5) + 50 }}'
entity_id: light.gang_lamp
service: light.turn_on
Can someone help me find the error in this formula?
After running this for some days I must say I’m really pleased with the outcome. No more beeing blinded at night when I walk into the hallway or useless light during the day. Also added a condition so the light can’t be triggered by our cat when we’re not home/sleeping. Finally added in a IF statement so the brightness doesn’t go over the lights max value.
Brightness at the lowest setting was good enough but brightness 0 didn’t turn on the light. That’s why the +1 is included.
- id: '1581631610216'
alias: Lampen - Gang movement
description: ''
trigger:
- entity_id: binary_sensor.motion_sensor_158d0001b19074
platform: state
to: 'on'
condition:
- condition: state
entity_id: alarm_control_panel.ha_alarm
state: disarmed
action:
- data_template:
brightness: '{% if ((states.sensor.br_irradiance.state|int // 4 + 1) < 255) -%}{{states.sensor.br_irradiance.state|int // 4 + 1}}{%- else -%}255{%- endif %}'
entity_id: light.gang_lamp
service: light.turn_on