Skip to content

Commit 92380cc

Browse files
author
Manus Operator
committed
Add Docker support with PowerShell automation scripts
1 parent 8bc75f6 commit 92380cc

File tree

5 files changed

+362
-87
lines changed

5 files changed

+362
-87
lines changed

.dockerignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Python
2+
__pycache__
3+
*.py[cod]
4+
*.so
5+
.Python
6+
build
7+
develop-eggs
8+
dist
9+
downloads
10+
eggs
11+
.eggs
12+
lib
13+
lib64
14+
parts
15+
sdist
16+
var
17+
wheels
18+
*.egg-info
19+
.installed.cfg
20+
*.egg
21+
MANIFEST
22+
23+
# Environment
24+
.env
25+
.venv
26+
venv
27+
ENV
28+
venv.bak
29+
30+
# Data
31+
*.csv
32+
33+
# Logs
34+
*.log
35+
36+
# Git
37+
.git
38+
.gitignore
39+
40+
# IDE
41+
.idea
42+
.vscode
43+
44+
# Other
45+
*.bak

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use official Python image as base
2+
FROM python:3.11-slim
3+
4+
# Install system dependencies for Bluetooth
5+
RUN apt-get update && apt-get install -y \
6+
bluez \
7+
bluetooth \
8+
libbluetooth-dev \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Set working directory
12+
WORKDIR /app
13+
14+
# Copy requirements file and install Python dependencies
15+
COPY requirements.txt ./
16+
RUN pip install --no-cache-dir -r requirements.txt
17+
18+
# Copy all application files
19+
COPY . ./
20+
21+
# Expose port 5000 for Flask
22+
EXPOSE 5000
23+
24+
# Set environment variables
25+
ENV FLASK_APP=monitor.py
26+
ENV PYTHONUNBUFFERED=1
27+
28+
# Command to run the application
29+
CMD ["python", "monitor.py"]

README.md

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
1-
# BatteryHub 🔋
2-
3-
**Universal Battery Management System Monitor** - Real-time monitoring for multiple BMS types!
4-
5-
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)
6-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7-
[![BMS Support](https://img.shields.io/badge/BMS-JBD%20%7C%20Daly%20%7C%20ANT-green.svg)](https://github.com/driller442/BatteryHub)
8-
9-
> 🎯 **Monitor your battery in real-time with a beautiful web dashboard!**
10-
11-
## ✨ Features
12-
13-
- 🔌 **Multi-BMS Support** - JBD, Daly, ANT, Overkill Solar, Xiaoxiang
14-
- 📊 **Real-Time Monitoring** - Voltage, Current, SOC, Temperature, Power
15-
- 📱 **Cell Voltage Tracking** - Individual cell monitoring with delta calculation
16-
- 🌐 **Web Dashboard** - Responsive interface at http://localhost:5000
17-
- 📈 **Historical Graphs** - Interactive 24-hour charts with Chart.js
18-
- 💾 **CSV Data Logging** - Automatic logging for external analysis
19-
-**Efficient BLE Protocol** - Notification-based (low power, fast updates)
20-
21-
## 🚀 Quick Start
22-
23-
```bash
24-
git clone https://github.com/driller442/BatteryHub.git
25-
cd BatteryHub
26-
pip install -r requirements.txt
27-
python monitor.py
28-
Open http://localhost:5000 in your browser!
29-
30-
📋 Supported BMS Hardware
31-
BrandModelsStatus
32-
JBDDP04S007, SP04S028, etc.✅ Fully Tested
33-
Overkill SolarAll JBD chipset models✅ Compatible
34-
XiaoxiangSmart BMS series✅ Compatible
35-
DalySmart BMS with Bluetooth⚠️ Experimental
36-
ANTLifepo4 BMS⚠️ Experimental
37-
Hardware Tested
38-
✅ JBD BMS DP04S007L4S100A (4S 100A) - Confirmed Working
39-
40-
🔧 Configuration
41-
Edit config.json with your BMS MAC address:
42-
43-
json
44-
{
45-
"user_config": {
46-
"mac_address": "A5:C2:37:3D:2D:93",
47-
"selected_profile": "JBD_Standard"
48-
}
49-
}
50-
🐛 Troubleshooting
51-
BMS Not Found?
52-
53-
Ensure BMS is powered on
54-
55-
Connect a load to wake from sleep
56-
57-
Check Bluetooth is enabled
58-
59-
Getting Zeros?
60-
61-
BMS in sleep mode - connect load/charger
62-
63-
Power cycle the BMS
64-
65-
🤝 Contributing
66-
Contributions welcome! See CONTRIBUTING.md
67-
68-
Report bugs
69-
70-
Add BMS profiles
71-
72-
Submit pull requests
73-
74-
📄 License
75-
MIT License - see LICENSE file for details.
76-
77-
⭐ Support This Project
78-
If BatteryHub is useful to you:
79-
80-
⭐ Star this repository
81-
82-
📣 Share with the DIY battery community
83-
84-
🐛 Report bugs or suggest features
85-
86-
🤝 Contribute code or documentation
87-
1+
# BatteryHub 🔋
2+
3+
**Universal Battery Management System Monitor** - Real-time monitoring for multiple BMS types!
4+
5+
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7+
[![BMS Support](https://img.shields.io/badge/BMS-JBD%20%7C%20Daly%20%7C%20ANT-green.svg)](https://github.com/driller44/batteryhub)
8+
9+
> 🎯 **Monitor your battery in real-time with a beautiful web dashboard!**
10+
11+
## ✨ Features
12+
13+
- 🔌 **Multi-BMS Support** - JBD, Daly, ANT, Overkill Solar, Xiaoxiang
14+
- 📊 **Real-Time Monitoring** - Voltage, Current, SOC, Temperature, Power
15+
- 📱 **Cell Voltage Tracking** - Individual cell monitoring with delta calculation
16+
- 🌐 **Web Dashboard** - Responsive interface at http://localhost:5000
17+
- 📈 **Historical Graphs** - Interactive 24-hour charts with Chart.js
18+
- 💾 **CSV Data Logging** - Automatic logging for external analysis
19+
-**Efficient BLE Protocol** - Notification-based (low power, fast updates)
20+
21+
## 🚀 Quick Start
22+
23+
```bash
24+
git clone https://github.com/driller44/batteryhub.git
25+
cd BatteryHub
26+
pip install -r requirements.txt
27+
python monitor.py
28+
Open http://localhost:5000 in your browser!
29+
30+
📋 Supported BMS Hardware
31+
BrandModelsStatus
32+
JBDDP04S007, SP04S028, etc.✅ Fully Tested
33+
Overkill SolarAll JBD chipset models✅ Compatible
34+
XiaoxiangSmart BMS series✅ Compatible
35+
DalySmart BMS with Bluetooth⚠️ Experimental
36+
ANTLifepo4 BMS⚠️ Experimental
37+
Hardware Tested
38+
✅ JBD BMS DP04S007L4S100A (4S 100A) - Confirmed Working
39+
40+
🔧 Configuration
41+
Edit config.json with your BMS MAC address:
42+
43+
json
44+
{
45+
"user_config": {
46+
"mac_address": "A5:C2:37:3D:2D:93",
47+
"selected_profile": "JBD_Standard"
48+
}
49+
}
50+
🐛 Troubleshooting
51+
BMS Not Found?
52+
53+
Ensure BMS is powered on
54+
55+
Connect a load to wake from sleep
56+
57+
Check Bluetooth is enabled
58+
59+
Getting Zeros?
60+
61+
BMS in sleep mode - connect load/charger
62+
63+
Power cycle the BMS
64+
65+
🤝 Contributing
66+
Contributions welcome! See CONTRIBUTING.md
67+
68+
Report bugs
69+
70+
Add BMS profiles
71+
72+
Submit pull requests
73+
74+
📄 License
75+
MIT License - see LICENSE file for details.
76+
77+
⭐ Support This Project
78+
If BatteryHub is useful to you:
79+
80+
⭐ Star this repository
81+
82+
📣 Share with the DIY battery community
83+
84+
🐛 Report bugs or suggest features
85+
86+
🤝 Contribute code or documentation
87+
8888
Made with ❤️ for the DIY solar and battery enthusiast community

build-docker.ps1

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<#
2+
BatteryHub Docker Build and Deployment Script
3+
#>
4+
5+
# Check if Docker is running
6+
function Check-DockerRunning {
7+
try {
8+
docker version | Out-Null
9+
Write-Host "? Docker is running" -ForegroundColor Green
10+
} catch {
11+
Write-Host "? Docker is not running. Please start Docker Desktop." -ForegroundColor Red
12+
exit 1
13+
}
14+
}
15+
16+
# Stop and remove existing container
17+
function Stop-Container {
18+
$container = docker ps -a --filter "name=batteryhub" --format "{{.ID}}"
19+
if ($container) {
20+
docker stop batteryhub 2>$null
21+
docker rm batteryhub 2>$null
22+
Write-Host "? Removed existing batteryhub container" -ForegroundColor Yellow
23+
}
24+
}
25+
26+
# Build Docker image
27+
function Build-Image {
28+
Write-Host "Building Docker image..." -ForegroundColor Yellow
29+
docker build -t driller44/batteryhub:latest .
30+
if ($LASTEXITCODE -ne 0) {
31+
Write-Host "? Docker build failed" -ForegroundColor Red
32+
exit 1
33+
}
34+
Write-Host "? Successfully built driller44/batteryhub:latest" -ForegroundColor Green
35+
}
36+
37+
# Create data directory if missing
38+
function Create-DataDir {
39+
if (-not (Test-Path -Path "data")) {
40+
New-Item -ItemType Directory -Path "data" | Out-Null
41+
Write-Host "? Created data directory" -ForegroundColor Yellow
42+
}
43+
}
44+
45+
# Run Docker container
46+
function Run-Container {
47+
Write-Host "Starting container..." -ForegroundColor Yellow
48+
docker run -d --name batteryhub -p 5000:5000 -v ${PWD}/data:/app/data -v ${PWD}/config.json:/app/config.json driller44/batteryhub:latest
49+
if ($LASTEXITCODE -ne 0) {
50+
Write-Host "? Failed to start container" -ForegroundColor Red
51+
exit 1
52+
}
53+
Write-Host "? Container started successfully!" -ForegroundColor Green
54+
Write-Host ""
55+
Write-Host "=== Access BatteryHub ===" -ForegroundColor Cyan
56+
Write-Host "Dashboard: http://localhost:5000" -ForegroundColor White
57+
Write-Host "Logs: .\manage-docker.ps1 logs" -ForegroundColor White
58+
Write-Host "Stop: .\manage-docker.ps1 stop" -ForegroundColor White
59+
}
60+
61+
# Main execution
62+
Write-Host "=== BatteryHub Docker Build Script ===" -ForegroundColor Cyan
63+
Write-Host ""
64+
Check-DockerRunning
65+
Stop-Container
66+
Build-Image
67+
Create-DataDir
68+
Run-Container
69+
70+
# Option to push to Docker Hub
71+
Write-Host ""
72+
$push = Read-Host "Push to Docker Hub? (y/N)"
73+
if ($push -eq 'y' -or $push -eq 'Y') {
74+
Write-Host "Logging into Docker Hub..." -ForegroundColor Yellow
75+
docker login
76+
if ($LASTEXITCODE -eq 0) {
77+
Write-Host "Pushing image..." -ForegroundColor Yellow
78+
docker push driller44/batteryhub:latest
79+
if ($LASTEXITCODE -eq 0) {
80+
Write-Host "? Successfully pushed to Docker Hub" -ForegroundColor Green
81+
Write-Host "Pull command: docker pull driller44/batteryhub:latest" -ForegroundColor White
82+
} else {
83+
Write-Host "? Failed to push to Docker Hub" -ForegroundColor Red
84+
}
85+
} else {
86+
Write-Host "? Docker login failed" -ForegroundColor Red
87+
}
88+
}

0 commit comments

Comments
 (0)