Why is this necessary?
This is not the same as integration Adaptive Lighting component for Home Assistant. That Adaptive Lighting component for Home Assistant integration controls the light level by the sun, and my version works by the light sensor and turns on/off the light by the light level range
Watch video
Let’s say your light turns on when the Min threshold is reached or turns off when the Max threshold is reached. This is a strict restriction on which the light turns on or off. It happens that the light turns on when the Min threshold is reached, but in fact it is still light in the room or the current value of the light sensor has not yet reached the Min threshold, and the room is already dark. To edit the range, you need to go into automation, or if you added a range variable to Lovelace, but then you also need to change the range manually. This option allows you to adjust the range automatically if we turn on the light manually. If the automation works, then the ranges of the light level will not change. To do this, I use the condition {{ trigger.to_state.context.parent_id == none }} which works if the light was turned on by a person
Explanation about entities. I built on a test machine and used virtual auxiliary elements. You need to replace these elements with real entities
input_boolean.virtualnyi_led - this needs to be replaced with your own, we specify a ceiling chandelier or lamps.
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux - we specify a light sensor instead of a sensor
We create two auxiliary elements “number”, they will serve for us as the threshold of the range Min and Max
input_number.lights_in_the_living_room_low_lux
input_number.lights_in_the_living_room_high_lux
Automation No. 1. Auto-correction of the light level range
Embed the code through the GUI. We create automation through the GUI , then click 3 dots and insert the code.
alias: 'Auto-correction of the light level range'
description: ''
trigger:
- platform: state
entity_id: input_boolean.virtualnyi_led
condition:
- condition: template
value_template: '{{ trigger.to_state.context.parent_id == none }}'
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.virtualnyi_led
state: 'on'
- condition: numeric_state
entity_id: >-
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux
below: '100'
above: '0'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >-
{{
states("input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux")
}}
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >-
{{
states("input_number.lights_in_the_living_room_low_lux")|round +
40 }}
- conditions:
- condition: state
entity_id: input_boolean.virtualnyi_led
state: 'off'
sequence:
- choose:
- conditions:
- condition: numeric_state
entity_id: >-
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux
above: '40'
below: '99'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >-
{{
states("input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux")}}
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >-
{{
states("input_number.lights_in_the_living_room_high_lux")|int
- 40 }}
- conditions:
- condition: numeric_state
entity_id: >-
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux
above: '100'
below: '200'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >
{% if
states("input_number.lights_in_the_living_room_low_lux")|round
>= 100 %} 40 {% else %} {% endif %}
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >
{% if
states("input_number.lights_in_the_living_room_high_lux")|round
>= 100 %} 80 {% else %} {% endif %}
default: []
default: []
mode: single
As soon as you do the automation “Auto-correction of the light level range”, you need to create a second automation that will turn on/ off the light when the threshold is reached. In automation, we use “Selection” and templates, where we specify the following
Turn on the light when the threshold Min is reached
{{(states('sensor.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux') | float) < (states('input_number.lights_in_the_living_room_low_lux') | float)}}
Turn off the light when the Max threshold is reached
{{(states('sensor.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux') | float) > (states('input_number.lights_in_the_living_room_high_lux') | float)}}
My version is not perfect, but it still works. I would be grateful if you have a working version and share your examples. After all, the more options there are, the better and you can bring it to the ideal.
Текст на русском (Text in Russian)
Зачем это нужно?
Это не тоже самое как интеграция Adaptive Lighting component for Home Assistant. Та интеграция Adaptive Lighting component for Home Assistant управляет уровнем света по солнцу, а мой вариант работает по датчику света и включает\выключает свет по диапазону уровня света
Смотрим видео
Допустим у вас свет включается при достижении порога Min или выключается при достижении порога Max. Это жесткое ограничение по которому свет включается или выключается. Бывает так, что свет включился при достижении порога Min, но по факту в комнате еще светло или текущее значение датчика света еще не достигло порога Min, а в комнате уже темновато.
Чтобы отредактировать диапазон, нужно лезть в автоматизацию, или, если добавили переменную диапазонов в Lovelace, но и тогда также нужно менять диапазон вручную. Этот вариант позволяет корректировать диапазон автоматически, если мы включаем свет вручную. Если сработает автоматика, то диапазоны уровня света не будут меняться. Для этого я использую условие {{ trigger.to_state.context.parent_id == none }} которое работает в том случае, если свет был включен человеком.
Пояснение про сущности. Я собирал на тестовой машине и использовал виртуальные вспомогательные элементы. Вам нужно заменить эти элементы на
реальные сущности
input_boolean.virtualnyi_led - это нужно заменить на свое, указываем потолочную люстру или лампы.
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux - указываем вместо сенсор датчика света
Создаем два вспомогательных элемента “число”, они будут служить для нас в качестве порога диапазона Min и Max
input_number.lights_in_the_living_room_low_lux
input_number.lights_in_the_living_room_high_lux
Автоматизация №1. Автокорректировка диапазона уровня света
Код вставлять через GUI. Создаем автоматизацию через GUI , далее нажимаем 3 точки и вставляем код.
alias: 'Автокорректировка диапазона уровня света'
description: ''
trigger:
- platform: state
entity_id: input_boolean.virtualnyi_led
condition:
- condition: template
value_template: '{{ trigger.to_state.context.parent_id == none }}'
action:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.virtualnyi_led
state: 'on'
- condition: numeric_state
entity_id: >-
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux
below: '100'
above: '0'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >-
{{
states("input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux")
}}
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >-
{{
states("input_number.lights_in_the_living_room_low_lux")|round +
40 }}
- conditions:
- condition: state
entity_id: input_boolean.virtualnyi_led
state: 'off'
sequence:
- choose:
- conditions:
- condition: numeric_state
entity_id: >-
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux
above: '40'
below: '99'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >-
{{
states("input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux")}}
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >-
{{
states("input_number.lights_in_the_living_room_high_lux")|int
- 40 }}
- conditions:
- condition: numeric_state
entity_id: >-
input_number.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux
above: '100'
below: '200'
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >
{% if
states("input_number.lights_in_the_living_room_low_lux")|round
>= 100 %} 40 {% else %} {% endif %}
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >
{% if
states("input_number.lights_in_the_living_room_high_lux")|round
>= 100 %} 80 {% else %} {% endif %}
default: []
default: []
mode: single
Как сделаете автоматизацию “Автокорректировка диапазона уровня света”, нужно создать вторую автоматизацию, которая будет включать\выключать свет по достижении порога.
В автоматизации используем “Выбор” и шаблоны, где указываем следующее
Включаем свет при достижении порога Min
{{(states('sensor.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux') | float) < (states('input_number.lights_in_the_living_room_low_lux') | float)}}
Выключаем свет при достижении порога Max
{{(states('sensor.gostinaia_datchik_sveta_potolochnaia_liustra_illuminance_lux') | float) > (states('input_number.lights_in_the_living_room_high_lux') | float)}}
Мой вариант не идеальный, но все же работает. Буду признателен, если вас есть рабочий вариант и вы поделитесь своими примерами. Ведь чем больше будет вариантов, тем лучше и можно довести до идеала.