dzVents calculations energy solar panels
Posted: Thursday 01 June 2023 18:41
Hi,
I have 2 solar systems (SunnyBoy) and have them added to Domoticz. To see what the totals of both systems are, I have a dummy called "Zonnepanelen". With below script I calculate the current and the total of today until 'now':
To register the highest power, I use
to update the uservariable 'HighestZonnepanelen' as soon as the current registered value is lower than the value that is registered by the solar panels. And that value is shown on my dashboard with another script. So far, so good and it's fun to see what the highest power, voltage or whatever has been so far.
Now, I would like to write the highest total power that day. That script should be triggered once a day of course, but whatever I do.....I get very strange values and I don't know what I'm doing wrong.
I use this script:
But the total (day)value at that moment was 30.227kWh and the uservariable is updated with something like 1729803.0 and it doesn't even look like the value I expect. Mind you, this was during the day and it would be better if I got the values when the systems have shut down during the evening.
What am I doing wrong with this last script?
I have 2 solar systems (SunnyBoy) and have them added to Domoticz. To see what the totals of both systems are, I have a dummy called "Zonnepanelen". With below script I calculate the current and the total of today until 'now':
Code: Select all
return
{
on =
{
timer = { 'every minute' }
},
execute = function(domoticz, item)
local garagePower = domoticz.devices(2013) -- garage
local woningPower = domoticz.devices(2039) -- woning
local totalPower = domoticz.devices(2037) -- totaal (garage + woning)
totalPower.updateElectricity(
garagePower.WhActual + woningPower.WhActual,
garagePower.WhTotal + woningPower.WhTotal
)
--domoticz.variables('HighestZonnepanelenDaily').set(garagePower.WhActual + woningPower.WhActual)
end
}
Code: Select all
commandArray = {}
solar = otherdevices_svalues['Zonnepanelen']
now, total = solar:match("([^;]+);([^;]+)")
-- Retrieve the current value of the "Zonnepanelen" sensor
local current_value = tonumber(now)
-- Retrieve the highest value stored in the user variable "Zonnepanelen"
local highest_value = tonumber(uservariables['HighestZonnepanelen'])
-- Check if the current value is higher than the stored highest value
if current_value > highest_value then
-- Update the user variable with the new highest value
commandArray['Variable:HighestZonnepanelen'] = tostring(current_value)
end
return commandArray
Now, I would like to write the highest total power that day. That script should be triggered once a day of course, but whatever I do.....I get very strange values and I don't know what I'm doing wrong.
I use this script:
Code: Select all
commandArray = {}
solar = otherdevices_svalues['Zonnepanelen']
now, total = solar:match("([^;]+);([^;]+)")
-- Retrieve the current value of the "Zonnepanelen" sensor
local current_value = tonumber(total)
-- Retrieve the highest value stored in the user variable "Zonnepanelen"
local highest_value = tonumber(uservariables['HighestZonnepanelenDaily'])
-- Check if the current value is higher than the stored highest value
if current_value > highest_value then
-- Update the user variable with the new highest value
commandArray['Variable:HighestZonnepanelenDaily'] = tostring(current_value)
end
return commandArray
What am I doing wrong with this last script?