Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install yamllint
- name: Run yamllint
run: yamllint .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode
.esphome_cache
9 changes: 9 additions & 0 deletions .lefthook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
assert_lefthook_installed: true
skip_lfs: true

pre-commit:
parallel: true
jobs:
- name: yamllint
run: yamllint .
10 changes: 10 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
extends: relaxed
rules:
line-length:
max: 256
level: warning
document-start: disable
ignore:
- ".esphome_cache/**"
- "esphome/.esphome/**"
90 changes: 90 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
version: "3"

vars:
CACHE_DIR: "{{.USER_WORKING_DIR}}/.esphome_cache"

tasks:
default:
desc: List all tasks
cmd: task --list-all

setup-cache:
desc: Create cache directories if they don't exist
cmds:
- mkdir -p "{{.CACHE_DIR}}/pip"
- mkdir -p "{{.CACHE_DIR}}/platformio"
generates:
- "{{.CACHE_DIR}}/pip"
- "{{.CACHE_DIR}}/platformio"

compile:
desc: Compile the ESPHome config
deps: [setup-cache]
cmd: >-
docker run --rm
-v "$PWD/esphome:/config"
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
-it esphome/esphome compile loopon_unity_esp_idf.yaml

flash:
desc: Flash the ESPHome firmware to the Unity sensor
deps: [setup-cache]
cmds:
- echo "Flashing firmware to Unity sensor..."
- >-
docker run --rm
-v "$PWD/esphome:/config"
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
--privileged
--network host
-v /dev:/dev
-it esphome/esphome
upload loopon_unity_esp_idf.yaml --device /dev/cu.usbmodem2101

monitor:
desc: Monitor the ESPHome firmware serial output
deps: [setup-cache]
cmds:
- echo "Connecting to Unity sensor serial monitor..."
- >-
docker run --rm
-v "$PWD/esphome:/config"
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
--privileged
-v /dev:/dev
-it esphome/esphome
logs loopon_unity_esp_idf.yaml

run:
desc: Run and watch the ESPHome firmware in real-time (upload + monitor)
deps: [setup-cache]
cmds:
- echo "Running Unity sensor firmware (uploading and monitoring)..."
- >-
docker run --rm
-v "$PWD/esphome:/config"
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
--privileged
-v /dev/cu.usbmodem2101:/dev/cu.usbmodem2101
-it esphome/esphome
run loopon_unity_esp_idf.yaml --device /dev/cu.usbmodem2101

log:
desc: Alternative way to monitor logs (same as monitor task)
deps: [setup-cache]
cmds:
- echo "Connecting to Unity sensor logs..."
- >-
docker run --rm
-v "$PWD/esphome:/config"
-v "{{.CACHE_DIR}}/pip:/root/.cache/pip"
-v "{{.CACHE_DIR}}/platformio:/root/.platformio"
--privileged
-v /dev:/dev
-it esphome/esphome
logs loopon_unity_esp_idf.yaml
Loading