Skip to Main Content

Info

Last week our solarpanels were installed, so I thought I'd mess around with Domoticz to see how they are doing.

Hardware Software
  • Ubuntu 20.04.4 LTS. I started out with Ubuntu 22.04, which was just released at the time, but I ran into a small bug. The Domoticz (text based) installer did not respond well to keystrokes, so even selecting OK by pressing Enter was impossible. 20.04 had no such issues so I switched to that.
  • Domoticz 2022.1.14127.

Domoticz Installation

I installed everything on my VMware server, but any supported platform will do fine of course.

For Ubuntu 20.04.4 I chose the minimal install, which works fine. Ubuntu Server may be an even better choice, since you don't really need the GUI.
I gave my VM a static IP address (10.9.1.36) and created a user tstruik.

After installing Ubuntu, I installed some packages to make life easier (i.e. making sure I could use ifconfig and Putty).
I used the Domoticz Wiki Installation Guide.
Note that curl needed to be installed first (probably because I used the minimal install). This is what I used - note that User, Group, ExecStart and WorkingDirectory need to be changed for your user, and that I enabled SSL here but don't actually use it. Enable the service

Configuration - Smart Meter and SMA Inverter

Configuration of a Dutch DSMR smart meter with P1 port is explained clearly on this Wiki page.

To connect the SMA Inverter to Domoticz you also need the SMA Inverters ModbusTCPIP plugin.

On our SMA Inverter I also had to enable TCP and UDP (otherwise the plugin will report "ModBus not Activated").
This requires logging in to the SMA webinterface with the Installer user group.
Then go to Settings --> External Communication/Modbus and enable both TCP & UDP.

This info on How to Test the Connection to Your SMA Inverter can be useful as well.

Steps I took to install the plugin:
The Hardware setup in Domoticz looks like this:
Hardware setup in Domoticz

Virtual meter for Energy Consumption

Since the Smart Meter reports the sum of power usage and return (or delivery), you can't see what you are actually consuming.
Which is ironic, because before we got solar panels this was not a problem; we always returned zero, so the usage was equal to the actual consumption.
To see that info again, you need to combine 3 numbers (usage, delivery and solar) and show the result in Domoticz.

I used the info and script found at Virtual meter that is the sum of two other meters, and the Domoticz Events page. LUA script setup:
And this is the content of my LUA script:
Note that I made some changes to the original script.
I removed the "if (devicechanged[solarsensor]) then" construct and set the interval Trigger to Time instead. Using devicechanged only works if the value actually changes, so at night when the value is zero, you get no results. And even during the day 2 consecutive results may have the same value.
I also changed the variable names a bit, and simplified the script as much as possible.
And I changed the logic of the calculation because - for my particular setup anyway - the original was not correct.

The end result is functional, but not perfect.
The SMA inverter input only refreshes every 5 minutes, while the script queries it every minute. This can lead to errors (like negative values for Consumption) because the script calculates the Consumption using the Smart Meter every minute. Over the course of the day this will have only a small impact, but it does look a bit weird. A better way would be to do the calculation using the average of the Smart Meter data over a 5 minute period, but that is not simple...

This is how it looks in Domoticz.:
Consumption in Domoticz
Note the negative values around 14:00, surrounded by high positive values. So the "interval noise" does cancel itself out mostly, but it is not very elegant.