-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathesp-snowflake-controller.yaml
81 lines (75 loc) · 1.94 KB
/
esp-snowflake-controller.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
substitutions:
node_name: esp-snowflake-controller
node_friendly_name: "Snowflake"
packages:
esp_common: !include shared/esp__common_core.yaml
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
version: 5.1.1
platform_version: 6.4.0
globals:
# makes sure we don't switch the snowflakes' state if it's already in the desired state
- id: snowflake_state
type: bool
initial_value: "false"
status_led:
pin:
number: 2
inverted: true
switch:
- platform: gpio
id: snowflake_button
name: Button
pin: 9
- platform: gpio
id: snowflake_power_enable
name: Power Enable
restore_mode: RESTORE_DEFAULT_OFF
pin: 21
- platform: template
id: snowflake_power
name: Power
lambda: "return id(snowflake_state);"
turn_off_action:
- if:
condition:
lambda: "return id(snowflake_state);"
then:
- globals.set:
id: snowflake_state
value: "false"
- switch.turn_on: snowflake_button
- delay: 2250ms
- switch.turn_off: snowflake_button
turn_on_action:
- if:
condition:
lambda: "return !id(snowflake_state);"
then:
- globals.set:
id: snowflake_state
value: "true"
- switch.turn_on: snowflake_button
- delay: 500ms
- switch.turn_off: snowflake_button
- platform: template
id: snowflake_button_short_press
name: Button Short Press
turn_on_action:
- switch.turn_on: snowflake_button
- delay: 500ms
- switch.turn_off: snowflake_button
- platform: template
id: snowflake_button_long_press
name: Button Long Press
turn_on_action:
- switch.turn_on: snowflake_button
- delay: 2250ms
- switch.turn_off: snowflake_button
binary_sensor:
- platform: gpio
id: snowflake_button_input
name: Button Input
pin: 20