WhToday error

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

Moderator: leecollings

Post Reply
hclardij
Posts: 12
Joined: Tuesday 27 October 2020 9:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

WhToday error

Post by hclardij »

Hi all,
I am new to programming and started with a little script to add the power generation of my 2 SMA inverters. Somehow I see something weird that I cannot explan. Please help.
First I created a 'dummy', sensor type 'electric (instant + counter)'
Then created this script:

return {

on = {
timer = { 'every 1 minutes' }
},

execute = function(domoticz, item)

local SolarPowerE = domoticz.devices(1) -- Power Erker
local SolarPowerG = domoticz.devices(3) -- Power Garage
local SolarPowerT = domoticz.devices(5) -- Total Solar Power

SolarPowerT.updateElectricity(
SolarPowerE.WhActual + SolarPowerG.WhActual,
SolarPowerE.WhToday + SolarPowerG.WhToday
)

end

}

Where SolarPowerT is the sum of my 2 generated powers of the inverters.
What I see is the following: SolarPowerT. WhActual is displaying the right value; SolarPowerT.WhToday starts with the negative value of what has been produced the day before. So if I have generated 35kWh on monday, it starts at tuesday 0.00 hours with -35kWh and then slowly ramps up.
Both the Inverters start the day with 0 so the total should be 0 too.

What am I overlooking here?

Thanks in advance !
User avatar
waltervl
Posts: 5737
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: WhToday error

Post by waltervl »

The counter value should be the total counter until now, like what you read on the display of your electricity meter.

So today 35
Tomorrow 35+30.
Etc

So you should combine the .WhTotal values instead of WhToday and put that in your combined dummy device.

Domoticz will do the today calculation for you.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: WhToday error

Post by Derik »

Like to have this script also..
I do also have multiple inverters..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
hclardij
Posts: 12
Joined: Tuesday 27 October 2020 9:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WhToday error

Post by hclardij »

Hi,
That could be an explanation although that would be agains what I read in the manual and that is 100% not what I see;
Every night the counter starts at a negative number This morning the value started at -37.4 kWh or so... During the day the numbers add up nicely,...but it always starts with the wrong number at midnight.
domoticz.jpg
domoticz.jpg (20.37 KiB) Viewed 693 times
hclardij
Posts: 12
Joined: Tuesday 27 October 2020 9:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WhToday error

Post by hclardij »

I see what you mean with the counter; I don't see why I start with the negative still. I tried with the WhToday but that is for the moment displaying the wrong value; I need to check what happens after midnight
User avatar
waltervl
Posts: 5737
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: WhToday error

Post by waltervl »

This script should work

Code: Select all

return {

	on = {
		timer = { 'every 1 minutes' }
},

	execute = function(domoticz, item)

	local SolarPowerE = domoticz.devices(1) -- Power Erker
	local SolarPowerG = domoticz.devices(3) -- Power Garage
	local SolarPowerT = domoticz.devices(5) -- Total Solar Power
	
	SolarPowerT.updateElectricity(SolarPowerE.WhActual + SolarPowerG.WhActual, SolarPowerE.WhTotal + SolarPowerG.WhTotal)

	end

}
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
hclardij
Posts: 12
Joined: Tuesday 27 October 2020 9:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WhToday error

Post by hclardij »

Hi,
I have tried that; I see a value but not the value that I want to see. This is displaying the total kWh that has been generated in its lifetime for both inverters.

Lets take 1 stap back to explain what I want to have displayed: I want the actual generated power and the total generated power for that day.
The value should be set to 0 at the beginning of the day.
Each inverter is giving those values individually, but I want to have the sum of both inverters.

I did a little test and created a second dummy sensor SolarPowerTT; Furthermore I set the value for the 2nd variable in the function to 0 instead of the sum of 2 other values.

return {

on = {
timer = { 'every 1 minutes' }
},

execute = function(domoticz, item)

local SolarPowerE = domoticz.devices(1) -- Power Erker
local SolarPowerG = domoticz.devices(3) -- Power Garage
local SolarPowerT = domoticz.devices(5) -- Total Solar Power Actual
local SolarPowerTT = domoticz.devices(6) -- Total Solar Power Today

SolarPowerT.updateElectricity(SolarPowerE.actualWatt + SolarPowerG.actualWatt, 0)
SolarPowerTT.updateElectricity(SolarPowerE.WhToday + SolarPowerG.WhToday, 0)

end

}

This is the output:
domo.jpg
domo.jpg (35.52 KiB) Viewed 677 times


So the SolarTotalToday sensor is working as it is displaying the right value.
The 'Today' value in the SolarTotal sensor is constant at minus 37.441 kWh . So by the looks it starts at -37k and then adds 0 everytime the script runs. Hence the steady -37441.

I think the electricity function in not appropriate for what I am looking for; I just need 2 values and no counter.

NB: This is a test setup with nothing else attached to it.

Thanks for your help!
User avatar
waltervl
Posts: 5737
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: WhToday error

Post by waltervl »

hclardij wrote: Monday 19 July 2021 15:49 Hi,
I have tried that; I see a value but not the value that I want to see. This is displaying the total kWh that has been generated in its lifetime for both inverters.
This is because it is the first time you did the calculation. If you keep on sending the data it will behave exactly the same as your normal 2 single solar panel counters. So you have to be patient...... keep it running for a couple of days.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
hclardij
Posts: 12
Joined: Tuesday 27 October 2020 9:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WhToday error

Post by hclardij »

Ok, I'll do that ! Thanks !
hclardij
Posts: 12
Joined: Tuesday 27 October 2020 9:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WhToday error

Post by hclardij »

You are right,..it works now.!!
Thanks a lot!
domo.jpg
domo.jpg (36.36 KiB) Viewed 654 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest