-
Notifications
You must be signed in to change notification settings - Fork 0
/
plug_common_dumb.yaml
132 lines (125 loc) · 4.85 KB
/
plug_common_dumb.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
# Common code for plugs without energy-monitoring
packages:
device_base: !include zz_common_device_base.yaml
esp8266:
early_pin_init: false # Prevent the physical relay flipping on reboot.
restore_from_flash: true #writes each state change to flash for switch or light with restore_mode: RESTORE_DEFAULT_OFF/ON, see https://esphome.io/components/esphome.html#esp8266-restore-from-flash
# Individual on/off sensors
binary_sensor:
# Reports when the button is pressed
- platform: gpio
device_class: power
pin:
number: ${button_gpio}
inverted: True
name: ${friendly_name} Button
on_press:
- switch.toggle: relay
entity_category: "diagnostic"
switch:
- platform: gpio
name: ${friendly_name}
pin: ${relay_gpio}
id: relay
restore_mode: RESTORE_DEFAULT_OFF #Try to restore relay state after reboot/power-loss event.
#RESTORE_DEFAULT_OFF (Default) - Attempt to restore state and default to OFF if not possible to restore. Uses flash write cycles.
#RESTORE_DEFAULT_ON - Attempt to restore state and default to ON. Uses flash write cycles.
#ALWAYS_OFF - Always initialize the pin as OFF on bootup. Does not use flash write cycles.
#ALWAYS_ON - Always initialize the pin as ON on bootup. Does not use flash write cycles.
on_turn_on:
- light.turn_on:
id: blue_led
brightness: 100%
on_turn_off:
- light.turn_off: blue_led
output:
- platform: esp8266_pwm
id: green_output
pin: ${green_gpio}
inverted: False
- platform: esp8266_pwm
id: blue_output
pin: ${blue_gpio}
inverted: False
light:
- platform: monochromatic
name: ${friendly_name} Green LED
output: green_output
id: green_led
entity_category: "diagnostic"
restore_mode: ALWAYS_OFF #Start with light off after reboot/power-loss event.
#RESTORE_DEFAULT_OFF (Default) - Attempt to restore state and default to OFF if not possible to restore. Uses flash write cycles.
#RESTORE_DEFAULT_ON - Attempt to restore state and default to ON. Uses flash write cycles.
#ALWAYS_OFF - Always initialize the pin as OFF on bootup. Does not use flash write cycles.
#ALWAYS_ON - Always initialize the pin as ON on bootup. Does not use flash write cycles.
effects:
- strobe:
- flicker:
alpha: 50% #The percentage that the last color value should affect the light. More or less the “forget-factor” of an exponential moving average. Defaults to 95%.
intensity: 50% #The intensity of the flickering, basically the maximum amplitude of the random offsets. Defaults to 1.5%.
- lambda:
name: Throb
update_interval: 1s
lambda: |-
static int state = 0;
auto call = id(green_led).turn_on();
// Transtion of 1000ms = 1s
call.set_transition_length(1000);
if (state == 0) {
call.set_brightness(1.0);
} else {
call.set_brightness(0.01);
}
call.perform();
state += 1;
if (state == 2)
state = 0;
- platform: monochromatic
name: ${friendly_name} Blue LED
output: blue_output
entity_category: "diagnostic"
id: blue_led
restore_mode: ALWAYS_OFF #Start with light off after reboot/power-loss event.
#RESTORE_DEFAULT_OFF (Default) - Attempt to restore state and default to OFF if not possible to restore. Uses flash write cycles.
#RESTORE_DEFAULT_ON - Attempt to restore state and default to ON. Uses flash write cycles.
#ALWAYS_OFF - Always initialize the pin as OFF on bootup. Does not use flash write cycles.
#ALWAYS_ON - Always initialize the pin as ON on bootup. Does not use flash write cycles.
effects:
- strobe:
- flicker:
alpha: 50% #The percentage that the last color value should affect the light. More or less the “forget-factor” of an exponential moving average. Defaults to 95%.
intensity: 50% #The intensity of the flickering, basically the maximum amplitude of the random offsets. Defaults to 1.5%.
- lambda:
name: Throb
update_interval: 1s
lambda: |-
static int state = 0;
auto call = id(blue_led).turn_on();
// Transtion of 1000ms = 1s
call.set_transition_length(1000);
if (state == 0) {
call.set_brightness(1.0);
} else {
call.set_brightness(0.01);
}
call.perform();
state += 1;
if (state == 2)
state = 0;
# Blink the green light if we aren't connected to WiFi. Could use https://esphome.io/components/status_led.html instead but then we couldn't use the green light for other things as well.
interval:
- interval: 500ms
then:
- if:
condition:
not:
wifi.connected:
then:
- light.turn_on:
id: green_led
brightness: 100%
transition_length: 0s
- delay: 250ms
- light.turn_off:
id: green_led
transition_length: 250ms