-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcu-basement.yaml
149 lines (140 loc) · 3.31 KB
/
mcu-basement.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
substitutions:
device: basement
name: Basement
comment: "Basement: Sockets"
esphome:
name: mcu-${device}
comment: ${comment}
platform: ESP8266
board: esp01_1m
packages:
common: !include common/common_esp8266.yaml
# Sonoff Dual R2
# Pin Function
# GPIO10 Push Button
# GPIO00 Pin "button 0" on expansion header
# GPIO09 Pin "button 1" on expansion header
# GPIO12 Relay #1 and red color on LED
# GPIO05 Relay #2 and green color on LED
# GPIO13 Blue Status LED
globals:
- id: blower_auto
type: bool
restore_value: true
initial_value: "true"
binary_sensor:
- platform: gpio
pin:
number: 0
mode: INPUT_PULLUP
inverted: True
name: ${name} Light Switch
device_class: light
on_click:
- min_length: 50ms
max_length: 350ms
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.basement_light
- min_length: 351ms
max_length: 1000ms
then:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.exercise_room
- min_length: 1001ms
max_length: 10000ms
then:
# - homeassistant.service:
# service: light.turn_off
# data:
# entity_id: light.basement_light
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.exercise_room
- homeassistant.service:
service: light.turn_off
data:
entity_id: light.exercise_room_fan
- platform: gpio
pin:
number: 10
mode: INPUT_PULLUP
inverted: true
name: ${name} Socket 1 Switch
on_press:
- switch.toggle: relay_2
- platform: gpio
pin:
number: 9
mode: INPUT_PULLUP
inverted: true
name: ${name} Door
device_class: door
filters:
invert:
on_press:
- homeassistant.service:
service: light.turn_on
data:
entity_id: light.basement_light
select:
- platform: template
name: "Sewage Treatment Blower"
icon: mdi:hair-dryer-outline
optimistic: true
options:
- "ON"
- "AUTO"
- "OFF"
initial_option: "AUTO"
restore_value: true
on_value:
then:
- lambda: |-
switch (i) {
case 0: {
id(blower_auto) = false;
id(relay_1).turn_on();
} break;
case 1: {
id(blower_auto) = true;
} break;
case 2:
id(blower_auto) = false;
id(relay_1).turn_off();
}
status_led:
pin:
number: 13
inverted: yes
switch:
- platform: gpio
name: "Sewage Treatment Blower"
icon: mdi:hair-dryer-outline
pin: 12
id: relay_1
restore_mode: ALWAYS_ON
- platform: gpio
name: ${name} Socket 1
icon: mdi:power-socket-fr
pin: 5
id: relay_2
time:
- platform: homeassistant
timezone: Europe/Bratislava
on_time:
- seconds: 0
minutes: /15
then:
- if:
condition:
lambda: 'return id(blower_auto);'
then:
- switch.turn_on: relay_1
- delay: 12min
- switch.turn_off: relay_1