Skip to content

Commit 48864be

Browse files
committed
chore: initial commit
0 parents  commit 48864be

17 files changed

+930
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; https://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[*.md]
14+
indent_size = 4
15+
trim_trailing_whitespace = false

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
3+
/secrets.yaml

.yamlfmt.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
doublestar: true
3+
exclude:
4+
- "**/*.sops.yaml"
5+
formatter:
6+
type: basic
7+
disable_alias_key_correction: true
8+
drop_merge_tag: true
9+
eof_newline: true
10+
force_array_style: block
11+
include_document_start: true
12+
line_ending: lf
13+
retain_line_breaks_single: true
14+
scan_folded_as_literal: true
15+
trim_trailing_whitespace: true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# esphome-configs

alexs-bedroom-bluetooth-proxy.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
# settings
3+
esphome:
4+
name: alexs-bedroom-bluetooth-proxy
5+
friendly_name: "Alex's Bedroom Bluetooth Proxy"
6+
7+
esp32:
8+
board: m5stack-atoms3
9+
variant: esp32s3
10+
framework:
11+
type: esp-idf
12+
13+
wifi:
14+
ssid: !secret wifi_ssid
15+
password: !secret wifi_password
16+
use_address: "192.168.2.171"
17+
domain: ".iot"
18+
on_connect:
19+
then:
20+
- light.turn_on:
21+
id: status_led
22+
red: 0%
23+
green: 100%
24+
blue: 0%
25+
brightness: 100%
26+
effect: none
27+
28+
logger:
29+
30+
api:
31+
encryption:
32+
key: !secret api_key
33+
34+
ota:
35+
- platform: esphome
36+
password: !secret ota_password
37+
38+
# configuration
39+
light:
40+
- platform: esp32_rmt_led_strip
41+
id: status_led
42+
chipset: WS2812
43+
pin: 35
44+
num_leds: 1
45+
rgb_order: GRB
46+
internal: true
47+
48+
bluetooth_proxy:
49+
active: true
50+
51+
esp32_ble_tracker:
52+
scan_parameters:
53+
interval: 320ms
54+
window: 320ms
55+
active: false

attic-bluetooth-proxy.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
# settings
3+
esphome:
4+
name: attic-bluetooth-proxy
5+
friendly_name: "Attic Bluetooth Proxy"
6+
7+
esp32:
8+
board: m5stack-atoms3
9+
variant: esp32s3
10+
framework:
11+
type: esp-idf
12+
13+
wifi:
14+
ssid: !secret wifi_ssid
15+
password: !secret wifi_password
16+
use_address: "192.168.2.120"
17+
domain: ".iot"
18+
on_connect:
19+
then:
20+
- light.turn_on:
21+
id: status_led
22+
red: 0%
23+
green: 100%
24+
blue: 0%
25+
brightness: 100%
26+
effect: none
27+
28+
logger:
29+
30+
api:
31+
encryption:
32+
key: !secret api_key
33+
34+
ota:
35+
- platform: esphome
36+
password: !secret ota_password
37+
38+
# configuration
39+
light:
40+
- platform: esp32_rmt_led_strip
41+
id: status_led
42+
chipset: WS2812
43+
pin: 35
44+
num_leds: 1
45+
rgb_order: GRB
46+
internal: true
47+
48+
bluetooth_proxy:
49+
active: true
50+
51+
esp32_ble_tracker:
52+
scan_parameters:
53+
interval: 320ms
54+
window: 320ms
55+
active: false

carport-door-opener.yaml

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
---
2+
# settings
3+
esphome:
4+
name: carport-door-opener
5+
friendly_name: "Carport Door Opener"
6+
7+
esp8266:
8+
board: nodemcuv2
9+
restore_from_flash: true
10+
11+
wifi:
12+
ssid: !secret wifi_ssid
13+
password: !secret wifi_password
14+
use_address: "192.168.2.77"
15+
domain: ".iot"
16+
17+
logger:
18+
19+
api:
20+
encryption:
21+
key: !secret api_key
22+
23+
ota:
24+
- platform: esphome
25+
password: !secret ota_password
26+
27+
sensor:
28+
- platform: wifi_signal
29+
name: "WiFi Signal dB"
30+
id: wifi_signal_db
31+
update_interval: 60s
32+
entity_category: "diagnostic"
33+
34+
# configuration
35+
globals:
36+
- id: performing_last_movement
37+
type: boolean
38+
restore_value: no
39+
initial_value: "false"
40+
41+
switch:
42+
- platform: gpio
43+
id: garage_door_relay
44+
pin: D1
45+
inverted: true
46+
restore_mode: ALWAYS_OFF
47+
internal: true
48+
on_turn_on:
49+
- delay: 500ms
50+
- switch.turn_off: garage_door_relay
51+
52+
binary_sensor:
53+
- platform: gpio
54+
id: open_endstop
55+
name: "Open Endstop"
56+
device_class: garage_door
57+
internal: true
58+
pin:
59+
number: D3
60+
mode: INPUT_PULLUP
61+
filters:
62+
- invert:
63+
- delayed_on: 1000ms # Wait to stop moving (1000ms for mechanical, higher for magnetic - depending on magnet strength)
64+
- delayed_off: 1000ms # Wait to start moving (1000ms for mechanical, higher for magnetic - depending on magnet strength)
65+
66+
- platform: gpio
67+
id: closed_endstop
68+
name: "Closed Endstop"
69+
device_class: garage_door
70+
internal: true
71+
pin:
72+
number: D2
73+
mode: INPUT_PULLUP
74+
filters:
75+
- invert:
76+
- delayed_on: 1000ms # Wait to stop moving (1000ms for mechanical, higher for magnetic - depending on magnet strength)
77+
- delayed_off: 1000ms # Wait to start moving (1000ms for mechanical, higher for magnetic - depending on magnet strength)
78+
79+
cover:
80+
- platform: template
81+
name: "Carport Door"
82+
id: carport_door
83+
device_class: garage
84+
assumed_state: true
85+
lambda: !lambda |-
86+
if (id(closed_endstop).state) // Door at closed endstop
87+
{
88+
if (id(carport_door).current_operation == esphome::cover::COVER_OPERATION_OPENING) // We should be opening
89+
{
90+
if (!id(performing_last_movement)) // Make sure we don't trigger this logic twice otherwise it will do unwanted things
91+
{
92+
delay(1000); // Wait for door to stop in case reed is triggered too early
93+
id(garage_door_relay).turn_on(); // Press button again
94+
id(performing_last_movement) = true; // Set flag to indicate we madeknow where the door is
95+
}
96+
}
97+
else if (id(carport_door).current_operation == esphome::cover::COVER_OPERATION_CLOSING)
98+
{
99+
// We should be closing, so all is good
100+
id(performing_last_movement) = false;
101+
id(carport_door).current_operation = esphome::cover::COVER_OPERATION_IDLE;
102+
id(carport_door).position = COVER_CLOSED;
103+
id(carport_door).publish_state();
104+
return COVER_CLOSED;
105+
}
106+
else
107+
{
108+
// No operation in progress, just send state
109+
id(performing_last_movement) = false;
110+
if ((!id(carport_door).position) == esphome::cover::COVER_CLOSED)
111+
{
112+
id(carport_door).position = COVER_CLOSED;
113+
id(carport_door).publish_state();
114+
return COVER_CLOSED;
115+
}
116+
}
117+
}
118+
else if (id(open_endstop).state) // Door at open endstop
119+
{
120+
if (id(carport_door).current_operation == esphome::cover::COVER_OPERATION_CLOSING) // We should be closing
121+
{
122+
if (!id(performing_last_movement)) // Make sure we don't trigger this logic twice otherwise it will do unwanted things
123+
{
124+
delay(1000); // Wait for door to stop in case reed is triggered too early
125+
id(garage_door_relay).turn_on(); // Press button again
126+
id(performing_last_movement) = true; // Set flag to indicate we madeknow where the door is
127+
}
128+
}
129+
else if (id(carport_door).current_operation == esphome::cover::COVER_OPERATION_OPENING)
130+
{
131+
// We should be opening, so all is good
132+
id(performing_last_movement) = false;
133+
id(carport_door).current_operation = esphome::cover::COVER_OPERATION_IDLE;
134+
id(carport_door).position = COVER_OPEN;
135+
id(carport_door).publish_state();
136+
return COVER_OPEN;
137+
}
138+
else // Door not at any endstop
139+
{
140+
// No operation in progress, just send state
141+
id(performing_last_movement) = false;
142+
if (id(carport_door).position != esphome::cover::COVER_OPEN)
143+
{
144+
id(carport_door).position = COVER_OPEN;
145+
id(carport_door).publish_state();
146+
return COVER_OPEN;
147+
}
148+
}
149+
}
150+
else
151+
{
152+
// The door is halfway open, so set it to OPEN
153+
if (id(carport_door).position != esphome::cover::COVER_OPEN)
154+
{
155+
id(carport_door).position = COVER_OPEN;
156+
id(carport_door).publish_state();
157+
return COVER_OPEN;
158+
}
159+
}
160+
return {};
161+
open_action:
162+
- lambda: !lambda |-
163+
id(carport_door).current_operation = esphome::cover::COVER_OPERATION_OPENING;
164+
if (!id(open_endstop).state) {
165+
id(garage_door_relay).turn_on();
166+
if (id(closed_endstop).state) {
167+
id(performing_last_movement) = true; // Set flag to indicate we know where the door is
168+
}
169+
}
170+
close_action:
171+
- lambda: !lambda |-
172+
id(carport_door).current_operation = esphome::cover::COVER_OPERATION_CLOSING;
173+
if (!id(closed_endstop).state) {
174+
id(garage_door_relay).turn_on();
175+
if (id(open_endstop).state) {
176+
id(performing_last_movement) = true; // Set flag to indicate we know where the door is
177+
}
178+
}
179+
stop_action:
180+
- lambda: !lambda |-
181+
if (id(carport_door).current_operation == esphome::cover::COVER_OPERATION_CLOSING ||
182+
id(carport_door).current_operation == esphome::cover::COVER_OPERATION_OPENING)
183+
{
184+
id(carport_door).current_operation = esphome::cover::COVER_OPERATION_IDLE;
185+
// Stop the door if it is moving
186+
id(performing_last_movement) = false;
187+
id(garage_door_relay).turn_on();
188+
}

0 commit comments

Comments
 (0)