|
1 | 1 | # 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. |
3 | 5 |
|
4 | 6 | ## 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 |
7 | 8 | ```bash
|
8 | 9 | git clone https://github.com/aaronjbrown/PyGrowatt.git
|
9 | 10 | 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 |
10 | 21 | pip install -r requirements.txt .
|
11 | 22 | ```
|
12 | 23 | To install for all users on the system, run pip as root:
|
13 | 24 | ```bash
|
14 | 25 | sudo pip install -r requirements.txt .
|
15 | 26 | ```
|
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)_ |
17 | 58 | Copy the ```Growatt.lua``` file into the [Wireshark Plugins folder](https://www.wireshark.org/docs/wsug_html_chunked/ChPluginFolders.html). For example on MacOS:
|
18 | 59 | ```bash
|
19 | 60 | mkdir -p ~/.config/wireshark/plugins
|
20 |
| -cp PyGrowatt/scripts/Growatt.lua ~/.config/wireshark/plugins |
| 61 | +cp scripts/Growatt.lua ~/.config/wireshark/plugins |
21 | 62 | ```
|
22 | 63 |
|
23 | 64 | ## 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: |
27 | 66 | ```bash
|
28 | 67 | 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 |
35 | 69 | ```
|
36 | 70 | 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.
|
37 | 71 |
|
|
0 commit comments