-
Notifications
You must be signed in to change notification settings - Fork 0
/
hue_dimmer_switch.yaml
54 lines (52 loc) · 2.39 KB
/
hue_dimmer_switch.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
blueprint:
name: Hue Dimmer Switch (Four Buttons) - Multiple Rooms
description: Control multiple groups of Hue lights with a Hue Dimmer Switch with four physical buttons and cycle through scenes in each room.
domain: automation
input:
dimmer_entity:
name: Dimmer Entity
description: The entity ID of the Hue Dimmer Switch.
selector:
entity:
domain: sensor
rooms:
name: Rooms
description: List of rooms with Hue lights to control.
selector:
target:
entity:
domain: light
scenes:
name: Scenes
description: List of scenes to cycle through when the On button is pressed repeatedly.
default: []
trigger:
platform: state
entity_id: !input dimmer_entity
action:
- choose:
- conditions:
- "{{ trigger.to_state.state == '1_click_up' }}"
sequence:
- choose:
# Toggle the lights on/off
- conditions:
- "{{ is_state(!input rooms | map(attribute='entity_id') | list | join(', '), 'on') }}"
sequence:
- service: scene.turn_on
target:
entity_id: !input scenes[0]
# Cycle through scenes
- conditions:
- "{{ not is_state(!input rooms | map(attribute='entity_id') | list | join(', '), 'on') }}"
sequence:
- variables:
room_index: "{{ state_attr('input_select.current_room', 'options').index(state_attr('input_select.current_room', 'state')) }}"
new_scene_index: "{{ state_attr('input_select.current_scene_' + (room_index | string), 'options').index(state_attr('input_select.current_scene_' + (room_index | string), 'state')) + 1 if state_attr('input_select.current_scene_' + (room_index | string), 'options').index(state_attr('input_select.current_scene_' + (room_index | string), 'state')) < (scenes | count) - 1 else 0 }}"
- service: input_select.select_option
data:
entity_id: input_select.current_scene_{{ room_index }}
option: "{{ state_attr('input_select.current_scene_' + (room_index | string), 'options')[new_scene_index] }}"
- service: scene.turn_on
target:
entity_id: !input scenes[new_scene_index]