Skip to content

Commit 5722927

Browse files
committed
Add ESPHome
1 parent e85ecb9 commit 5722927

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

.templates/esphome/service.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
esphome:
2+
container_name: esphome
3+
image: esphome/esphome:latest
4+
restart: unless-stopped
5+
user: 0:1000
6+
volumes:
7+
- ./volumes/esphome:/config
8+
- /etc/localtime:/etc/localtime:ro
9+
network_mode: host
10+
devices:
11+
- /dev/ttyUSB0:/dev/ttyUSB0

install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,5 +313,10 @@ if [ ! "$(user_in_group docker)" == "true" ]; then
313313
echo "You will need to restart your system before the changes take effect."
314314
sudo usermod -G "docker" -a $USER
315315
fi
316+
if [ ! -e /dev/ttyUSB0 ]; then
317+
echo "Creating static /dev/ttyUSB0 device for ESPhome"
318+
sudo mknod -m660 /dev/ttyUSB0 c 188 0
319+
sudo chgrp dialout /dev/ttyUSB0
320+
fi
316321
do_env_checks
317322
do_kernel_checks

menu.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,20 @@ function do_env_setup() {
252252
fi
253253
}
254254

255+
function do_ttyUSB0_checks() {
256+
[ -e /dev/ttyUSB0 ] && return
257+
echo "/dev/ttyUSB0 not created, needed for esphome" >&2
258+
[ -f .ttyusb0_notcreated ] && return
259+
260+
if (whiptail --title "/dev/ttyUSB0" --yesno "/dev/ttyUSB0 not created, and is required to run ESPHome.\nWould you like to create it now?\n\nYou will not be prompted again." 20 78); then
261+
echo "Creating static /dev/ttyUSB0 device for ESPHome"
262+
sudo mknod -m660 /dev/ttyUSB0 c 188 0
263+
sudo chgrp dialout /dev/ttyUSB0
264+
else
265+
touch .ttyusb0_notcreated
266+
fi
267+
}
268+
255269
function do_docker_checks() {
256270
if command_exists docker; then
257271
DOCKER_VERSION_GOOD="false"
@@ -369,6 +383,7 @@ else
369383
do_env_checks
370384
do_python3_checks
371385
echo "Please enter sudo pasword if prompted"
386+
do_ttyUSB0_checks
372387
do_docker_checks
373388

374389
if [[ "$DOCKER_VERSION_GOOD" == "true" ]] && \

0 commit comments

Comments
 (0)