Page 1 of 1

Wrong value

Posted: Tuesday 08 April 2025 17:55
by edwin1234
I have this script running:

Code: Select all

 on = { timer = { "every 1 minutes" }},     -- Change to your liking to 1,2,3,4,5,6,10,12,15 or 20   

   execute = function(dz, item)
        
       local Opbrengst  = dz.devices(1813)
       local Enphase     = dz.devices("Enphase Panelen - total").counterToday
       local Solaredge   = dz.devices("OpbrengstTotaal").counterToday
       
       Opbrengst.updateElectricity(dz.utils.round(Enphase + Solaredge), 0) -- Rounded to two decimals
        
   end
}
It adds the enphase and solaredge values
And writes to a dummy general kwh device
It gives today a value of 19 wh but should be 19kwh
Image
Image

How can i change this ?

Regards
E95DF840-4950-4637-9B81-A0FB762F4B70.jpeg
E95DF840-4950-4637-9B81-A0FB762F4B70.jpeg (51.05 KiB) Viewed 989 times

Re: Wrong value

Posted: Tuesday 08 April 2025 18:39
by jvdz
multiply by 1000?

Code: Select all

Opbrengst.updateElectricity(Enphase + Solaredge)*1000, 0)

Re: Wrong value

Posted: Tuesday 08 April 2025 18:45
by waltervl
updateElectricity(power, energy)
Power is W, energy is Wh.
But you should not use .counterToday as input value but .WhTotal.
This will give you at first huge total (as it will combine the total energy production of your solar panels) but you can delete that after a day from the month graph. And then it will show you nicely your total daily production.

See also the scripts in the energy dashboard topic: viewtopic.php?p=317834#p317834

Re: Wrong value

Posted: Tuesday 08 April 2025 20:02
by edwin1234
I treid your script but got an error:

Error: dzVents: Error: (3.1.7) An error occurred when calling event handler zonnepanelenTotaal
2025-04-08 19:59:00.334 Error: dzVents: Error: (3.1.7) .../domoticz/scripts/dzVents/scripts/zonnepanelenTotaal.lua:11: attempt to perform arithmetic on a nil value (field 'WhTotal')

Code: Select all

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

execute = function(domoticz, item)

local Enphase = domoticz.devices(1185) -- Solar set 1, existing General kwh device
local Solaredge = domoticz.devices(905) -- Solar set 2, existing General kwh device -- Create manually a dummy kWh, Electricity (instant and counter) device$
local totalPower =  domoticz.devices(2460) -- total, to be used in Energy dashboard configuration


totalPower.updateElectricity( Enphase.actualWatt + Solaredge.actualWatt, Enphase.WhTotal + Solaredge.WhTotal )
end

}
What did i do wrong here?
Sorry i am a real script noob.

Re: Wrong value

Posted: Tuesday 08 April 2025 23:32
by waltervl
It could be that one of the 2 solarpanel devices is not a General kWh devices that does not have a WhTotal value.

Can you make a screenshot of those 2 devices so we can see what the type is? Then you should adapt the function to get the correct Wh value.

Re: Wrong value

Posted: Wednesday 09 April 2025 6:14
by edwin1234
Thanks for your help
Here are the photos

Image

Values are zero now because its morning :)

Re: Wrong value

Posted: Wednesday 09 April 2025 8:07
by waltervl
So the Enphase is a P1 meter, then you have to read other values. It could be Enphase.return1 or Enphase.return2 for the counter values depending on the input. And Enphase.usageDelivered for the Watt values.

Re: Wrong value

Posted: Wednesday 09 April 2025 12:14
by edwin1234
Thanks for the answer,

Sorry but dont know how to do that or where to find these values.

Re: Wrong value

Posted: Wednesday 09 April 2025 13:05
by waltervl
A P1 smart meter device is the wrong device to monitor a solar panel inverter, but you cannot do anything about this as the plugin developer decided that for you.
If you look at the graph on the Enphase log page sou see T1 and T2 graphs. Look which one the Enphase plugin is using and use that one.
In your script change line

Code: Select all

totalPower.updateElectricity( Enphase.actualWatt + Solaredge.actualWatt, Enphase.WhTotal + Solaredge.WhTotal )
into

Code: Select all

totalPower.updateElectricity( Enphase.usageDelivered + Solaredge.actualWatt, Enphase.return1 + Solaredge.WhTotal )
or if T2 is used:

Code: Select all

totalPower.updateElectricity( Enphase.usageDelivered + Solaredge.actualWatt, Enphase.return2 + Solaredge.WhTotal )

Re: Wrong value

Posted: Wednesday 09 April 2025 15:41
by edwin1234
Thank you very much for the answer.
I am gonna try that

Regards

Re: Wrong value

Posted: Thursday 10 April 2025 21:22
by edwin1234
Hi waltervl,
The script doesnt give an error but it only shows the kwh from solaredge in total.
It doesnt add enphase with it.
I did try both methods .

Regards

Re: Wrong value

Posted: Thursday 10 April 2025 23:57
by waltervl
Can you post the outcome of API call (modify to real values: server-ip, port and IDX of Enphase p1 device)

Code: Select all

http://server-ip:port/json.htm?type=command&param=getdevices&rid=IDX

Re: Wrong value

Posted: Friday 11 April 2025 5:33
by edwin1234
Forget to mention that i’m on an older domoticz version
(2021)


Code: Select all

 {
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "2322.119",
			"CounterDeliv" : "0.000",
			"CounterDelivToday" : "0.000 kWh",
			"CounterToday" : "0.000 kWh",
			"CustomImage" : 0,
			"Data" : "2322119;0;0;0;0;0",
			"Description" : "Opbrengst van de enphase panelen bij elkaar",
			"Favorite" : 0,
			"HardwareDisabled" : false,
			"HardwareID" : 13,
			"HardwareName" : "Enphase Panelen",
			"HardwareType" : "Enphase Envoy - with micro inverters",
			"HardwareTypeVal" : 94,
			"HaveTimeout" : false,
			"ID" : "EnphaseEnvoyUsage",
			"LastUpdate" : "2025-04-10 21:09:17",
			"Name" : "Enphase Panelen - total",
			"Notifications" : "false",
			"PlanID" : "0",
			"PlanIDs" : 
			[
				0
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Energy",
			"SwitchTypeVal" : 0,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 1,
			"Usage" : "0 Watt",
			"UsageDeliv" : "0 Watt",
			"Used" : 1,
			"XOffset" : "0",
			"YOffset" : "0",
			"idx" : "1185"
		},

Re: Wrong value

Posted: Friday 11 April 2025 10:46
by waltervl
Try it with Enphase.usage1 or usage2 instead of Enphase.return1 or 2
If you move to a newer version the Enphase integration will not use the P1 smart meter device anymore but normal general kWh devices, much better.

Re: Wrong value

Posted: Friday 11 April 2025 13:14
by edwin1234
Ok , thank you

I will try that and let you know.

Regards

Re: Wrong value

Posted: Saturday 12 April 2025 17:09
by edwin1234
Hi Walter,

Its working šŸ‘šŸ»

Thank you

Regards