Page 1 of 1

PVOutput, downloaded info > user variables

Posted: Wednesday 02 December 2015 11:46
by Toulon7559
If you have a PV-system with logger directly uploading data to PVOutput, it makes less sense to make an extra, direct interface between the PV-system and Domoticz: getting the PV-data quick&easy is by download of the information from PVOutput through the standard, automated download function of Domoticz.
The downloaded information from PVOutput for power&energy becomes visible at 'Overige' as 'meters & graphs' for Generation and for Consumption, and in Blocky as sensors.
In the background of Domoticz you can also find the related data under Setup/Events as svalues.
To apply this information in scripts, you have to extract the svalues and to convert them to numbers.
Some effort required in each script and is not complete, because day-energy is missing in the svalues.
To reduce the extraction&conversion to a once-only effort, in the attached script the svalues are periodically translated to global user variables for Actual Power, Lifetime Energy and Day-Energy. These user variables are then generally available for all scripts, by just making a call in the script for the global variables: see the explanation in the introduction of the script.
If you want from a PVOutput-SID both the data for Generation and for Consumption, you have to duplicate the script and you have to tune accordingly.

Note1: If PVOutput reports no actual power data (e.g. for PV-info during the night), the power read-back in the script fails and the script stops.
;-) Unintended (but effective), automatic stop at night for PVOutput-information ....
Note2: For tuning in this script you have to replace all XX by appropriate label.
Prone to error: perhaps somebody with a solution for 'general/simpler' setting of this aspect?

Code: Select all

-- PVOutput-UserVariables script, version_0.1
-- (C)2015 Toulon7559 for making user variables from PVoutput-svalues

-- Domoticz from the PVOutput-downloads makes displayvalues for power, for lifetime energy and for dayvalue energy.
-- Although de dashboard shows the dayvalue for energy, in the svalues this value is missing: only svalues for actual power and for lifetime energy.
-- This script derives the dayvalue for energy from PVOutput's lifetime energy and stores it as a user variable.
-- It requires that you first make 2 uservariables, for the actual dayvalue PVO_DayEnergyXX respectively for a reference value PVO_RefEnergyXX, with XX as identifier for the selected PVOutput-download
-- In addtion by definition of uservariables PVO_PowerXX and PVO_LifeEnergyXX you get the PVOutput download completely as uservariables. Line 11 is the start for tuning your application of this script, by setting XX and the 'name' of the svalues.
-- These uservariables then are generally available for all Domoticz-oriented scripts: just include in your other script(s) the lines 27~30 or 29+30 from this script.

-- Line10= Set references
PVO_DownloadXX = '<svalue-name>'
Interval = 1

-- Line14= Get Current date & time from os as date.year, date.month, date.day, date.hour, date.min, date.sec
date = os.date("*t")
year = date.year
month = date.month
day = date.day
hour = date.hour
minutes = date.min
seconds = date.sec

-- Line23= Check Current time in minutes against Interval to start the script
if (minutes % Interval == 0) then
PVO_PowerXX = tonumber(uservariables['PVO_PowerXX'])
PVO_LifeEnergyXX = tonumber(uservariables['PVO_LifeEnergyXX'])
PVO_DayEnergyXX = tonumber(uservariables['PVO_DayEnergyXX'])
PVO_RefEnergyXX = tonumber(uservariables['PVO_RefEnergyXX'])
sPVOPowerXX, sPVOEnergyXX = otherdevices_svalues[PVO_DownloadXX]:match("([^;]+);([^;]+)")
sPVOPowerXX = tonumber(sPVOPowerXX);
sPVOEnergyXX = tonumber(sPVOEnergyXX);
end
if ((hour+minutes) == 0) or (PVO_RefEnergyXX == 0) then
   PVO_LifeEnergyXX = sPVOEnergyXX
   PVO_RefEnergyXX = sPVOEnergyXX
   PVO_DayEnergyXX = 0
   PVO_PowerXX = 0
end
if sPVOPowerXX ~= 0 then PVO_PowerXX = sPVOPowerXX else PVO_PowerXX = 0
end
PVO_LifeEnergyXX = sPVOEnergyXX
PVO_DayEnergyXX = PVO_LifeEnergyXX - PVO_RefEnergyXX
print ('PVO_PowerXX           = '.. PVO_PowerXX)
print ('PVO_Energy_LifetimeXX = '.. PVO_LifeEnergyXX)
print ('PVO_Energy_DayStartXX = '.. PVO_RefEnergyXX)
print ('PVO_Energy_DayCumXX   = '.. PVO_DayEnergyXX)

commandArray = {}

-- Line50= Save the global values
commandArray['Variable:PVO_PowerXX'] = tostring(PVO_PowerXX)
commandArray['Variable:PVO_LifeEnergyXX'] = tostring(PVO_LifeEnergyXX)
commandArray['Variable:PVO_RefEnergyXX'] = tostring(PVO_RefEnergyXX)
commandArray['Variable:PVO_DayEnergyXX'] = tostring(PVO_DayEnergyXX)

return commandArray

Re: PVOutput, downloaded info > user variables

Posted: Wednesday 02 December 2015 18:29
by Toulon7559
Addition
Why this script?

My PV-sytem has 3 different invertersets, and therefore also 3 different PV-loggers.
The gridoutput of the Involar inverters is read by means of a kWh-meter with S0-interface: no inside information available from the inverters.
Domoticz is making the upload for PVOutput by means of S0PCM-read-out and a lua script.
The other 2 PV-loggers provide nice inside information, but 'require some assistance' related to the grid-output:
- the inverters type STECAGrid500s do not measure the grid-output, and instead the related PV-logger makes an estimation based on the measured PV-input, after which it makes an upload to PVOutput. Estimation with a conversion factor always has an error .........
- the SAJ-inverter has no direct interface for PVOutput, but provides the grid-output with a resolution of 0.1kWh, which is not really accurate, and which has side-effects in PVOutput (= 'strange' average power values). The related PV-logger has no ability to improve that resolution.
To measure in more detail the true grid-output, both invertersets have a kWh-meter at the grid-output. However, the S0-interfaces of these meters cannot be connected to the Loggers for correlation.
The clumsy method of correlation & correction is that periodically I write down the status of the 3 kWh-meters and compare with the info at PVOutput after which I manually correct the PVOutput-info, as required.

Online correlation & correction is obviously the better method, especially for unattended operation (or for ;-) lazy users).
An S0PCM interfacing Domoticz@Raspberry and with lua-scripts like http://www.domoticz.com/forum/viewtopic ... 006#p43815 provides the 'true' information for grid-output based on the S0-interfaces of the 3 kWh-meters: this power and energy information is alternative for information from the loggers.
Domoticz can read back the data uploaded by the loggers to PVOutput.
The difference between (loggerinfo uploaded the loggers to PVOutput, and downloaded to Domoticz) and (info calculated by Domoticz based on measured S0-data) is the required correction of the info at PVOutput.
The script in the previous message generally provides the data from PVOutput in an easy way as user variables, because with just a few extra lines the script at http://www.domoticz.com/forum/viewtopic ... 006#p43815 can now calculate the differences and automatically correct the logger-values at PVOutput.
If you continuously correct the information at PVOutput, that probably confuses the processing at PVOutput, and obviously that is not a good solution.
In my case I have choosen to make an end-of-day correction at 23:55 hours by upload of the 'true' v1-value: my PV-loggers do not upload between that time and midnight.
The live values at PVOutput during the day may not be the most correct (due to the mentioned errors of the loggers), but in that way the end-of-day energy v1-values at PVOutput are the best available.

Re: PVOutput, downloaded info > user variables

Posted: Tuesday 27 June 2017 10:49
by elitechukzj
very good