-
Notifications
You must be signed in to change notification settings - Fork 0
/
home-assistant-automation-for-rotary-encoder.yaml
131 lines (129 loc) · 4.06 KB
/
home-assistant-automation-for-rotary-encoder.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#******************************************************************************
# This is a simple home assistant automation that is triggered when a rotary
# encoder from ESPHome is at a specific value, in this case "3"
#******************************************************************************
alias: Rotary encoder 1
description: ""
trigger:
- platform: template
value_template: |
{% set state = states('sensor.rotary_encoder_rotary_encoder') %}
{% if is_number(state) and state | float == 3 %}
{{ true }}
{% endif %}
condition: []
action:
- service: light.turn_on
data:
rgb_color:
- 189
- 5
- 240
target:
entity_id: light.workshop_rgb_light
mode: single
#******************************************************************************
# This is a more complex home assistant automation that is triggered whenever
# the rotary encoder changes value.
# The action then uses a series of "choose" decisions to set an RGB lightbulb
# to colours of the rainbow between 1-7. When encoder = 0 the light is turned off
# when encoder is > 7 it sets the bulb to white.
#******************************************************************************
alias: Rotary encoder 2
mode: single
description: ""
trigger:
- platform: state
entity_id:
- sensor.rotary_encoder_rotary_encoder
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 0.0 }}"
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 1.0 }}"
sequence:
- service: light.turn_on
data:
color_name: red
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 2.0 }}"
sequence:
- service: light.turn_on
data:
color_name: orange
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 3.0 }}"
sequence:
- service: light.turn_on
data:
color_name: yellow
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 4.0 }}"
sequence:
- service: light.turn_on
data:
color_name: green
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 5.0 }}"
sequence:
- service: light.turn_on
data:
color_name: blue
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 6.0 }}"
sequence:
- service: light.turn_on
data:
color_name: indigo
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float == 7.0 }}"
sequence:
- service: light.turn_on
data:
color_name: violet
target:
entity_id: light.workshop_rgb_light
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state | float > 7.0 }}"
sequence:
- service: light.turn_on
data:
color_name: white
target:
entity_id: light.workshop_rgb_light