Skip to content

Commit 8a493ff

Browse files
committed
Improve target_device choice
1 parent 4c5c637 commit 8a493ff

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# Basic Makefile for this ESPHome project
22
# Make sure you activate the ESPHome venv environment before running these commands
33

4+
5+
ifeq ($(LOCALLY_ATTACHED),)
6+
# default value
7+
LOCALLY_ATTACHED:=0
8+
endif
9+
410
ifeq ($(LOCALLY_ATTACHED),1)
511
# to upload to a device locally attached via USB:
612
OPTIONS:=--device /dev/ttyACM0
713
else
814
# to upload to a device that has already been flashed with this project
915
# and needs just to be updated over the network:
10-
OPTIONS:= --device smarthome-hmi-waveshare-lcd-p2.lan
16+
OPTIONS:= --device $(TARGET_DEVICE)
1117
endif
1218

1319
ifeq ($(CONFIG_FILE),)
@@ -17,11 +23,21 @@ endif
1723

1824

1925
flash-main:
26+
ifeq ($(LOCALLY_ATTACHED),0)
27+
ifeq ($(TARGET_DEVICE),)
28+
$(error "TARGET_DEVICE variable is not set. Please set it to the IP address of the device you want to flash.")
29+
endif
30+
endif
2031
@echo "Flashing the MAIN firmware..."
2132
source venv/bin/activate && \
2233
esphome run $(OPTIONS) $(CONFIG_FILE)
2334

2435
upload-main:
36+
ifeq ($(LOCALLY_ATTACHED),0)
37+
ifeq ($(TARGET_DEVICE),)
38+
$(error "TARGET_DEVICE variable is not set. Please set it to the IP address of the device you want to flash.")
39+
endif
40+
endif
2541
@echo "Uploading the MAIN firmware..."
2642
source venv/bin/activate && \
2743
esphome upload $(OPTIONS) $(CONFIG_FILE)

0 commit comments

Comments
 (0)