Public Access
feat(build): devcontainer setup
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
3 files changed
+151
No files matched your search
@@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"name": "ESPHome NUT UPS Development",
|
||||||
|
"image": "ghcr.io/esphome/esphome:latest",
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/devcontainers/features/git:1": {},
|
||||||
|
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||||
|
"ghcr.io/devcontainers/features/python:1": {
|
||||||
|
"version": "3.11",
|
||||||
|
"installTools": true
|
||||||
|
},
|
||||||
|
"ghcr.io/anthropics/devcontainer-features/claude-code:1.0.5": {}
|
||||||
|
},
|
||||||
|
"mounts": [
|
||||||
|
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
|
||||||
|
"source=/dev,target=/dev,type=bind"
|
||||||
|
],
|
||||||
|
"privileged": true,
|
||||||
|
"runArgs": [
|
||||||
|
"--device-cgroup-rule=c 188:* rmw",
|
||||||
|
"--device-cgroup-rule=c 189:* rmw",
|
||||||
|
"--device=/dev/bus/usb:/dev/bus/usb:rwm"
|
||||||
|
],
|
||||||
|
"workspaceFolder": "/workspace",
|
||||||
|
"postCreateCommand": "bash .devcontainer/setup.sh",
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"ms-python.python",
|
||||||
|
"ms-python.flake8",
|
||||||
|
"ms-python.black-formatter",
|
||||||
|
"redhat.vscode-yaml",
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"ms-vscode.cmake-tools",
|
||||||
|
"esphome.esphome-vscode",
|
||||||
|
"platformio.platformio-ide",
|
||||||
|
"ms-vscode.hexeditor"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"python.defaultInterpreterPath": "/usr/local/bin/python",
|
||||||
|
"python.formatting.provider": "black",
|
||||||
|
"python.linting.enabled": true,
|
||||||
|
"python.linting.flake8Enabled": true,
|
||||||
|
"files.associations": {
|
||||||
|
"*.yaml": "yaml",
|
||||||
|
"*.yml": "yaml"
|
||||||
|
},
|
||||||
|
"terminal.integrated.defaultProfile.linux": "bash",
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"[yaml]": {
|
||||||
|
"editor.tabSize": 2
|
||||||
|
},
|
||||||
|
"[python]": {
|
||||||
|
"editor.tabSize": 4
|
||||||
|
},
|
||||||
|
"[cpp]": {
|
||||||
|
"editor.tabSize": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"forwardPorts": [
|
||||||
|
6052,
|
||||||
|
6123,
|
||||||
|
80,
|
||||||
|
443,
|
||||||
|
8080,
|
||||||
|
3232
|
||||||
|
],
|
||||||
|
"containerEnv": {
|
||||||
|
"ESPHOME_DASHBOARD_USE_PING": "true",
|
||||||
|
"PLATFORMIO_CORE_DIR": "/workspace/.platformio"
|
||||||
|
},
|
||||||
|
"init": true,
|
||||||
|
"remoteUser": "root",
|
||||||
|
"capAdd": [
|
||||||
|
"SYS_RAWIO",
|
||||||
|
"SYS_ADMIN"
|
||||||
|
]
|
||||||
|
}
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "🚀 Setting up ESPHome NUT UPS Development Environment..."
|
||||||
|
|
||||||
|
# Update and install packages
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y \
|
||||||
|
usbutils libusb-1.0-0-dev libudev-dev build-essential cmake ninja-build \
|
||||||
|
git wget curl tree vim nano htop tmux screen jq socat minicom picocom udev
|
||||||
|
|
||||||
|
# Install Python tools
|
||||||
|
pip install --upgrade pip black flake8 pylint mypy pytest jupyter ipython platformio
|
||||||
|
|
||||||
|
# Update ESPHome
|
||||||
|
pip install --upgrade esphome
|
||||||
|
|
||||||
|
# Set up USB permissions
|
||||||
|
cat > /etc/udev/rules.d/99-esphome-usb.rules << 'UDEV_EOF'
|
||||||
|
SUBSYSTEM=="usb", ATTR{idVendor}=="303a", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTR{idVendor}=="10c4", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTR{idVendor}=="1a86", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTR{idVendor}=="051d", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTR{idVendor}=="0764", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", MODE="0666"
|
||||||
|
UDEV_EOF
|
||||||
|
|
||||||
|
# Create aliases
|
||||||
|
cat >> ~/.bashrc << 'BASH_EOF'
|
||||||
|
alias esphome-config='esphome config'
|
||||||
|
alias esphome-compile='esphome compile'
|
||||||
|
alias esphome-upload='esphome upload'
|
||||||
|
alias esphome-logs='esphome logs'
|
||||||
|
alias esphome-dashboard='esphome dashboard /workspace'
|
||||||
|
alias lsusb='lsusb -v'
|
||||||
|
alias serialports='ls -la /dev/tty{USB,ACM}* 2>/dev/null || echo "No serial ports found"'
|
||||||
|
alias build-component='cd /workspace && esphome compile configs/test-config.yaml'
|
||||||
|
alias flash-test='cd /workspace && esphome upload configs/test-config.yaml'
|
||||||
|
alias monitor='cd /workspace && esphome logs configs/test-config.yaml'
|
||||||
|
BASH_EOF
|
||||||
|
|
||||||
|
# Welcome message
|
||||||
|
cat > /tmp/WELCOME.md << 'WELCOME_EOF'
|
||||||
|
# 🎉 ESPHome NUT UPS Development Environment Ready!
|
||||||
|
|
||||||
|
## Quick Commands
|
||||||
|
- `esphome-dashboard` - Start web dashboard
|
||||||
|
- `./tools/scan-usb.sh` - Check USB devices
|
||||||
|
- `build-component` - Build test config
|
||||||
|
- `flash-test` - Flash to device
|
||||||
|
- `monitor` - View logs
|
||||||
|
|
||||||
|
Happy coding! 🚀
|
||||||
|
WELCOME_EOF
|
||||||
|
|
||||||
|
echo "✅ Development environment setup complete!"
|
||||||
|
cat /tmp/WELCOME.md
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "🔍 Scanning USB devices..."
|
||||||
|
echo "========================="
|
||||||
|
echo "All USB devices:"
|
||||||
|
lsusb
|
||||||
|
echo ""
|
||||||
|
echo "ESP32 boards:"
|
||||||
|
lsusb | grep -E "(303a|10c4|1a86)" || echo "No ESP32 boards found"
|
||||||
|
echo ""
|
||||||
|
echo "UPS devices:"
|
||||||
|
lsusb | grep -E "(051d|0764)" || echo "No UPS devices found"
|
||||||
|
echo ""
|
||||||
|
echo "Serial ports:"
|
||||||
|
ls -la /dev/tty{USB,ACM}* 2>/dev/null || echo "No serial ports found"
|
||||||
Reference in new issue
Block a user