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+
410ifeq ($(LOCALLY_ATTACHED ) ,1)
511# to upload to a device locally attached via USB:
612OPTIONS: =--device /dev/ttyACM0
713else
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 )
1117endif
1218
1319ifeq ($(CONFIG_FILE ) ,)
@@ -17,11 +23,21 @@ endif
1723
1824
1925flash-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
2435upload-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