Created
May 16, 2020 15:39
-
-
Save bessarabov/ad0dee17eb88357ce41993dfd17fba31 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
default_config: | |
timer: | |
my_timer: | |
five_sec_after_button_press: | |
one_min_after_button_press: | |
input_text: | |
fake_button: | |
input_boolean: | |
fake_motion: | |
fake_light: | |
fake_night: | |
need_to_turn_off_automation: | |
script: | |
press: | |
sequence: | |
- service: input_text.set_value | |
data: | |
entity_id: input_text.fake_button | |
value: toggle | |
- service: input_text.set_value | |
data: | |
entity_id: input_text.fake_button | |
value: '' | |
sensor: | |
- platform: template | |
sensors: | |
button: | |
value_template: "{{ states('input_text.fake_button') }}" | |
binary_sensor: | |
- platform: template | |
sensors: | |
living_room_motion: | |
device_class: motion | |
value_template: "{{ states('input_boolean.fake_motion') == 'on' }}" | |
night: | |
value_template: "{{ states('input_boolean.fake_night') == 'on' }}" | |
light: | |
- platform: template | |
lights: | |
living_main_light: | |
value_template: "{{ states('input_boolean.fake_light') == 'on' }}" | |
turn_on: | |
service: input_boolean.turn_on | |
entity_id: input_boolean.fake_light | |
turn_off: | |
service: input_boolean.turn_off | |
entity_id: input_boolean.fake_light | |
##### | |
##### | |
##### | |
automation: | |
## Если свет не горит, то нажатие на кнопку всегда включет свет | |
- alias: turn_light_on_on_button_press | |
trigger: | |
platform: state | |
entity_id: sensor.button | |
to: 'toggle' | |
condition: | |
- condition: state | |
entity_id: light.living_main_light | |
state: 'off' | |
action: | |
- service: light.turn_on | |
entity_id: light.living_main_light | |
## Если свет горит, то нажатие на кнопку всегда выключит свет | |
- alias: turn_light_off_on_button_press | |
trigger: | |
platform: state | |
entity_id: sensor.button | |
to: 'toggle' | |
condition: | |
- condition: state | |
entity_id: light.living_main_light | |
state: 'on' | |
action: | |
- service: light.turn_off | |
entity_id: light.living_main_light | |
- service: timer.start | |
data: | |
entity_id: timer.five_sec_after_button_press | |
duration: '00:00:05' | |
- service: timer.start | |
data: | |
entity_id: timer.one_min_after_button_press | |
duration: '00:01:00' | |
- service: input_boolean.turn_on | |
entity_id: input_boolean.need_to_turn_off_automation | |
## Включаем свет если ночь + есть движение | |
- alias: auto light on | |
trigger: | |
platform: state | |
entity_id: binary_sensor.living_room_motion | |
to: 'on' | |
condition: | |
- condition: state | |
entity_id: binary_sensor.living_room_motion | |
state: 'on' | |
- condition: state | |
entity_id: binary_sensor.night | |
state: 'on' | |
action: | |
- service: light.turn_on | |
entity_id: light.living_main_light | |
- service: timer.start | |
data: | |
entity_id: timer.my_timer | |
duration: '00:02:00' | |
## Выключаем свет когда таймер завершил работу | |
- alias: auto light off | |
trigger: | |
- platform: event | |
event_type: timer.finished | |
event_data: | |
entity_id: timer.my_timer | |
action: | |
- service: light.turn_off | |
entity_id: light.living_main_light | |
## Выключаем автоматику по следующей логике | |
## «если свет был выключен выключателем и в течении минуты движений не было | |
## (не считая первых 5 секунд после выключения), | |
- alias: turn_automation_off | |
trigger: | |
- platform: event | |
event_type: timer.finished | |
event_data: | |
entity_id: timer.one_min_after_button_press | |
condition: | |
- condition: state | |
entity_id: input_boolean.need_to_turn_off_automation | |
state: 'on' | |
action: | |
- service: automation.turn_off | |
entity_id: automation.auto_light_on | |
## Ночь закончилась — включаем автоматику в любом случае | |
- alias: turn_automation_on | |
trigger: | |
platform: state | |
entity_id: binary_sensor.night | |
to: 'off' | |
action: | |
- service: input_boolean.turn_off | |
entity_id: input_boolean.need_to_turn_off_automation | |
- service: automation.turn_on | |
entity_id: automation.auto_light_on | |
## Сбрасывается флаг input_boolean.need_to_turn_off_automation если | |
## не выполняется условие: | |
## "в течении минуты движений не было (не считая первых 5 секунд после выключения)," | |
- alias: remove flag need_to_turn_off_automation | |
trigger: | |
platform: state | |
entity_id: binary_sensor.living_room_motion | |
to: 'on' | |
condition: | |
- condition: template | |
value_template: "{{ not is_state('timer.five_sec_after_button_press', 'active') and is_state('timer.one_min_after_button_press', 'active') }}" | |
action: | |
- service: input_boolean.turn_off | |
entity_id: input_boolean.need_to_turn_off_automation | |
This file contains hidden or 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
title: Home | |
views: | |
- badges: [] | |
cards: | |
- type: vertical-stack | |
cards: | |
- type: entities | |
show_header_toggle: false | |
title: То чем управляю | |
entities: | |
- entity: input_boolean.fake_motion | |
- entity: input_boolean.fake_night | |
- entity: binary_sensor.living_room_motion | |
- entity: binary_sensor.night | |
- type: button | |
name: кнопка | |
show_name: true | |
show_icon: false | |
tap_action: | |
action: call-service | |
service: script.turn_on | |
service_data: | |
entity_id: script.press | |
- type: entities | |
show_header_toggle: false | |
title: Свет | |
entities: | |
- entity: light.living_main_light | |
- type: entities | |
show_header_toggle: false | |
title: Внутренние сущности | |
entities: | |
- entity: timer.my_timer | |
name: через сколько свет выключится | |
- entity: timer.five_sec_after_button_press | |
- entity: timer.one_min_after_button_press | |
- entity: input_boolean.need_to_turn_off_automation | |
- entity: automation.auto_light_on | |
name: автоматизация, которая включает свет ночью по движению | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HA UI DEMO Stand:
https://drive.google.com/file/d/1hRn7LRJDT8PwnFtiNw6HnaK3mQCbE9lh/view?usp=sharing