-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbedroom_light_with_nightlight.yaml
99 lines (95 loc) · 3.05 KB
/
bedroom_light_with_nightlight.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
blueprint:
name: "Bedroom light with nightlight"
description: Bedroom light control with nightlight functionality
domain: automation
input:
controller_entity:
name: Control switch (action sensor)
selector:
entity:
domain: sensor
multiple: false
bedroom_light:
name: Light
selector:
entity:
domain: light
nightlight_light:
name: Light
selector:
entity:
domain: light
nightlight_colour:
name: Nightlight colour
selector:
color_rgb:
nightlight_intensity:
name: Nightlight intensity (%)
selector:
number:
min: 0
max: 100
mode: slider
mode: queued
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: !input controller_entity
variables:
trigger_action: '
{% if trigger.event.event_type == "state_changed" %}
{{ trigger.event.data.new_state.state }}
{% endif %}'
controller_entity: !input controller_entity
bedroom_light: !input bedroom_light
nightlight_light: !input nightlight_light
nightlight_colour: !input nightlight_colour
nightlight_intensity: !input nightlight_intensity
action:
- choose:
- conditions: '{{ trigger_action | string == "on" }}'
sequence:
- choose:
- conditions:
- condition: state
entity_id: !input 'bedroom_light'
state: 'off'
sequence:
- service: light.turn_on
target:
entity_id: !input 'bedroom_light'
data:
brightness_pct: "{{ states('sensor.adaptivelightbrightness') }}"
color_temp: "{{ states('sensor.adaptivelightcolourtemp') }}"
- conditions:
- condition: state
entity_id: !input 'bedroom_light'
state: 'on'
- condition: numeric_state
entity_id: !input 'bedroom_light'
attribute: brightness
below: '255'
sequence:
- service: light.turn_on
target:
entity_id: !input 'bedroom_light'
data:
brightness_pct: 100
color_temp: 350
- conditions: '{{ trigger_action | string == "off" }}'
sequence:
- service: light.turn_off
entity_id: !input bedroom_light
- conditions: '{{ trigger_action | string == "brightness_move_up" }}'
sequence:
- service: light.turn_off
entity_id: !input bedroom_light
- service: light.turn_on
entity_id: !input nightlight_light
data:
brightness_pct: '{{ nightlight_intensity | int }}'
rgb_color:
- '{{ nightlight_colour[0] | int }}'
- '{{ nightlight_colour[1] | int }}'
- '{{ nightlight_colour[2] | int }}'