For the upload of values to PVOutput no 'internal' function is available.
After some experimenting and a 24hr-test, please find below a lua-script performing such upload-function.
Some characteristics:
- The shown code is for a 'general' script, with an activation of upload of values from only S0PCM Counter1
- Values for Voltage and Current usually are not available in configurations applying S0-interfaces, therefore processing & upload not present in this script
- A complete picture at PVO-side should have temperature, and therefore also a function for such upload has been included
- At the start of each segment some explaining comments have been included
- For reference during debugging, at the start of several segments the applicable line-number has been inserted [pay attention when changing the script!].
- As indicated in the listing, you have to adapt/tune the settings for your application/configuration, to make it run at your Domoticz.
- For control of rate of upload, the script has a waiting-loop with a interval you can set [in the example-script set to 5 minutes]
- The data to be uploaded is extracted/compiled from the time-values and from the svalues produced by Domoticz.

- Be aware that PVOutput also has an internal interval-setting (with default 10 minutes), which sometimes causes surprising 'combination-effects' at PVO-side
- If feeding PVOutput with 2 or more async uploadstreams you can expect some effects due to conflict/interference [= missing info, empty fields, unexpected override, etc.]
- The waiting loop and the subsequent if-then's have an 'internal' effect that Domoticz checks every minute, but if the check is not matching the interval-time set in the lua-script, then in the log you will see a 'nil value' error and no upload.
- Addition of 2015-05-19: the script in line 30 calls for UTC-time, but (as detected later) PVOutput needs 'Local time'.
See therefore in this thread my message of 2015-05-17 for a related correction of the script.
If you see room/solutions for improvement, please contribute!
If questions, please ask.
Good luck with application!
Interested to hear your experiences.
Code: Select all
-- PVOutput S0PCM upload script
-- (C)2013 GizMoCuz for WU-Upload-script, adapted by Toulon7559 for periodic upload of S0PCM-info to PVOutput
-- The idea is to apply a dedicated lua-script for each S0PCM-Counter, separate for the application for consumption or for generation.
-- In that way for each type of data you can directly upload the data to the related PVO-account, not bothered by synchronisation.
-- This example script has an active upload for readout of consumption by Counter1 = S0PCM1
-- Combination of counter-outputs for one upload-stream to be tested in a next release of this basic script.
-- Line9= Values
-- For 'names' take the Domoticz device-names and remove -- before the line below as required for activation of the selected counter
Counter1='S0PCM1'
-- Counter2='S0PCM2'
-- Counter3='S0PCM3'
-- Counter4='S0PCM4'
-- Counter5='S0PCM5'
OutsideTemp='TFA_Temp_RV'
-- Line18= PVOutput Settings: adapt as required for your configuration & application
-- baseurl is the header for the upload-message
baseurl="http://pvoutput.org/service/r2/addstatus.jsp?"
SID="PVO_System_ID"
-- PVO System ID of your PV-System
API="PVO_API_key"
-- PVO_API_key must be the full API-string, NOT a ReadOnlyKey
Cumflag=1
-- Must be 1 for upload of lifetime cumulative energy value; set to 0 for today's cumulative energy value
Interval=5
-- Upload interval in minutes
-- Line30= Get date & time
utc_dtime = os.date("!%m-%d-%y %H:%M:%S",os.time())
month = string.sub(utc_dtime, 1, 2)
day = string.sub(utc_dtime, 4, 5)
year = "20" .. string.sub(utc_dtime, 7, 8)
hour = string.sub(utc_dtime, 10, 11)
minutes = string.sub(utc_dtime, 13, 14)
seconds = string.sub(utc_dtime, 16, 17)
-- Line39= Compile auxiliary strings for the upload-message
timestring = hour .. "%3A" .. minutes
datestring = year .. "" .. month .. "" .. day
-- Line43= Current date from os as date.year, date.month, date.day, date.hour, date.min, date.sec
-- Check time in minutes against Interval to start the script
-- This first assembly for PVO_URL is the extended header for the upload-message
date = os.date("*t")
if (date.min % Interval == 0) then
PVO_URL= baseurl .. "sid=" .. SID .. "&key=" .. API .. "&d=" .. datestring .. "&t=" .. timestring
end
-- Line51= Data Extraction from svalues for Counter1 and for OutsideTemp
sActlPwr, sLifeEnergy = otherdevices_svalues[Counter1]:match("([^;]+);([^;]+)")
sActlPwr = tonumber(sActlPwr);
sLifeEnergy = tonumber(sLifeEnergy);
-- print (sActlPwr)
-- print (sLifeEnergy)
sTemp = otherdevices_svalues[OutsideTemp]:match("([^;]+)")
sTemp = tonumber(sTemp);
-- print(sTemp)
-- Line61= Select & activate from the following 2 examples as required to upload of an active input
-- This is the assembly of the complete message body for solo-upload of consumption values v3 and v4 based on consumption data from Counter1
-- if Counter1 ~= '' then
-- PVO_URL= PVO_URL .. "&v3=" .. sLifeEnergy .. "&v4=" .. sActlPwr .. "&c1=" .. Cumflag
-- end
-- This is the assembly of the complete message body for solo-upload of generation values v1 and v2 based on generation data from Counter2
-- if Counter2 ~= '' then
-- PVO_URL= PVO_URL .. "&v1=" .. sLifeEnergy .. "&v2=" .. sActlPwr .. "&c1=" .. Cumflag
-- end
-- Line71= Assembly of active message body, including insertion of v5 for temperature
if Counter1 ~= '' then
PVO_URL= PVO_URL .. "&v3=" .. sLifeEnergy .. "&v4=" .. sActlPwr .. "&v5=" .. sTemp .. "&c1=" .. Cumflag
end
print (PVO_URL)
commandArray = {}
-- Remove -- before the line below to actually upload
-- commandArray['OpenURL']=PVO_URL
return commandArray