PV output

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

Moderator: leecollings

Post Reply
gvandick
Posts: 37
Joined: Saturday 01 July 2017 12:48
Target OS: Windows
Domoticz version:
Contact:

PV output

Post 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
}
Last edited by gvandick on Tuesday 19 September 2023 9:59, edited 1 time in total.
Toulon7559
Posts: 858
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: PV output

Post 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.
Last edited by Toulon7559 on Monday 02 October 2023 22:50, edited 1 time in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
gvandick
Posts: 37
Joined: Saturday 01 July 2017 12:48
Target OS: Windows
Domoticz version:
Contact:

Re: PV output

Post by gvandick »

Thx

I will try
gvandick
Posts: 37
Joined: Saturday 01 July 2017 12:48
Target OS: Windows
Domoticz version:
Contact:

Re: PV output

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest