Skip to content

tiagordc/hksun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Huawei SUN2000

Description

Read Huawei inverter real-time data to a sqlite database.

This data can then be used by other applications to run home automations or to monitor the solar production when the inverter is not connected to the internet.

Very bespoke to my setup. Published for reference.

Local development

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
python app.py

Docker

  • Run:
docker rm -f $(docker ps -aq -f ancestor=hksun)
docker rmi hksun
docker build -t hksun .
docker run -d --name=solar --restart=unless-stopped -p 5000:5000 -v "/home/docker/solar:/database" -l autoheal=true hksun
docker system prune
docker logs --tail 20 -f solar
  • Autoheal
docker run -d --name autoheal --restart=always -v /var/run/docker.sock:/var/run/docker.sock willfarrell/autoheal
  • Query database:
watch -n 5 'sqlite3 /home/docker/solar/readings.db "SELECT * FROM Inverter ORDER BY Timestamp DESC LIMIT 10"'
  • Clear docker logs
sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'

Service

A potential service to reset the network connection if the inverter stops responding.

  • Install service:
cp solar.service /etc/systemd/system/solar.service
systemctl daemon-reload
systemctl enable solar.service
systemctl start solar.service
systemctl status solar.service

Tests

docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock python:3.11 bash
pip install docker
python
import docker
client = docker.from_env()
client.containers.list()

TODO

Releases

No releases published

Packages

No packages published