This tutorials shows how to integrate the Deye SUN-12K-SG04LP3-EU hybrid inverter with the KAA platform.
It utilizes the deye-controller library to fetch data from the inverter and then uses kaa_mqtt_client
to send data to the KAA platform.
SUN-12K-SG04LP3-EU
) is configured and connected to the internet.You can connect to the Deye Web UI via a local network or through a TCP proxy. I’ll show you how to configure it in both ways.
{your_inverter_ip}/config_hide.html
.TCP-Server
and Port to 8899
.This will enable the MQTT client to read data from the Deye inverter over your local network.
For remote access, you will need a server with a static IP. We’ll use go-solarman-proxy as the TCP proxy, which requires Go to run. This setup allows you to send data to a remote server without being restricted to the local network where the inverter is installed.
Navigate to {your_inverter_ip}/config_hide.html
.
Under Server A Settings, set both IP address and Domain Name to your static server’s IP.
Choose a port, such as 12345
.
In Internal server parameters setting, set Protocol to TCP-Client
, IP to the desired IP (such as 192.168.3.123
), and Port to 8899
.
Download and install go-solarman-proxy according to the documentation.
Launch the proxy with the following command:
go-solarman-proxy 0.0.0.0 12345
If the connection is successful, this will link the Deye logger to your server. The proxy will then allow the MQTT Client to read data from the Deye logger.
Download the Python MQTT client from here.
Set up the environment and navigate to the examples/deye
directory.
This project requires the following environment variables to work properly:
export IP="{local-or-proxy-ip}"
export SERIAL_NUMBER="{your-deye-device-serial-number}"
export DEFAULT_KPC_HOST="mqtt.cloud.kaaiot.com"
export DEFAULT_KPC_PORT="1883"
export APPLICATION_VERSION="{your-application-version}"
export ENDPOINT_TOKEN="{your-endpoint-token}"
DEFAULT_KPC_HOST, DEFAULT_KPC_PORT, APPLICATION_VERSION, and ENDPOINT_TOKEN: These values can be found here.
IP: Open you Deye inverter’s Web Interface.
If you’re connecting locally, use the IP address found in the index_cn.html
file under the Device Information tab.
For a proxy setup, set the IP to localhost
.
To start the project, install required libraries by executing:
pip install -r requirements.txt
Then insert the environment variables into your terminal and execute main.py
.
You can use the Kaa dashboard to create a custom UI to view your data and go beyond the default device page.
This part requires the TENANT_ID
and APPLICATION_NAME
variables to work:
export TENANT_ID="{your-tenant-id}"
export APPLICATION_NAME="{your-application-name}"
Add them and restart the program to apply changes.
In Kaa console open the Solutions tab. A solution is automatically created for each application, but you can create a new one if needed.
To keep things simple, here’s a quick example.
After running the python3 main.py
script, a JSON template will be generated using the environment variables you provided earlier.
To apply the template, follow these steps:
In the top right corner, click Import Dashboard.
Navigate to the ./template/output
folder and copy the code from overview.json
.
Paste the code into the import dialog.
You should now see a dashboard similar to the one shown at the beginning of this section.