Skip to content

Commit 4308643

Browse files
committed
Docker and Kubernetes support.
1 parent 7f8de89 commit 4308643

File tree

4 files changed

+116
-14
lines changed

4 files changed

+116
-14
lines changed

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Specific files
2+
Dockerfile
3+
.dockerignore
4+
.gitignore
5+
.DS_Store
6+
.git
7+
.idea
8+
kubernetes/
9+
scripts/Growatt.lua
10+
test/
11+
12+
# Byte-compiled / optimized / DLL files
13+
__pycache__/
14+
*.py[cod]
15+
*$py.class
16+
17+
# Distribution / packaging
18+
build
19+
dist
20+
venv
21+
venv3
22+
*.egg-info/

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3
2+
3+
WORKDIR /opt/PyGrowatt
4+
5+
copy . .
6+
RUN pip install --no-cache-dir -r requirements.txt .
7+
8+
WORKDIR /opt/PyGrowatt/scripts
9+
ENTRYPOINT [ "python" ]
10+
CMD [ "growatt_pvoutput.py", "--config", "/opt/PyGrowatt/scripts/config.ini" ]

README.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,71 @@
11
# PyGrowatt
2-
PyGrowatt extends [PyModbus](https://github.com/riptideio/pymodbus) to implement the custom modbus protocol used by [Growatt](https://www.ginverter.com/) solar inverters with [ShineWiFi-X](https://www.ginverter.com/Monitoring/10-630.html) modules. PyGrowatt can be used to communicate with a solar inverter, decode energy data, and upload it to services such as [PVOutput](https://pvoutput.org/).
2+
PyGrowatt extends [PyModbus](https://github.com/riptideio/pymodbus) to implement the custom modbus protocol used by [Growatt](https://www.ginverter.com/) solar inverters with [ShineWiFi-X](https://www.ginverter.com/Monitoring/10-630.html) modules. PyGrowatt provides custom ModbusRequest and ModbusResponse objects for use with PyModbus.
3+
4+
PyGrowatt can be used to communicate with a solar inverter, decode energy data, and upload it to services such as [PVOutput](https://pvoutput.org/). An example script is included to start a TCP server listening on port 5279 and wait for an inverter to connect. Once an inverter connects, the server will parse the received energy data and periodically upload the data to PVOutput.
35

46
## Installation
5-
### PyGrowatt Python Module
6-
Download the repository and use [pip](https://pip.pypa.io/en/stable/) to install PyGrowatt:
7+
### Download the repository
78
```bash
89
git clone https://github.com/aaronjbrown/PyGrowatt.git
910
cd PyGrowatt
11+
```
12+
13+
### Edit the configuration
14+
```bash
15+
cp scripts/config.ini.example scripts/config.ini
16+
vi scripts/config.ini
17+
```
18+
### Python Module _(optional)_
19+
Use [pip](https://pip.pypa.io/en/stable/) to install PyGrowatt to the local system:
20+
```bash
1021
pip install -r requirements.txt .
1122
```
1223
To install for all users on the system, run pip as root:
1324
```bash
1425
sudo pip install -r requirements.txt .
1526
```
16-
### Growatt Wireshark Dissector:
27+
28+
### Docker Container _(optional)_
29+
Build a [Docker](https://www.docker.com/) container:
30+
```bash
31+
docker build -t pygrowatt .
32+
```
33+
By default, the container runs the example ```growatt_pvoutput.py``` script.
34+
35+
### Kubernetes Deployment _(optional)_
36+
To deploy in a minikube instance:
37+
```bash
38+
# Ensure minikube is installed
39+
brew install minikube
40+
41+
#Start minikube and configure it to use the local Docker environment
42+
minikube start
43+
44+
# Point your shell to minikube's docker-daemon (in each terminal)
45+
eval $(minikube -p minikube docker-env)
46+
47+
# Build the Docker container (as above) in minikube's docker-daemon
48+
docker build -t pygrowatt .
49+
50+
# Apply the kubernetes deployment template
51+
kubectl apply -f kubernetes/pygrowatt-deployment.yaml
52+
53+
# Forward ports from your localhost to your minikube instance
54+
kubectl port-forward --address 0.0.0.0 services/pygrowatt-service 5279:5279
55+
```
56+
57+
### Growatt Wireshark Dissector _(optional)_
1758
Copy the ```Growatt.lua``` file into the [Wireshark Plugins folder](https://www.wireshark.org/docs/wsug_html_chunked/ChPluginFolders.html). For example on MacOS:
1859
```bash
1960
mkdir -p ~/.config/wireshark/plugins
20-
cp PyGrowatt/scripts/Growatt.lua ~/.config/wireshark/plugins
61+
cp scripts/Growatt.lua ~/.config/wireshark/plugins
2162
```
2263

2364
## Usage
24-
PyGrowatt provides custom ModbusRequest and ModbusResponse objects for use with PyModbus.
25-
26-
An example script is included to start a TCP server listening on port 5279 and wait for an inverter to connect. Once an inverter connects, the server will parse the received energy data and periodically upload the data to PVOutput. To use this script, first you will need to create a configuration file:
65+
To use the example PVOutput script you will need to enter your `Apikey` and `SystemId` in the configuration file, then execute the script:
2766
```bash
2867
cd scripts
29-
cp config.ini.example config.ini
30-
vi config.ini
31-
```
32-
You will need to enter your `Apikey` and `SystemId`, then you can execute the script:
33-
```bash
34-
python growatt_wifi.py
68+
python growatt_pvoutput.py --config config.ini
3569
```
3670
Finally, you need to configure the ShineWifi-X module to communicate with the computer running this script. You will also need to configure the computer running this script with a static IP address.
3771

kubernetes/pygrowatt-deployment.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: pygrowatt-deployment
5+
labels:
6+
app: pygrowatt
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: pygrowatt
12+
template:
13+
metadata:
14+
name: pygrowatt
15+
labels:
16+
app: pygrowatt
17+
spec:
18+
containers:
19+
- name: pygrowatt-container
20+
image: pygrowatt
21+
imagePullPolicy: Never
22+
ports:
23+
- containerPort: 5279
24+
protocol: TCP
25+
---
26+
apiVersion: v1
27+
kind: Service
28+
metadata:
29+
name: pygrowatt-service
30+
spec:
31+
selector:
32+
app: pygrowatt
33+
ports:
34+
- port: 5279
35+
targetPort: 5279
36+
type: LoadBalancer

0 commit comments

Comments
 (0)