-
-
Notifications
You must be signed in to change notification settings - Fork 505
/
detect_and_adjust_lights.yaml
executable file
·60 lines (58 loc) · 2.41 KB
/
detect_and_adjust_lights.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
##############################################################################
### Detect when lights are turned on and adjust them accordingly based on time.
### Code by @JesseWebDotCom
## @CCOSTAN
## Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
##############################################################################
- alias: detect lights and adjust the brightness when turned on based on time
id: 844b6be0-3ba3-4f8a-bbcd-a5ec5abdb88a
mode: parallel
trigger:
- platform: event
event_type: state_changed
condition:
- condition: state
entity_id: group.family
state: 'home'
- condition: state
entity_id: input_boolean.alert_mode
state: 'off'
- condition: template
value_template: "{{ trigger.event.data is not none }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id is not none }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'light' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.tv' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.couch' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.office' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.flood_2' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.treeflood' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.led' }}"
- condition: template
value_template: "{{ trigger.event.data.entity_id.split('_')[1] != 'screensaver' }}"
- condition: template
value_template: "{{ trigger.event.data.new_state.state == 'on' }}"
- condition: template
value_template: "{{ trigger.event.data.old_state.state == 'off' }}"
action:
- service: light.turn_on
data:
entity_id: "{{ trigger.event.data.entity_id }}"
brightness: >
{% set hour=states("sensor.time").split(':')[0] | int %}
{%- if hour >= 5 and hour < 8 -%}
50
{%- elif hour >= 8 and hour <20 -%}
255
{%- elif hour >= 20 and hour <24 -%}
40
{%- else -%}
15
{%- endif %}