Byte Journeys

Join me as I share insights and discoveries from my journey in the world as a software engineering manager by day and tinkerer by night.

Deye Sun and Loxone

20 January 2023

As we ushered in the new year, I found myself the proud owner of a 400Wp solar panel that I installed on my balcony. The kit I got came with a Deye Sun 300 inverter. Like many, this inverter has an in-built webserver, which conveniently displays the amount of power being generated in somewhat real time. Naturally, as a smart home enthusiast, I was eager to integrate this data into my Loxone smart home server. Allow me to share with you a step-by-step guide on how I made this possible.

Deye web interface

Setting Up and Extracting Relevant Data

The initial step involves configuring the input, for which I leveraged a virtual HTTP input. The unique URL pattern that allows us to access our desired data appears as follows: http://{username}:{password}@{inverter-ip}/status.html. As you may have guessed, you’ll need to replace ‘username’, ‘password’, and ‘inverter-ip’ with the details that correspond to your specific setup.

Virtual HTTP input

A word of caution here: while this inverter is a fantastic tool, its webserver isn’t particularly robust. Through trial and error, I found that querying the data more frequently than every 120 seconds can cause the webserver to crash, so do bear this in mind.

The subsequent phase involves parsing the inverter’s webpage. It incorporates a snippet of JavaScript that can be parsed with relative ease. The specific value we’re after is contained in a variable dubbed ‘webdata_now_p’, which can be interpreted as depicted in the following illustration:

Parsing the page

Now we have the value of our current solar power generation available in our Loxone server and we can do with it whatever we want.

Making the Most of the Value

The ultimate goal is to incorporate the power generation value into a counter. Here’s a diagram of how I configured this:

Using the value

The diagram may seem complex due to the numerous hoops around the counter. This complexity is a byproduct of the inverter’s occasional inaccessibility. This occurs when the solar panels aren’t producing power, which naturally leads to the inverter shutting down and the web interface becoming unreachable. Furthermore, I’ve established a static variable that holds the current cost per kWh, enabling me to calculate my savings on a daily, monthly, and yearly basis with the power generated by the solar panels.

Once configured this way, you’re rewarded with a visually pleasing view in the Loxone app:

Loxone app solar energy

Conclusion

I hope that this guide facilitates your endeavor to monitor your solar power generation via your Loxone smart home server. Once you’ve established this system, the potential applications are boundless. For instance, we’ve set up a system to power a socket on or off depending on whether we’re generating more than 20W of power through the solar panels. We’ve plugged all our mobile devices’ chargers into this socket, ensuring they only charge when we’re benefiting from free energy courtesy of the sun.