Script to estimate energy flow on the meter

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
thebenchmark
Posts: 1
Joined: Sunday 20 November 2022 21:30
Target OS: -
Domoticz version:
Contact:

Script to estimate energy flow on the meter

Post by thebenchmark »

Hello everyone

I measure both my power usage & production. After the usage meter there is no production it has been completely split.
There are 5 solar generators and 1 usage meters in total. They are all connected to DomoticZ and date is nicely being processed there.
I wanted to add a virtual meter to determine the power movement at the meter level. This can be calculated as usage minus production.
I made script for this but its not calculating. I'm ashamed to say I had it working before but now it's no longer working after adding the 5th solar array.
I'm running the latest stable domoticZ version.

Code: Select all

return {

	on = {
	    timer = { 'every minute' }
	},
	
	execute = function(domoticz, item)
	    
	    local pcmPower = domoticz.devices(9)      -- Internal power consumption meter
	    local pvzPower = domoticz.devices(3)      -- solar zuid
	    local pvoPower = domoticz.devices(4)      -- solar oost
	    local pvwPower = domoticz.devices(5)      -- solar west
	    local pvvPower = domoticz.devices(2)      -- solar front 
	    local pvz2Power = domoticz.devices(1)      -- solar zuid APS 2
	
	    local totalPower = domoticz.devices(6)  -- total (power consumtion - solar) power meter for movement of MAIN grid
	    
	    totalPower.updateElectricity(
            	pcmPower.WhActual - pvzPower.WhActual - pvoPower.WhActual - pvwPower.WhActual - pvz2Power.WhActual - pvvPower.WhActual,
            	pcmPower.WhTotal - pvzPower.WhTotal - pvoPower.WhTotal - pvwPower.WhTotal - pvz2Power.WhTotal - pvvPower.WhTotal
            )
	    
	end
	
}
EDIT: After a bit of searching it seems the new power meter doesn't support the "WhActual" value. Its a youless meter so i'll have to find that.
HvdW
Posts: 504
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Script to estimate energy flow on the meter

Post by HvdW »

Here you go. viewtopic.php?p=293865#p293865
The script in itself is not your usercase buy you can learn from this script how to import the JSON string and extract the data you'd like to analyze.
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests