I have slightly expanded the ability to turn on and off the light by the light sensor. To turn on and off the light, we use low_lux and high_lux. In fact, we rigidly specify the boundaries and if the lighting on the street is below low_lux, then the light will turn on, and if it is above high_lux, then it will turn on. The meaning of this idea is that if it is still light on the street according to the light sensor and the light has not fallen below low_lux, and the light level in the room is lower than on the street, then you need to manually adjust low_lux. I made an adaptive adjustment of the light. Using the separation of who turned on the light, a person or automation. If automation works, the low_low and high_lux ranges will remain unchanged, but if you turn on the light manually, the low_lux and high_lux ranges will change.
Watch the video how it works
To work, you need two automations.
The first automation is responsible for turning on and off the light by low_lux and high_lux
alias: 'Living room: Ceiling chandelier. The light sensor.'
description: 'Operation of lighting by the light sensor'
trigger:
- platform: state
entity_id: sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux
condition:
- condition: time
after: '12:00'
before: '21:59'
- condition: state
entity_id: input_boolean.gostinaia_potolochnaia_liustra_korrektirovka_sveta
state: 'on'
action:
- choose:
- conditions:
- condition: template
value_template: >-
{{(states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
| float) <
(states('input_number.lights_in_the_living_room_low_lux') |
float)}}
sequence:
- type: turn_on
device_id: xxxxxxxxxxxxxxxxxxxxx
entity_id: light.yeelight_ceiling4_0x000000000000000
domain: light
brightness_pct: 40
- conditions:
- condition: template
value_template: >-
{{(states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
| float) >
(states('input_number.lights_in_the_living_room_high_lux') |
float)}}
sequence:
- type: turn_off
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxx
entity_id: light.yeelight_ceiling4_0x000000000000000
domain: light
default: []
mode: single
max: 10
The second automation is responsible for adjusting the low_lux and high_lux ranges. Adjusts the ranges if the light was turned on by a person
alias: 'Living room: Ceiling chandelier. The light sensor. Adjustment'
description: ''
trigger:
- platform: state
entity_id: light.yeelight_ceiling4_0x000000000000000
condition:
- condition: template
value_template: '{{ trigger.to_state.context.parent_id == none }}'
- condition: state
entity_id: input_boolean.gostinaia_potolochnaia_liustra_korrektirovka_sveta
state: 'on'
action:
- choose:
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'on'
- condition: template
value_template: >
{% if
states.sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux.state
| float < 500 %} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >-
{{
states.sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux.state
}}
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'off'
- condition: template
value_template: >
{% if states.input_number.lights_in_the_living_room_low_lux.state
>
states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
%} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: '100'
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'off'
- condition: template
value_template: >
{% if states.input_number.lights_in_the_living_room_high_lux.state
<
states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
%} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >-
{{
states.sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux.state
}}
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'off'
- condition: template
value_template: >
{% if states.input_number.lights_in_the_living_room_high_lux.state
| float > 800 %} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: '300'
default: []
mode: single
Текст на русском (Text in Russian)
Я немного расширил возможность включения и выключения света по датчику света. Для включения и выключения света мы используем low_lux и high_lux. По сути жестко указываем границы и если на улице освещение будет ниже low_lux, то свет включится, а если выше high_lux, то включится. Смысл этой затеи в том, что, если по датчику света на улице еще светло и свет не опустился ниже low_lux, а в помещении уровень света ниже, чем на улице, то нужно вручную корректировать low_lux. Я сделал адаптивную регулировку света. Используя разделение кто включил свет, человек или автоматизация. Если сработает автоматизация, то диапазоны low_lux и high_lux останутся неизменными, но если включить свет вручную, то то диапазоны low_lux и high_lux изменятся.
Смотрим видео как это работает
Для работы нужны две автоматизации.
Первая автоматизация отвечает за включение и выключение света по low_lux и high_lux
alias: 'Гостиная: Потолочная люстра. Датчик света.'
description: Работа освещения по датчику света
trigger:
- platform: state
entity_id: sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux
condition:
- condition: time
after: '12:00'
before: '21:59'
- condition: state
entity_id: input_boolean.gostinaia_potolochnaia_liustra_korrektirovka_sveta
state: 'on'
action:
- choose:
- conditions:
- condition: template
value_template: >-
{{(states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
| float) <
(states('input_number.lights_in_the_living_room_low_lux') |
float)}}
sequence:
- type: turn_on
device_id: xxxxxxxxxxxxxxxxxxxxx
entity_id: light.yeelight_ceiling4_0x000000000000000
domain: light
brightness_pct: 40
- conditions:
- condition: template
value_template: >-
{{(states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
| float) >
(states('input_number.lights_in_the_living_room_high_lux') |
float)}}
sequence:
- type: turn_off
device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxx
entity_id: light.yeelight_ceiling4_0x000000000000000
domain: light
default: []
mode: single
max: 10
Вторая автоматизация отвечает за корректировку диапазонов low_lux и high_lux. Корректирует диапазоны в том случае, если свет был включен человеком
alias: 'Гостиная: Потолочная люстра. Датчик света. Корректировка'
description: ''
trigger:
- platform: state
entity_id: light.yeelight_ceiling4_0x000000000000000
condition:
- condition: template
value_template: '{{ trigger.to_state.context.parent_id == none }}'
- condition: state
entity_id: input_boolean.gostinaia_potolochnaia_liustra_korrektirovka_sveta
state: 'on'
action:
- choose:
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'on'
- condition: template
value_template: >
{% if
states.sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux.state
| float < 500 %} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: >-
{{
states.sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux.state
}}
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'off'
- condition: template
value_template: >
{% if states.input_number.lights_in_the_living_room_low_lux.state
>
states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
%} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_low_lux
data:
value: '100'
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'off'
- condition: template
value_template: >
{% if states.input_number.lights_in_the_living_room_high_lux.state
<
states('sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux')
%} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: >-
{{
states.sensor.gostinaia_datchik_sveta_levoe_okno_illuminance_lux.state
}}
- conditions:
- condition: state
entity_id: light.yeelight_ceiling4_0x000000000000000
state: 'off'
- condition: template
value_template: >
{% if states.input_number.lights_in_the_living_room_high_lux.state
| float > 800 %} true {% else %} false {% endif %}
sequence:
- service: input_number.set_value
target:
entity_id: input_number.lights_in_the_living_room_high_lux
data:
value: '300'
default: []
mode: single