Last active
February 29, 2024 06:00
-
-
Save kai-zer-ru/c58548a3311782987a386965c46797a5 to your computer and use it in GitHub Desktop.
double_light_blueprint.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Свет по датчику движения и времени | |
description: Управляем светом по датчику движения и времени с задержкой | |
domain: automation | |
input: | |
motion_entity: | |
name: Датчик движения | |
selector: | |
entity: | |
domain: | |
- binary_sensor | |
device_class: | |
- motion | |
multiple: false | |
light_entity_1: | |
name: Свет днём | |
selector: | |
entity: | |
filter: | |
- domain: | |
- light | |
multiple: false | |
light_entity_2: | |
name: Свет ночью | |
selector: | |
entity: | |
filter: | |
- domain: | |
- light | |
multiple: false | |
timer_entity: | |
name: Таймер | |
selector: | |
entity: | |
filter: | |
- domain: | |
- timer | |
multiple: false | |
number_day: | |
name: Время задержки днём (в минутах) | |
selector: | |
number: | |
min: 1.0 | |
max: 60.0 | |
unit_of_measurement: мин. | |
step: 1.0 | |
mode: slider | |
default: 10 | |
number_night: | |
name: Время задержки ночью (в минутах) | |
selector: | |
number: | |
min: 1.0 | |
max: 60.0 | |
unit_of_measurement: мин. | |
step: 1.0 | |
mode: slider | |
default: 3 | |
turn_on_light_day: | |
name: Включать свет днём? | |
selector: | |
entity: | |
filter: | |
- domain: | |
- input_boolean | |
multiple: false | |
source_url: https://gist.github.com/kai-zer-ru/c58548a3311782987a386965c46797a5 | |
mode: restart | |
max_exceeded: silent | |
variables: | |
number_night: !input number_night | |
number_day: !input number_day | |
turn_on_light_day: !input turn_on_light_day | |
number_night_minutes: '{{ number_night | int * 60 }}' | |
number_day_minutes: '{{ number_day | int * 60 }}' | |
trigger: | |
- platform: state | |
entity_id: !input motion_entity | |
to: "on" | |
from: "off" | |
id: move_on | |
- platform: state | |
entity_id: !input motion_entity | |
from: "on" | |
to: "off" | |
id: move_off | |
- platform: event | |
event_type: timer.finished | |
event_data: | |
entity_id: !input timer_entity | |
id: timer_v_off | |
- platform: state | |
entity_id: | |
- !input light_entity_1 | |
from: "on" | |
to: "off" | |
id: light_1_off | |
- platform: state | |
entity_id: | |
- !input light_entity_1 | |
from: "off" | |
to: "on" | |
id: light_1_on | |
- platform: state | |
entity_id: | |
- !input light_entity_2 | |
from: "on" | |
to: "off" | |
id: light_2_off | |
- platform: state | |
entity_id: | |
- !input light_entity_2 | |
from: "off" | |
to: "on" | |
id: light_2_on | |
action: | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: | |
- move_off | |
sequence: | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
- if: | |
- condition: or | |
conditions: | |
- condition: state | |
entity_id: !input light_entity_1 | |
state: "on" | |
- condition: state | |
entity_id: !input light_entity_2 | |
state: "on" | |
then: | |
- if: | |
- condition: time | |
after: "20:00:00" | |
before: "07:00:00" | |
then: | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
data: | |
duration: "{{ number_night_minutes }}" | |
else: | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
data: | |
duration: "{{ number_day_minutes }}" | |
- conditions: | |
- condition: trigger | |
id: | |
- move_on | |
sequence: | |
- if: | |
- condition: and | |
conditions: | |
- condition: state | |
entity_id: !input light_entity_2 | |
state: "off" | |
- condition: time | |
after: "20:00:00" | |
before: "07:00:00" | |
then: | |
- service: light.turn_on | |
target: | |
entity_id: !input light_entity_2 | |
else: | |
- if: | |
- condition: state | |
entity_id: !input turn_on_light_day | |
state: "on" | |
then: | |
- service: light.turn_on | |
target: | |
entity_id: !input light_entity_1 | |
- if: | |
- condition: state | |
entity_id: !input timer_entity | |
state: active | |
then: | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: trigger | |
id: | |
- timer_v_off | |
sequence: | |
- service: light.turn_off | |
target: | |
entity_id: !input light_entity_1 | |
- service: light.turn_off | |
target: | |
entity_id: !input light_entity_2 | |
- conditions: | |
- condition: trigger | |
id: | |
- light_1_off | |
sequence: | |
- if: | |
- condition: state | |
entity_id: !input light_entity_2 | |
state: "off" | |
then: | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
- conditions: | |
- condition: trigger | |
id: | |
- light_1_on | |
- light_2_on | |
sequence: | |
- if: | |
- condition: state | |
entity_id: !input motion_entity | |
state: "off" | |
then: | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
- if: | |
- condition: time | |
after: "20:00:00" | |
before: "07:00:00" | |
then: | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
data: | |
duration: "{{ number_night_minutes}}" | |
else: | |
- service: timer.start | |
target: | |
entity_id: !input timer_entity | |
data: | |
duration: "{{ number_day_minutes }}" | |
- conditions: | |
- condition: trigger | |
id: | |
- light_2_off | |
sequence: | |
- if: | |
- condition: state | |
entity_id: !input light_entity_1 | |
state: "off" | |
then: | |
- service: timer.cancel | |
target: | |
entity_id: !input timer_entity | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment