Page 6 of 7
Re: Lua script for uploading energy values to PVoutput
Posted: Saturday 28 March 2020 15:37
by DiaDomo
I have the same problem, see also:
https://www.domoticz.com/forum/viewtopi ... 59#p241159
Member Cabbie seems to have a fix for this. Hopefully he will share this...
Re: Lua script for uploading energy values to PVoutput
Posted: Saturday 28 March 2020 18:03
by waaren
This is the dzVents version I use. API key and id stored in domoticz uservariables type string

- pv.png (14.54 KiB) Viewed 3481 times
Code: Select all
--[[
dzVents version of pvOutput script.
api-key and id stored in domoticz uservariables type string
]]
local scriptVar = 'PVOutput'
return {
on = {
timer = { 'every 5 minutes'},
httpResponses = { scriptVar },
},
logging = {
level = domoticz.LOG_DEBUG, -- change to error when OK
marker = "pvOutput"
},
execute = function(dz, item)
local function post2PVOutput(PVSettings, postData)
-- dz.utils.dumpTable(PVSettings, 'PVSettings > ')
-- dz.log('postData: ' .. postData,dz.LOG_FORCE)
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('mySmartMeter')
local temperature = dz.devices('myTemperature')
local voltage = dz.devices('myVolt')
local round = dz.utils.round
local postdDataAsString =
'd=' .. os.date("%Y%m%d") ..
'&t=' .. os.date("%H:%M") ..
'&v1=' .. P1.return1 + P1.return2 ..
'&v2=' .. P1.usageDelivered ..
'&v3=' .. P1.usage1 + P1.usage2 ..
'&v4=' .. P1.usage ..
'&v5=' .. round(temperature.temperature,1) ..
'&v6=' .. round(voltage.sValue,1) ..
'&c1=1'
--[[
v1 - energy generation
v2 - power generation W from
v3 - energy consumption
v4 - power consumption
v5 - temperature
v6 - voltage
'&c1= .. c1
'&n= .. n
Donation mode only parms
'&delay=' .. Delay
'&v7=' .. WaterConsumption
'&v8=' .. InverterFrequency
'&v11=' .. InverterTemp
'&v12=' .. GasConsumption
]] --
return postdDataAsString
end
if item.isHTTPResponse then
dz.log("Return from PVOutput ==>> " .. item.data,dz.LOG_FORCE)
else
PVSettings =
{
url = 'HTTPS://pvoutput.org/service/r2/addstatus.jsp',
api = dz.variables('PVoutput_API').value,
id = dz.variables('PVoutput_ID').value,
}
post2PVOutput(PVSettings, makepostData())
end
end
}
Re: Lua script for uploading energy values to PVoutput
Posted: Saturday 28 March 2020 20:24
by DiaDomo
Many thx!
Note: one typo in your script:
Code: Select all
local P1 = dz.devices('mySmartMeter)
should be:
Code: Select all
local P1 = dz.devices('mySmartMeter')
Re: Lua script for uploading energy values to PVoutput
Posted: Sunday 29 March 2020 12:20
by reinten
Many thanks Waaren!
After the update to Buster lua events uploading to PVoutput were not working any more due to socket.http problem.
Converted PVoutput upload to dzVents with your script and it works like a charm again.
Re: Lua script for uploading energy values to PVoutput
Posted: Tuesday 31 March 2020 19:51
by DiaDomo
One question regarding your script Waaren:
It's uploading but I'm missing at least 3 kWh per day. I looked at the new and old script:
in the original LUA script 4 devices are used:
Code: Select all
local GenerationDeviceName = "Levering" -- Device name of the Generated energy
local ConsumptionDeviceName = "Consumption" -- Name of the energy device that shows calculated Consumption
local VoltageDeviceName = "DC Inverter 1" -- Name of the voltage device that shows voltage of the inverter
local TemperatureDeviceName = "Buiten" -- Name of the temperature device that shows outside temperature
In Waaren's dzVents script 3 devices are used:
Code: Select all
local P1 = dz.devices('Power')
local temperature = dz.devices('Buiten')
local voltage = dz.devices('DC Inverter 1')
Apparently device 'Power' is a combination of both the 'Generation' and 'Consumption' device.
Unfortunately the upload to PVOut is in my case not correct anymore because the Power device gives lower amounts than the 'Levering' device (is my case the SolarEdge Inverter).

- Example values
- example-pvout.JPG (40.81 KiB) Viewed 3399 times
Can you help me further?
Re: Lua script for uploading energy values to PVoutput
Posted: Tuesday 31 March 2020 19:59
by waaren
DiaDomo wrote: ↑Tuesday 31 March 2020 19:51
in the original LUA script 4 devices are used:
In Waaren's dzVents script 3 devices are used:
Can you help me further?
Sure, send me your 'old' Lua script and your 'new' dzVents script via PM and I will try to help you.
Re: Lua script for uploading energy values to PVoutput
Posted: Tuesday 31 March 2020 22:19
by roblom
DiaDomo wrote:One question regarding your script Waaren:
It's uploading but I'm missing at least 3 kWh per day. I looked at the new and old script:
in the original LUA script 4 devices are used:
Code: Select all
local GenerationDeviceName = "Levering" -- Device name of the Generated energy
local ConsumptionDeviceName = "Consumption" -- Name of the energy device that shows calculated Consumption
local VoltageDeviceName = "DC Inverter 1" -- Name of the voltage device that shows voltage of the inverter
local TemperatureDeviceName = "Buiten" -- Name of the temperature device that shows outside temperature
In Waaren's dzVents script 3 devices are used:
Code: Select all
local P1 = dz.devices('Power')
local temperature = dz.devices('Buiten')
local voltage = dz.devices('DC Inverter 1')
Apparently device 'Power' is a combination of both the 'Generation' and 'Consumption' device.
Unfortunately the upload to PVOut is in my case not correct anymore because the Power device gives lower amounts than the 'Levering' device (is my case the SolarEdge Inverter).
example-pvout.JPG
Can you help me further?
Remember that you can have internal usage. When you generate 1000W and use 1500W at the same time, your smartmeter will show an import of 500W and 0W generation. So when you log the generation at your inverter and compare these values with your smartmeter the smartmeter shows less.
For me it's not clear if this explains your findings but I thought I share it anyway.
Re: Lua script for uploading energy values to PVoutput
Posted: Wednesday 01 April 2020 16:04
by EdwinP
waaren wrote: ↑Tuesday 31 March 2020 19:59
DiaDomo wrote: ↑Tuesday 31 March 2020 19:51
in the original LUA script 4 devices are used:
In Waaren's dzVents script 3 devices are used:
Can you help me further?
Sure, send me your 'old' Lua script and your 'new' dzVents script via PM and I will try to help you.
Hi Waaren,
I am also using an Lua calculation script which calculates actual power consumption based on P1 output vs SolarGeneration. Both calculation and upload scripts broke. Dus to Lua 5.2-5.3 errors.
I got the calculation script working again, but not the pvoutput upload script. I am trying to figure out how to put in the correct values for Generation en Consumption.
Any help is much appreciated.
Re: Lua script for uploading energy values to PVoutput
Posted: Wednesday 01 April 2020 16:10
by waaren
EdwinP wrote: ↑Wednesday 01 April 2020 16:04
I got the calculation script working again, but not the pvoutput upload script.
Any help is much appreciated.
Sent you a PM
Re: Lua script for uploading energy values to PVoutput
Posted: Friday 03 April 2020 11:07
by EdwinP
Thank you waaren for helping out.
I had my setup based on
https://www.domoticz.com/wiki/Upload_en ... o_PVoutput.
This setup picks up my real generated power from my inverter, picks up my export/import from my SmartMeter(P1) and calculates my actual consumption (example: import+generation=consumption)
The upgrade to 2020.1 broke my scripts. The calculation script was easily fixed by remarking one line:
Code: Select all
-- local http = require("socket.http")
The upload to pvoutput script stopped working. I used the above example from waaren. Except it did not account for the calculation setup I use. Waaren helped me out with that. These are the differences I have now in my working setup:
Code: Select all
local P1 = dz.devices('P1 Power') -- P1 output device
local generated = dz.devices('SolarMain') -- Output from SBSpot (SMA inverter)
local consumed = dz.devices('Consumption') -- Consumption virtual device
local temperature = dz.devices('TempHumBaro') -- Weather output from wheater device
local voltageDevice = dz.devices('uac1') -- Output from SBSpot (SMA inverter)
and for retrieved values:
Code: Select all
dz.log('P1 : ' .. P1.sValue,dz.LOG_DEBUG)
dz.log('generated : ' .. generated.nValue .. ';' .. generated.sValue,dz.LOG_DEBUG)
dz.log('consumed : ' .. consumed.nValue .. ';' .. consumed.sValue,dz.LOG_DEBUG)
dz.log('Temperature: ' .. temperature.temperature,dz.LOG_DEBUG)
dz.log('voltage : ' .. voltage,dz.LOG_DEBUG)
Mapping to the pvoutput values:
Code: Select all
'd=' .. os.date("%Y%m%d") ..
'&t=' .. os.date("%H:%M") ..
'&v3=' .. round(consumed.WhTotal,1) .. -- consumed
'&v4=' .. round(consumed.actualWatt,1) ..
'&v5=' .. round(temperature.temperature,1) ..
'&v6=' .. voltage ..
'&c1=1'
This made my setup work again. Many thanks to waaren for helping me out.
I have attached the complete script.
Re: Lua script for uploading energy values to PVoutput
Posted: Friday 03 April 2020 11:48
by tsybeck
I actually worked on the same.
Here are replacement dzVents-scripts for the old Lua scripts that are being used on the wiki.
These scripts work with the Consumption device that was also in the old Lua scripts.
So that means that when you have Solar Panels, the Consumption scripts calculates what the actual usage of electricity is by comparing the generated values from the solar panels with the used/returned electricity in the Smart Meter.
Re: Lua script for uploading energy values to PVoutput
Posted: Friday 03 April 2020 12:36
by DiaDomo
EdwinP wrote: ↑Friday 03 April 2020 11:07
Thank you waaren for helping out.
I had my setup based on
https://www.domoticz.com/wiki/Upload_en ... o_PVoutput.
This setup picks up my real generated power from my inverter, picks up my export/import from my SmartMeter(P1) and calculates my actual consumption (example: import+generation=consumption)
The upgrade to 2020.1 broke my scripts. The calculation script was easily fixed by remarking one line:
Code: Select all
-- local http = require("socket.http")
The upload to pvoutput script stopped working. I used the above example from waaren. Except it did not account for the calculation setup I use. Waaren helped me out with that. These are the differences I have now in my working setup:
Code: Select all
local P1 = dz.devices('P1 Power') -- P1 output device
local generated = dz.devices('SolarMain') -- Output from SBSpot (SMA inverter)
local consumed = dz.devices('Consumption') -- Consumption virtual device
local temperature = dz.devices('TempHumBaro') -- Weather output from wheater device
local voltageDevice = dz.devices('uac1') -- Output from SBSpot (SMA inverter)
and for retrieved values:
Code: Select all
dz.log('P1 : ' .. P1.sValue,dz.LOG_DEBUG)
dz.log('generated : ' .. generated.nValue .. ';' .. generated.sValue,dz.LOG_DEBUG)
dz.log('consumed : ' .. consumed.nValue .. ';' .. consumed.sValue,dz.LOG_DEBUG)
dz.log('Temperature: ' .. temperature.temperature,dz.LOG_DEBUG)
dz.log('voltage : ' .. voltage,dz.LOG_DEBUG)
Mapping to the pvoutput values:
Code: Select all
'd=' .. os.date("%Y%m%d") ..
'&t=' .. os.date("%H:%M") ..
'&v3=' .. round(consumed.WhTotal,1) .. -- consumed
'&v4=' .. round(consumed.actualWatt,1) ..
'&v5=' .. round(temperature.temperature,1) ..
'&v6=' .. voltage ..
'&c1=1'
This made my setup work again. Many thanks to waaren for helping me out.
I have attached the complete script.
Thx EdwinP,
I'm struggling already several days. I'm using your script but I get the following error:
Code: Select all
2020-04-03 12:30:00.135 Status: dzVents: Info: PVOutput: ------ Start external script: pvOutput- FORUM 2.lua:, trigger: "every 5 minutes"
2020-04-03 12:30:00.151 Status: dzVents: Debug: PVOutput: Processing device-adapter for Power: P1 smart meter energy device adapter
2020-04-03 12:30:00.153 Status: dzVents: Debug: PVOutput: Processing device-adapter for Levering: kWh device adapter
2020-04-03 12:30:00.154 Status: dzVents: Debug: PVOutput: Processing device-adapter for Consumption: kWh device adapter
2020-04-03 12:30:00.155 Status: dzVents: Debug: PVOutput: Processing device-adapter for Buiten: Temperature+humidity+barometer device adapter
2020-04-03 12:30:00.155 Status: dzVents: Debug: PVOutput: Processing device-adapter for DC Inverter 1: Voltage device adapter
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: P1 : 1012595;1032974;915249;2042007;0;446
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: generated : 0;375.752;8439180.000
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: consumed : 0;-70.248;7501494.0
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: Temperature: 8.6999998092651
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: voltage : 375.6
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: url = HTTPS://pvoutput.org/service/r2/addstatus.jsp
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: method = POST
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: post data = d=20200403&t=12:30&v1=8439180.0&v2=375.8&v3=7501494.0&v4=-70.2&v5=8.7&v6=375.6&c1=1
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: headers = {["X-Pvoutput-Apikey"]="<......>", ["X-Pvoutput-SystemId"]="54427"}
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: callback = PVOutput
2020-04-03 12:30:00.156 Status: dzVents: Info: PVOutput: ------ Finished pvOutput- FORUM 2.lua
2020-04-03 12:30:01.081 Status: dzVents: Info: Handling httpResponse-events for: "PVOutput"
2020-04-03 12:30:01.081 Status: dzVents: Info: PVOutput: ------ Start external script: pvOutput- FORUM 2.lua: HTTPResponse: "PVOutput"
2020-04-03 12:30:01.081 Status: dzVents: !Info: PVOutput: Return from PVOutput ==>> Bad request 400: Invalid power value [-70]
2020-04-03 12:30:01.081 Status: dzVents: Info: PVOutput: ------ Finished pvOutput- FORUM 2.lua
Can you help me further? Maybe the power value cannot be negative?
This is the script:
Code: Select all
--[[
dzVents version of pvOutput script.
api-key and id stored in domoticz uservariables:
PVoutput_API
PVoutput_ID
both as type string
v1 - energy generated
v2 - power generated W from
v3 - energy consumption
v4 - power consumption
v5 - temperature
v6 - voltage
c1 - Cumulative Flag 1 Both v1 and v3 values are lifetime energy values.
Consumption and generated energy is reset to 0 at the start of the day.
2 Only v1 generated is a lifetime energy value.
3 Only v3 consumption is a lifetime energy value.
n - Net flag When set to 1 will indicate that the power values are net export/import.
rather than gross generated/consumption. This option is used for devices that are
unable to report gross consumption data. The provided import/export data is merged
with existing generated data to derive consumption.
Donation mode only parms
========================
'&delay=' .. Delay
'&v7=' .. WaterConsumption
'&v8=' .. InverterFrequency
'&v11=' .. InverterTemp
'&v12=' .. GasConsumption
]]
local scriptVar = 'PVOutput'
return
{
on =
{
timer =
{
'every 5 minutes',
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to LOG_ERROR when OK - was LOG_DEBUG
marker = scriptVar,
},
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('Power') -- P1 output device
local generated = dz.devices('Levering') -- Output from SBSpot (SMA inverter)
local consumed = dz.devices('Consumption') -- Consumption virtual device
local temperature = dz.devices('Buiten') -- Weather output from wheater device
local voltageDevice = dz.devices('DC Inverter 1') -- Output from SBSpot (SMA inverter)
local round = dz.utils.round
local voltageString = voltageDevice.sValue
local voltage = round(tonumber(voltageString:match('%d*%.*%d*')),1) -- To prevent error if 'V' is part of the string
dz.log('P1 : ' .. P1.sValue,dz.LOG_DEBUG)
dz.log('generated : ' .. generated.nValue .. ';' .. generated.sValue,dz.LOG_DEBUG)
dz.log('consumed : ' .. consumed.nValue .. ';' .. consumed.sValue,dz.LOG_DEBUG)
dz.log('Temperature: ' .. temperature.temperature,dz.LOG_DEBUG)
dz.log('voltage : ' .. voltage,dz.LOG_DEBUG)
local postdDataAsString =
'd=' .. os.date("%Y%m%d") ..
'&t=' .. os.date("%H:%M") ..
-- Use these if you want net production from Solarpanels
'&v1=' .. round(generated.WhTotal,1) .. -- produced
'&v2=' .. round(generated.actualWatt,1) ..
-- Use these if you want what is sent to the grid
-- '&v1=' .. P1.return1 + P1.return2 .. -- returned to the grid
-- '&v2=' .. P1.usageDelivered ..
-- Use these if you want what is obtained from the grid
-- '&v3=' .. P1.usage1 + P1.usage2 .. -- net values from your smart meter
-- '&v4=' .. P1.usage ..
-- Use these if you want what is calculated
'&v3=' .. round(consumed.WhTotal,1) .. -- consumed
'&v4=' .. round(consumed.actualWatt,1) ..
'&v5=' .. round(temperature.temperature,1) ..
'&v6=' .. voltage ..
'&c1=1'
return postdDataAsString
end
if item.isHTTPResponse then
dz.log("Return from PVOutput ==>> " .. item.data,dz.LOG_FORCE)
else
PVSettings =
{
url = 'HTTPS://pvoutput.org/service/r2/addstatus.jsp',
api = dz.variables('PVoutput_API').value,
id = dz.variables('PVoutput_ID').value,
}
post2PVOutput(PVSettings, makepostData())
end
end
}
Re: Lua script for uploading energy values to PVoutput
Posted: Friday 03 April 2020 14:54
by EdwinP
DiaDomo wrote: ↑Friday 03 April 2020 12:36
Thx EdwinP,
I'm struggling already several days. I'm using your script but I get the following error:
Code: Select all
2020-04-03 12:30:00.135 Status: dzVents: Info: PVOutput: ------ Start external script: pvOutput- FORUM 2.lua:, trigger: "every 5 minutes"
2020-04-03 12:30:00.151 Status: dzVents: Debug: PVOutput: Processing device-adapter for Power: P1 smart meter energy device adapter
2020-04-03 12:30:00.153 Status: dzVents: Debug: PVOutput: Processing device-adapter for Levering: kWh device adapter
2020-04-03 12:30:00.154 Status: dzVents: Debug: PVOutput: Processing device-adapter for Consumption: kWh device adapter
2020-04-03 12:30:00.155 Status: dzVents: Debug: PVOutput: Processing device-adapter for Buiten: Temperature+humidity+barometer device adapter
2020-04-03 12:30:00.155 Status: dzVents: Debug: PVOutput: Processing device-adapter for DC Inverter 1: Voltage device adapter
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: P1 : 1012595;1032974;915249;2042007;0;446
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: generated : 0;375.752;8439180.000
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: consumed : 0;-70.248;7501494.0
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: Temperature: 8.6999998092651
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: voltage : 375.6
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: url = HTTPS://pvoutput.org/service/r2/addstatus.jsp
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: method = POST
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: post data = d=20200403&t=12:30&v1=8439180.0&v2=375.8&v3=7501494.0&v4=-70.2&v5=8.7&v6=375.6&c1=1
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: headers = {["X-Pvoutput-Apikey"]="<......>", ["X-Pvoutput-SystemId"]="54427"}
2020-04-03 12:30:00.156 Status: dzVents: Debug: PVOutput: OpenURL: callback = PVOutput
2020-04-03 12:30:00.156 Status: dzVents: Info: PVOutput: ------ Finished pvOutput- FORUM 2.lua
2020-04-03 12:30:01.081 Status: dzVents: Info: Handling httpResponse-events for: "PVOutput"
2020-04-03 12:30:01.081 Status: dzVents: Info: PVOutput: ------ Start external script: pvOutput- FORUM 2.lua: HTTPResponse: "PVOutput"
2020-04-03 12:30:01.081 Status: dzVents: !Info: PVOutput: Return from PVOutput ==>> Bad request 400: Invalid power value [-70]
2020-04-03 12:30:01.081 Status: dzVents: Info: PVOutput: ------ Finished pvOutput- FORUM 2.lua
Can you help me further? Maybe the power value cannot be negative?
Only thing that seems strange is a negative consumption. Imho that can't be lower then 0. You are sending the 3rd value of consumed to PVoutput, and it seems it's 70 lower then the last time, which is why pvoutput does not accept the value.
My guess something is going wrong with your calculation script.
I'm still using the old Lua version. And as I have always something turned on in my house, I never get below 0 consumption.
Gr, Edwin
Re: Lua script for uploading energy values to PVoutput
Posted: Sunday 05 April 2020 13:38
by Upper78
tsybeck wrote: ↑Friday 03 April 2020 11:48
I actually worked on the same.
Here are replacement dzVents-scripts for the old Lua scripts that are being used on the wiki.
These scripts work with the Consumption device that was also in the old Lua scripts.
So that means that when you have Solar Panels, the Consumption scripts calculates what the actual usage of electricity is by comparing the generated values from the solar panels with the used/returned electricity in the Smart Meter.
Thanks,
These scripts did the trick easy. Just replaced the IDX, and it worked like a charm.

Re: Lua script for uploading energy values to PVoutput
Posted: Tuesday 30 June 2020 23:51
by roblom
tsybeck wrote: ↑Friday 03 April 2020 11:48
I actually worked on the same.
Here are replacement dzVents-scripts for the old Lua scripts that are being used on the wiki.
These scripts work with the Consumption device that was also in the old Lua scripts.
So that means that when you have Solar Panels, the Consumption scripts calculates what the actual usage of electricity is by comparing the generated values from the solar panels with the used/returned electricity in the Smart Meter.
My system recently crashed so I thought lets try the new Dzvents script. It worked like a charm! The only thing is is that I think that the http response doesn't work. As far as I can see it's always 'PVOutput' instead of the actual response. How do I change that?
Re: Lua script for uploading energy values to PVoutput
Posted: Monday 06 July 2020 16:54
by roblom
I found out that it will post the response but only when in DEBUG mode. I added a check and if the response is not OK then it will put the HTTP response in the log.
So the log says sometimes:
Bad request 400: Invalid power value [-178]
I think it is because of a timing problem but am not sure. Anybody else have this problem?
Re: Lua script for uploading energy values to PVoutput
Posted: Monday 06 July 2020 17:14
by waaren
roblom wrote: ↑Monday 06 July 2020 16:54
I found out that it will post the response but only when in DEBUG mode.
What script do you use ? The one that was shared here does use LOG_FORCE so it should always show the response in the log.
So the log says sometimes:
Bad request 400: Invalid power value [-178]
I think it is because of a timing problem but am not sure. Anybody else have this problem?
pvoutput doe not like negative values in parm v1 or parm v2
Re: Lua script for uploading energy values to PVoutput
Posted: Monday 06 July 2020 22:56
by roblom
waaren wrote: ↑Monday 06 July 2020 17:14
roblom wrote: ↑Monday 06 July 2020 16:54
I found out that it will post the response but only when in DEBUG mode.
What script do you use ? The one that was shared here does use LOG_FORCE so it should always show the response in the log.
So the log says sometimes:
Bad request 400: Invalid power value [-178]
I think it is because of a timing problem but am not sure. Anybody else have this problem?
pvoutput doe not like negative values in parm v1 or parm v2
I've used the version of tsybeck as a base, but I already customized it. I know that PVoutput doesn't like negative values but the question is how come they are negative. I've added some bug tracking (see below) but at the moment the sun is down so no data anymore
Code: Select all
if item.isHTTPResponse then
if item.statusText=='OK' then
dz.log("Data successfully added to PVoutput")
else
dz.log("Error: the return from PVOutput was /n" .. item.data,dz.LOG_ERROR)
dz.log('-- Energy generation (v1) = ' .. Solar.WhTotal .. ' Wh ', dz.LOG_ERROR)
dz.log('-- Power generation (v2) = ' .. Solar.actualWatt .. ' W ', dz.LOG_ERROR)
dz.log('-- Energy consumption (v3) = ' .. Consumption.WhTotal .. ' Wh ', dz.LOG_ERROR)
dz.log('-- Power consumption (v4) = ' .. Consumption.actualWatt .. ' W ', dz.LOG_ERROR)
end
else
....
Re: Lua script for uploading energy values to PVoutput
Posted: Monday 06 July 2020 23:24
by waaren
roblom wrote: ↑Monday 06 July 2020 22:56
I've used the version of tsybeck as a base, but I already customized it. I know that PVoutput doesn't like negative values but the question is how come they are negative.
Please share the complete script you are using now. It will make it easier to find why the script sometimes sends negative values.
Re: Lua script for uploading energy values to PVoutput
Posted: Tuesday 07 July 2020 11:42
by roblom
Thanks for the help! But I found out that I have negative consumption values so I have to sort that out first.