Page 1 of 1

PV output

Posted: Monday 18 September 2023 20:17
by gvandick
I install a kWH meter SDM120 for my solarpanels. During nigt time there is a small consumption on the meter a negative value.

The script I use has no solution for negative value. That means that uploading to PV output during night time is not accepted due negative value.

I trie to change the script but I didn't find a solution .

The changes I added are marked red.

Can someone give a solution.





local scriptVar = 'PVOutput'

return {
on = {
timer = { 'every 5 minutes'},
httpResponses = { scriptVar },
},

logging = {
level = domoticz.LOG_INFO,
marker = "pvOutput"
},

execute = function(dz, item)

local function post2PVOutput(PVSettings, postData)
dz.openURL({
url = PVSettings.url,
method = 'POST',
headers = {
['X-Pvoutput-Apikey'] = PVSettings.api,
['X-Pvoutput-SystemId'] = PVSettings.id
},
callback = scriptVar,
postData = postData
})
end

local function makepostData()

local P1 = dz.devices('Electriciteit')
--local Youless = dz.devices('Youless')

----------------------------------------------------------------------------------------------------------
-- Domoticz IDX of the needed devices)
----------------------------------------------------------------------------------------------------------

local Solar = dz.devices(258) -- IDX of Solar Panels
local Consumption = dz.devices(763) -- IDX of Consumption device (from consumption.lua script)
--local Gas = dz.devices(2) -- IDX of Smart Gas Meter
local temperature = dz.devices(896) -- change to your outside temp device
local voltage = dz.devices (310) -- change to a device with a voltage value

dz.log('-- Energy generation (v1) = ' .. Solar.WhTotal .. ' Wh ', dz.LOG_INFO)

if localSolar < 0 then
dz.log('(NEGATIVE-- Power generation (v2) = ' .. Solar.actualWatt .. ' W ', dz.LOG_INFO)
dz.log('Power generation set to 0', dz.LOG_INFO)
localSolar = 0
else
dz.log('-- Power generation (v2) = ' .. Solar.actualWatt .. ' W ', dz.LOG_INFO)
end





-- dz.log('-- Power generation (v2) = ' .. Solar.actualWatt .. ' W ', dz.LOG_INFO)
dz.log('-- Energy consumption (v3) = ' .. Consumption.WhTotal .. ' Wh ', dz.LOG_INFO)
dz.log('-- Power consumption (v4) = ' .. Consumption.actualWatt .. ' W ', dz.LOG_INFO)

local round = dz.utils.round
local postdDataAsString =

--[[
v1 - energy generation
v2 - power generationn
v3 - energy consumption
v4 - power consumption
v5 - temperature
v6 - voltage
]] --

'd=' .. os.date("%Y%m%d") ..
'&t=' .. os.date("%H:%M") ..
'&v1=' .. Solar.WhTotal ..
'&v2=' .. Solar.actualWatt ..
-- '&v2=' .. 0 ..
'&v3=' .. Consumption.WhTotal ..
'&v4=' .. Consumption.actualWatt ..
'&v5=' .. round(temperature.temperature,1) ..
'&v6=' .. dz.utils.round(voltage.voltage,1) ..
'&c1=1'





return postdDataAsString



end



if item.isHTTPResponse then
dz.log("Return from PVOutput \n" .. item.data,dz.LOG_DEBUG)
else

----------------------------------------------------------------------------------------------------------
-- Settings for pvoutput.org
----------------------------------------------------------------------------------------------------------





post2PVOutput(PVSettings, makepostData())
end
end
}

Re: PV output

Posted: Monday 18 September 2023 22:15
by Toulon7559
Below are just some pragmatic work-arounds, if you might not find a 'clean' solution for a continuous check against negative value to PVO.

1. Set a time-bracket for output is 0
Between sunset and sunrise per definition the PV-output will be 0.
dzVents can dynamically provide the 2 applicable time-values for your location
Perhaps simpler solution than check on output-level is to use that basic info as alternative trigger to set output to PVO to 0, if time is between sunset and sunrise?

Obviously this solution is rude, because it only covers the astronomical period of darkness:
actual dark periods during astronomical daytime may still cause upload of negative output to PVO.
As extension you might delay the applied sunrise-time and advance the applied sunset-time to cover 'uncertain' parts in the edges of the day:
anyway not much energy-production in those edges of the day .....

2. Raise the uploaded output value to >0
How much is the negative value in nighttime?
If neglectable value, a quick&dirty solution to get rid of negative value is increase of the output-value by this (small) amount:
in that way the practical output to PVO always >0.

Re: PV output

Posted: Wednesday 20 September 2023 13:09
by gvandick
Thx

I will try

Re: PV output

Posted: Saturday 23 September 2023 7:56
by gvandick
I dupicate the script. One with timer 'daytime every 5 minutes' and second script with timer 'nigttime every 5 minutes'. I set output solar Watt '&v2=' .. 0 ..

This works, maybe I must it fine tuned f.e. x minutes before of afther.

Thanks for the lead