saldo saldering domoticz

Read energy consumption balance with Domoticz

Manual for setting up a meter for netting with Domoticz.

Netting and Domoticz

Domoticz is an ideal tool to read your energy meter. If you have solar panels, it is very useful if you can read your balance of consumption and return. This balance determines whether you still have to pay extra or get something back. You want to offset the electricity generated in the summer with the consumption in the winter. With this balance you can see whether you are still in the right position and whether you are not using too much.

By default you do not have a meter for netting with Domoticz. In this article I will show you how to create this.

The condition is that you have already connected a P1 kabel  to your Raspberry and have Domoticz running on it. You can read how to do this in https://daik.nl/index.php/nl/2024/01/22/zelf-meterstanden-uitlezen-met-raspberry/

Create Hardware

To start, you need to create a new Dummy hardware under Setup/Hardware, I have called it “Smartmeter”:

Create hardware

If you have clicked on Add, you can now add a device under the hardware overview:

Create Virtual Sensor

Name this: Balance and usage Sensor Type: Managed counter

Use this name, it is necessary for the script

saldo counter

Create script

Go to Setup / More Options / Events:

Click the + , to create a new script, Select dzVents/Timer:

create script Domoticz

copy the script below over the existing text, or first remove all text from the old script, so that only this new script remains:

local startUsageLow = 3475000      
local startUsageHigh = 5716000    
local startReturnLow = 30000     
local startReturnHigh = 78000    

local fetchIntervalMins = 1    --   1 = every minute, 10 = every 10 minutes, etc.)

return {
    on =      {
                        timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
              },
             
    logging = {
                         level = domoticz.LOG_DEBUG, domoticz.LOG_INFO,  
                         marker = 'Separate meter readings '
              },

    execute = function(dz, item)

        local P1  = dz.devices('Power') -- Electra, P1 Smart Meter device (idx or "name") (required)
        local sumSaldoHigh = (P1.return2 - startReturnHigh) - (P1.usage2 - startUsageHigh)
        local sumSaldoLow = (P1.return1 - startReturnLow) - (P1.usage1 - startUsageLow)
        local sumSaldo = sumSaldoHigh + sumSaldoLow

        dz.log('Saldo Hoog      : ' ..sumSaldoHigh, dz.LOG_INFO)
        dz.log('Saldo Laag       : ' ..sumSaldoLow, dz.LOG_INFO)
        dz.log('Saldo Totaal    : ' ..sumSaldo, dz.LOG_INFO)
        
        dz.devices('Saldo').updateCounter(sumSaldo)

     end
}

-- einde Script

Within the script, the following must be replaced with the values that apply to you:

local startUsageLow = 3475000

local startUsageHigh = 5716000

local startReturnLow = 30000

local startReturnHigh = 78000

You enter the meter readings there from the moment you want to settle, which will probably be the last measurement at the last settlement. You should be able to find those meter readings on your bill. You must enter the readings in Watt hours, so if your bill shows 3475 kWh, enter 3475000.

This script takes the high and low rates into account (so-called weekend rates). If you do not use that, you can enter 0 for startUsageHigh and startReturnHigh. These will have no further influence on the calculation.

Furthermore, it says “local fetchIntervalMins = 1”. This is useful for running the script for the first time, because then you can see every minute whether it is going well. If the script is running I would change that to 30, then the balance is changed every half hour, that seems sufficient to me.

Check the operation of the netting script

Save the script and go to the log to see if your script works properly. A properly functioning script results in this logging:

2024-02-07 21:04:00.295 Status: dzVents: Info: Separate meter readings : Saldo Hoog : 247671
2024-02-07 21:04:00.295 Status: dzVents: Info: Separate meter readings : Saldo Laag : 57073
2024-02-07 21:04:00.295 Status: dzVents: Info: Separate meter readings : Saldo Totaal : 304744
2024-02-07 21:04:00.296 Status: dzVents: Debug: Separate meter readings : Processing device-adapter for Saldo: Counter device adapter
2024-02-07 21:04:00.296 Status: dzVents: Info: Separate meter readings : ------ Finished SaldoPower

Naturally, the values will differ from what you encounter.

You will now also see a new card in Utility, which looks like this:

Netting meter

This will now be neatly maintained. If you put it on your dashboard (turn the asterisk yellow) you will no longer be able to miss it.

After the settlement, you simply enter the new values in the script and you can continue for another year.

If you find any errors in this article, or just want to leave some comments, please create a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *