Wrong value

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

Moderator: leecollings

Post Reply
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Wrong value

Post 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 982 times
Attachments
5C05F2D0-3F49-468C-9363-265E9C967AD1.jpeg
5C05F2D0-3F49-468C-9363-265E9C967AD1.jpeg (123.4 KiB) Viewed 983 times
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Wrong value

Post by jvdz »

multiply by 1000?

Code: Select all

Opbrengst.updateElectricity(Enphase + Solaredge)*1000, 0)
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Wrong value

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post 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.
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Wrong value

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post by edwin1234 »

Thanks for your help
Here are the photos

Image

Values are zero now because its morning :)
Attachments
IMG_0846.jpeg
IMG_0846.jpeg (64.4 KiB) Viewed 904 times
IMG_0847.jpeg
IMG_0847.jpeg (60.63 KiB) Viewed 904 times
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Wrong value

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post by edwin1234 »

Thanks for the answer,

Sorry but dont know how to do that or where to find these values.
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Wrong value

Post 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 )
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post by edwin1234 »

Thank you very much for the answer.
I am gonna try that

Regards
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post 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
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Wrong value

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post 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"
		},
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Wrong value

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post by edwin1234 »

Ok , thank you

I will try that and let you know.

Regards
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Wrong value

Post by edwin1234 »

Hi Walter,

Its working 👍🏻

Thank you

Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest