Page 1 of 1

Domoticz own dashbords electricity, bidirectional measurement

Posted: Monday 22 December 2025 21:15
by geoterm
Hi,
I've created my own dashboard for electricity consumption and production in a single-family home. It's based on a PZEM-004T system with six units. Three are for production and three are for consumption by the building. Now I need to create devices: the amount of energy in kWh, the energy pumped into the grid (when there's overproduction), and the energy drawn from the grid so I can compare it with the utility's bidirectional energy meter. There's a device in Domoticz called a smart meter (an attachment), but I don't know how to use it. Please help.

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Monday 22 December 2025 23:36
by HvdW
Most important: https://wiki.domoticz.com/DzVents:_next ... _scripting
Learn to use dzVents, the easiest scripting language around.
to get all data from Power - P1
domoticz.devices('Power').dump()

Code: Select all

return {
    on = {
        timer = { 'every minute' }
    },

    execute = function(domoticz)
        domoticz.log(domoticz.devices('Power').dump(), domoticz.LOG_INFO)
    end
}
Watch the log every minute.
Here is another script

Code: Select all

return {
    on = {
        timer = { 'every minute' }
    },

    execute = function(domoticz)

        local powerDevice = domoticz.devices('Power')
        local textDevice  = domoticz.devices('Electricity')

        if not powerDevice or not textDevice then
            domoticz.log('Power of Electricity device niet gevonden', domoticz.LOG_ERROR)
            return
        end

        -- sValue opsplitsen
        local values = domoticz.utils.stringSplit(powerDevice.sValue, ';')

        local usageT1      = values[1] or '0' -- laag
        local usageT2      = values[2] or '0' -- hoog
        local returnT1     = values[3] or '0'
        local returnT2     = values[4] or '0'
        local currentPower = values[5] or '0'
        local returnExtra  = values[6] or '0'

        -- Verbruik vandaag (kWh)
        local counterToday = powerDevice.counterToday or '0'

        -- Netjes opgemaakte tekst
        local text =
            '⚡ Electricity overzicht\n' ..
            '----------------------\n' ..
            'Verbruik vandaag   : ' .. counterToday .. ' kWh\n' ..
            '\n' ..
            'Verbruik T1 (laag) : ' .. usageT1 .. ' Wh\n' ..
            'Verbruik T2 (hoog) : ' .. usageT2 .. ' Wh\n' ..
            'Teruglevering T1  : ' .. returnT1 .. ' Wh\n' ..
            'Teruglevering T2  : ' .. returnT2 .. ' Wh\n' ..
            'Actueel vermogen  : ' .. currentPower .. ' W\n' ..
            'Teruglevering     : ' .. returnExtra

        -- Update Text device
        textDevice.updateText(text)
    end
}

Create a dummy device with the name 'Electricity' should be the type TEXT device.
The script fills in the data.

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Tuesday 23 December 2025 0:27
by waltervl
See also the wiki for the Dummy/Virtual devices that states what they are used for.
https://wiki.domoticz.com/Dummy_for_vir ... mart_meter

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Tuesday 23 December 2025 8:29
by geoterm
Ok, Thank You, i will try.

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Tuesday 23 December 2025 12:10
by geoterm
I definitely need to create two output devices – one to count kWh drawn from the grid, and the other pumped into the grid. Two input devices: the total kWh from the photovoltaics and the total kWh consumed by the building.

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Tuesday 23 December 2025 16:33
by waltervl
You can do that with the P1 smart meter device, it has 2 counters, one for usage and one for delivery.
You do not have a real grid meter that measures these values for you?

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Tuesday 23 December 2025 20:10
by geoterm
Okay, I'll do it through P1.
I have a bidirectional meter at the property line – from the power company – and I'm curious how these two measurements will compare.
Of course, I could buy a bidirectional meter at home, but it's important that it works with Domoticz so I don't have to buy BACnet gateways, etc.

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Tuesday 23 December 2025 20:52
by geoterm
There is some problem.
Logs:
2025-12-23 20:39:31.087 Error: GetJSonDevices: exception occurred : 'stoull'
2025-12-23 20:40:00.970 Error: UpdateMultiMeter: Error converting sValue values! (IDX: 287, sValue: '-601;nil;nil;nil;nil;nil', dType: 250, sType: 1)
2025-12-23 20:43:33.064 Error: dzVents: An error occurred when calling event handler L123sP1 287 dzvents
2025-12-23 20:43:33.064 Error: dzVents: ...cripts/dzVents/generated_scripts/L123sP1 287 dzvents.lua:8: attempt to call a table value
dz vents:

Code: Select all

return {
	on = {
		devices = {
			160
		}
	},
	execute = function(domoticz, device)
		domoticz.devices(287).updateP1(domoticz.utils.round((domoticz.devices(161).actualWatt - domoticz.devices(160).actualWatt), 0))
	end
}

Re: Domoticz own dashbords electricity, bidirectional measurement

Posted: Wednesday 24 December 2025 0:42
by waltervl
A P1 device needs 6 values, read the docs. You only supply 2.