Now I have found out that the outcome of the script over a whole day is about 6% too high. This is probably due to some delay between the measurement and the calculation. Many small deviations then add up to a substantial deviation. If I perform the same calculation for the 10-minute average data that Buienradar sends to domoticz, the daily total almost corresponds with the figures published by the KNMI the following day (deviation < 0.3%).
To (almost) eliminate the error in the daily total for my own pyranometer, I now also want to calculate this per 10 minutes with a dzVents script. So I want to calculate the arithmetic mean of 60 values and send it to a domoticz sensor which I then use as input for the calculation to J/cm².
I made the following script for that.
Code: Select all
return
{
on = {
devices = {'Sun Power SEM228T'}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'SEM228T',
},
data =
{
SEM228THistory = { history = true, maxMinutes = 10 },
},
execute = function(domoticz, sensor)
-- add new data
domoticz.data.SEM228THistory.add(sensor.Watts)
-- average
local average = domoticz.data.SEM228THistory.avg()
-- maximum value in the past 10 minutes:
local max = domoticz.data.temperatures.maxSince('00:10:00')
-- maximum value in the past 10 minutes:
local min = domoticz.data.temperatures.minSince('00:10:00')
end
}
Code: Select all
2022-03-30 15:25:22.639 Error: dzVents: Error: (3.1.7) SEM228T: Item data is not a number type. Type is nil
2022-03-30 15:25:22.639 Error: dzVents: Error: (3.1.7) SEM228T: An error occurred when calling event handler SEM228T10M
2022-03-30 15:25:22.639 Error: dzVents: Error: (3.1.7) SEM228T: /home/pi/domoticz/dzVents/runtime/HistoricalStorage.lua:289: attempt to perform arithmetic on a nil value (local 'sum')