-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathesp_hallway
175 lines (149 loc) · 4.07 KB
/
esp_hallway
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
substitutions:
plug_name: esp-hallway
esphome:
name: ${plug_name}
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifiha
password: !secret passwifi
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp epfloor2 Fallback Hotspot"
password: !secret paswapesp
captive_portal:
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
password: !secret api
ota:
password: !secret api
##############################################
light:
#свет в спальне
- platform: binary
name: "Bedroom Lamp"
output: output_bedroom_lamp
id: light_bedroom
#подсветка в спальне
- platform: binary
name: "Bedroom illumination"
output: output_bedroom_illumination
id: light_bedroom_illumination
#свет в restroom
- platform: binary
name: "Restroom Lamp"
output: output_restroom_lamp
id: light_restroom
#фоновая подсветка в коридоре
- platform: monochromatic
name: "Hallway Led"
output: output_component_hallway_led
id: light_hallway_led
##############################################
output:
#пин для света в спальне
- id: output_bedroom_lamp
platform: gpio
pin: D7
#пин подсветки в спальне
- id: output_bedroom_illumination
platform: gpio
pin: D5
#пин света в restroom
- id: output_restroom_lamp
platform: gpio
pin: D6
#пин для фоновой подсветки в коридоре
- platform: esp8266_pwm
id: output_component_hallway_led
pin: D1
###############################################
binary_sensor:
#Выключатель LED
- platform: gpio
pin:
number: D3
mode: INPUT_PULLUP
inverted: true
name: "${plug_name} Button Bedroom Lamp"
filters:
- delayed_on: 150ms
- delayed_off: 150ms
on_press:
- light.toggle: light_bedroom
# on_release:
# - delay: 10s
# - light.turn_off: light_bedroom_lamp
#Выключатель в restroom и bedroom
- platform: gpio
pin:
number: D4
mode: INPUT_PULLUP
inverted: true
name: "${plug_name} Button Bedroom Illumination"
filters:
- delayed_on: 150ms
- delayed_off: 150ms
on_press:
- light.toggle: light_bedroom_illumination
# - delayed_on: 150ms
# - delayed_off: 150ms
# on_press:
# - light.toggle: light_restroom_lamp
#Выключатель на D8 для restroom
- platform: gpio
pin:
number: D8
# mode: INPUT_PULLUP
inverted: true
name: "${plug_name} Button Restroom Lamp "
filters:
- delayed_on: 200ms
- delayed_off: 200ms
on_press:
- light.toggle: light_restroom
#Датчик движения с включением фоновой подсветки
- platform: gpio
pin:
number: D2
inverted: false
mode: INPUT_PULLUP
name: "Hallway sensor"
filters:
- delayed_on: 200ms
- delayed_off: 10s
device_class: motion
on_press:
- light.turn_on: light_hallway_led
on_release:
# - delay: 10s
- light.turn_off: light_hallway_led
################################################
sensor:
- platform: uptime
id: device_uptime
# internal: true
- platform: wifi_signal
name: "${plug_name} WiFi"
update_interval: 15s
text_sensor:
- platform: template
name: "${plug_name} uptime"
lambda: |-
uint32_t uptime = (id(device_uptime).state);
int minutes = (uptime % 3600) / 60;
int hours = (uptime % 86400) / 3600;
int days = uptime / 86400;
if (days > 0) {
return { (String(days) + " д." + String(hours) + " ч." + String(minutes) + " мин.").c_str() };
}
if (hours > 0) {
return { (String(hours) + " ч. " + String(minutes) + " мин.").c_str() };
} else {
return { (String(minutes) + " мин.").c_str() };
}
update_interval: 60s
icon: mdi:clock-start