Skip to content

Commit 635fc29

Browse files
committed
feat: Move to ESP-IDF framework
The ESP-IDF framework is smaller than the arduino framework, so has a few features missing. But we now fit in memory again on ESPHome 2025.7.0+ Additionally: - Add lefthook - Add yamllint hook - Lint files. We found a few bugs - Add Taskfile for common tasks (run, compile logs) Signed-off-by: Dan Webb <dan.webb@damacus.io>
1 parent ac7d7b4 commit 635fc29

File tree

9 files changed

+1754
-1221
lines changed

9 files changed

+1754
-1221
lines changed

.github/workflows/lint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Lint
3+
on: [push, pull_request]
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- name: Set up Python
10+
uses: actions/setup-python@v4
11+
with:
12+
python-version: '3.12'
13+
- name: Install dependencies
14+
run: |
15+
python -m pip install --upgrade pip
16+
pip install yamllint
17+
- name: Run yamllint
18+
run: yamllint .

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.vscode
2+
.esphome_cache

.lefthook.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
assert_lefthook_installed: true
3+
skip_lfs: true
4+
5+
pre-commit:
6+
parallel: true
7+
jobs:
8+
- name: yamllint
9+
run: yamllint .

.yamllint

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
extends: relaxed
3+
rules:
4+
line-length:
5+
max: 256
6+
level: warning
7+
document-start: disable
8+
ignore:
9+
- ".esphome_cache/**"
10+
- "esphome/.esphome/**"

Taskfile.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
version: "3"
3+
4+
vars:
5+
CACHE_DIR: "{{.USER_WORKING_DIR}}/.esphome_cache"
6+
7+
tasks:
8+
default:
9+
desc: List all tasks
10+
cmd: task --list-all
11+
12+
setup-cache:
13+
desc: Create cache directories if they don't exist
14+
cmds:
15+
- mkdir -p "{{.CACHE_DIR}}/pip"
16+
- mkdir -p "{{.CACHE_DIR}}/platformio"
17+
generates:
18+
- "{{.CACHE_DIR}}/pip"
19+
- "{{.CACHE_DIR}}/platformio"
20+
21+
compile:
22+
desc: Compile the ESPHome config
23+
deps: [setup-cache]
24+
cmd: >-
25+
docker run --rm
26+
-v "$PWD/esphome:/config"
27+
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
28+
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
29+
-it esphome/esphome compile loopon_unity_esp_idf.yaml
30+
31+
flash:
32+
desc: Flash the ESPHome firmware to the Unity sensor
33+
deps: [setup-cache]
34+
cmds:
35+
- echo "Flashing firmware to Unity sensor..."
36+
- >-
37+
docker run --rm
38+
-v "$PWD/esphome:/config"
39+
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
40+
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
41+
--privileged
42+
--network host
43+
-v /dev:/dev
44+
-it esphome/esphome
45+
upload loopon_unity_esp_idf.yaml --device /dev/cu.usbmodem2101
46+
47+
monitor:
48+
desc: Monitor the ESPHome firmware serial output
49+
deps: [setup-cache]
50+
cmds:
51+
- echo "Connecting to Unity sensor serial monitor..."
52+
- >-
53+
docker run --rm
54+
-v "$PWD/esphome:/config"
55+
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
56+
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
57+
--privileged
58+
-v /dev:/dev
59+
-it esphome/esphome
60+
logs loopon_unity_esp_idf.yaml
61+
62+
run:
63+
desc: Run and watch the ESPHome firmware in real-time (upload + monitor)
64+
deps: [setup-cache]
65+
cmds:
66+
- echo "Running Unity sensor firmware (uploading and monitoring)..."
67+
- >-
68+
docker run --rm
69+
-v "$PWD/esphome:/config"
70+
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
71+
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
72+
--privileged
73+
-v /dev/cu.usbmodem2101:/dev/cu.usbmodem2101
74+
-it esphome/esphome
75+
run loopon_unity_esp_idf.yaml --device /dev/cu.usbmodem2101
76+
77+
log:
78+
desc: Alternative way to monitor logs (same as monitor task)
79+
deps: [setup-cache]
80+
cmds:
81+
- echo "Connecting to Unity sensor logs..."
82+
- >-
83+
docker run --rm
84+
-v "$PWD/esphome:/config"
85+
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
86+
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
87+
--privileged
88+
-v /dev:/dev
89+
-it esphome/esphome
90+
logs loopon_unity_esp_idf.yaml

0 commit comments

Comments
 (0)