-
Notifications
You must be signed in to change notification settings - Fork 7
/
xiaomi_cube.yaml
204 lines (193 loc) · 5.12 KB
/
xiaomi_cube.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# grab the python scene_genertor script from here
# https://github.com/sunnythaper/python_scripts
homeassistant:
customize:
package.node_anchors:
mycube: &mycube binary_sensor.cube_xxxxxx
input_select:
cube_light_color:
name: color
options:
- white
- red
- orangered
- orange
- gold
- yellow
- yellowgreen
- green
- teal
- blue
- blueviolet
- purple
- magenta
cube_light:
name: light
options:
- light.rc1
- light.rc3
- light.c1
- light.fita_sala
cube_mode:
name: cube mode
options:
- color
- brightness
cube_scene:
name: Scene
options:
- sala_padrao
- sala_conforto
- sala_red_blue
- movie
notify:
- name: scene_generator
platform: file
filename: cube_generated_scene.yaml
timestamp: true
automation:
- id: rotate_cube_color
alias: Rotate to set color
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: rotate
condition:
- condition: state
entity_id: input_select.cube_mode
state: 'color'
action:
- service_template: >
{% if trigger.event.data.action_value | float > 0 %}
input_select.select_next
{% else %}
input_select.select_previous
{% endif %}
data:
entity_id: input_select.cube_light_color
- service: light.turn_on
data_template:
entity_id: "{{ states('input_select.cube_light') }}"
color_name: "{{ states('input_select.cube_light_color') }}"
- id: rotate_cube_brightness
alias: Rotate to set brightness
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: rotate
condition:
- condition: state
entity_id: input_select.cube_mode
state: 'brightness'
action:
- service_template: >
{% if trigger.event.data.action_value | float > 0 %}
input_select.select_next
{% else %}
input_select.select_previous
{% endif %}
data:
entity_id: input_select.cube_light_color
- service: light.turn_on
data_template:
entity_id: "{{ states('input_select.cube_light') }}"
brightness: >
{% if trigger.event.data.action_value | float > 0 %}
{{ state_attr( states('input_select.cube_light'), 'brightness')| int + 25}}
{% else %}
{{ state_attr( states('input_select.cube_light'), 'brightness')| int - 25}}
{% endif %}
- id: flip90_cube_light
alias: Flip90 to select light
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: flip90
action:
- service: input_select.select_next
entity_id: input_select.cube_light
- service: light.turn_on
data_template:
entity_id: "{{ states('input_select.cube_light') }}"
flash: short
- id: flip180_cube_mode
alias: Flip180 to select mode
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: flip180
action:
- service: input_select.select_next
entity_id: input_select.cube_mode
- service: light.turn_on
data_template:
entity_id: "{{ states('input_select.cube_light') }}"
flash: short
- id: tap_twice_toggle
alias: Tap twice to toggle light
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: tap_twice
action:
- service: light.toggle
data_template:
entity_id: "{{ states('input_select.cube_light') }}"
- id: shake_cube_scene
alias: Shake cube to change scene
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: shake_air
action:
- service: input_select.select_next
entity_id: input_select.cube_scene
- service: scene.turn_on
data_template:
entity_id: "scene.{{ states('input_select.cube_scene') }}"
- id: free_fall_cube_save
alias: Free fall cube to save scene
hide_entity: True
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: *mycube
action_type: free_fall
action:
- service: python_script.scene_generator
data:
domains:
- light
- switch
attributes:
- brightness
- color_temp
- rgb_color
- xy_color
save_file: True