pixel
Pvoutput systeem koppelen aan Domoticz 2

Pvoutput systeem koppelen aan Domoticz

0
(0)

Je wilt graag je zonnepanelen in de gaten houden vanuit een andere locatie dan thuis.natuurlijk kan je je domoticz met verschillende tools ook vanaf buiten huis gebruiken.

Maar je wilt nu gewoon simpel dat kan natuurlijk ook met een mooie grafiek erbij.
En ook weer een extra back-up natuurlijk zo.
Dit kan met de website van pvoutput.org zoals onze opbrengst.
Ik log dit met een s0 meter met daaraan een Arduino mini met code.
En deze zit in verbinding met de raspberry pi waar domoticz op draait.
Dit systeem is hier ook al eens eerder gepubliceerd.

Vanaf domoticz versie 2020.1 werkt onderstaande code niet meer, het beste kan je dan deze handleiding volgen.

Pvoutput systeem koppelen aan Domoticz 3

Installeren van socket library dit is nodig om je bestanden vanaf je domoticz omgeving te versturen naar de website van o.a pvoutput.
Doe je dit niet gaat het systeem ook nooit werken er wordt dan niets verstuurd naar pvoutput.

  • Download en installeer het via de volgende ssh commando’s. Met putty of een andere ssh programma.
  1. “cd /usr/local/share”
  2. “sudo mkdir lua”
  3. “cd lua”
  4. “sudo mkdir 5.2”
  5. “cd 5.2”
  6. Download the file “sudo wget http://www.domoticz.com/forum/download/file.php?id=1454
  7. Rename file “sudo mv file.php?id=1454 usrlocalsharelua5p2.tar.gz”
  8. Extract the file with “sudo tar -xzvf usrlocalsharelua5p2.tar.gz”
  9. “cd /usr/local/lib”
  10. “sudo mkdir lua”
  11. “cd lua”
  12. “sudo mkdir 5.2”
  13. “cd 5.2”
  14. Download the file “sudo wget http://www.domoticz.com/forum/download/file.php?id=1453
  15. Rename file “sudo mv file.php?id=1453 usrlocalliblua5p2.tar.gz”
  16. Extract all the files with “sudo tar -xvf usrlocalliblua5p2.tar.gz”.


Advertentie :


For doing http requests we need a socket. As there is no packaged versions available, simonrg has made two gzipped tar files for the Raspberry Pi. For more infomation see this forum post.

Het volgende script heb je nodig.
Je hoeft alleen maar de ******** gedeelte in te vullen.
En je geeft hem de naam : script_time_upload_to_PVoutput.lua

Heb hem nu ook online gezet zodat je hem zo kan downloaden.

-- /home/pi/domoticz/scripts/lua/script_time_upload_to_PVoutput.lua
-- This script collects the values below from Domoticz
-- * The Power generation, energy generation and voltage from a Solar power inverter
-- * The temperature from a outside temperature sensor
-- * The Power consumption and energy consumption which is calculated in another Lua script 
-- And uploads all of the values to a PVoutput account.
-- For more information about PVoutput, see their user documentation on http://www.pvoutput.org/help.html
--https://www.domoticz.com/wiki/Upload_energy_data_to_PVoutput
-- Domoticz IDX of devices
local GenerationDeviceName = "********" -- Device name of the Generated energy
local TemperatureDeviceName = "********" -- Name of the temperature device that shows outside temperature

-- PVoutput parameters
local PVoutputApi = "********" -- Your PVoutput api key
local PVoutputSystemID = "********" -- Your PVoutput System ID
local PVoutputPostInterval = 5 -- The number of minutes between posts to PVoutput (normal is 5 but when in donation mode it's max 1)
local PVoutputURL = '://pvoutput.org/service/r2/addstatus.jsp?key=' -- The URL to the PVoutput Service

-- Require parameters
local http = require("socket.http")

-- Script parameters
EnergyGeneration = 0 -- v1 in Watt hours
PowerGeneration = 0 -- v2 in Watts
CurrentTemp = 0 -- v5 in celcius
c1 = 0 -- c1 = 0 when v1 is today's energy. c1 = 1 when v1 is lifetime energy.
Debug = "NO" -- Turn debugging on ("YES") or off ("NO")

-- Lua Functions
function UploadToPVoutput(self)
b, c, h = http.request("http" .. PVoutputURL .. PVoutputApi .. "&sid=".. PVoutputSystemID .. "&d=" .. os.date("%Y%m%d") .. "&t=" .. os.date("%H:%M") .. 
"&v1=" .. EnergyGeneration .. "&v2=" .. PowerGeneration .. "&v5=" .. CurrentTemp ..  "&c1=" .. c1 ) if b=="OK 200: Added Status" then     print(" -- Current status successfully uploaded to PVoutput.") else     print(" -- " ..b) end print(" -- Energy generation (v1) = ".. EnergyGeneration .. " Wh") print(" -- Power generation (v2) = " .. PowerGeneration .. " W") print(" -- Current temperature (v5) = " .. CurrentTemp .. " C") print(" -- Cumulative Flag (c1) = " .. c1 .. "")
end
function update(device, id, power, energy, index)
commandArray[index] = {['UpdateDevice'] = id .. "|0|" .. power .. ";" .. energy}
end 

-- CommandArray
commandArray = {}
time = os.date("*t") if PVoutputPostInterval>1 then     TimeToGo = PVoutputPostInterval - (time.min % PVoutputPostInterval)     print('Time to go before upload to PVoutput: ' ..TimeToGo.. " minutes") end if((time.min % PVoutputPostInterval)==0)then     -- Generated     PowerGeneration, EnergyGeneration = otherdevices_svalues[GenerationDeviceName]:match("([^;]+);([^;]+)")     if Debug=="YES" then         print(" ---- The total generated energy is " .. EnergyGeneration .. " Wh");         print(" ---- The current generated power is " .. PowerGeneration .. " W");     end     -- Temperature     CurrentTemp = otherdevices_svalues[TemperatureDeviceName]:match("([^;]+)")     if Debug=="YES" then         print(" ---- The outside temperature is " .. CurrentTemp .. " C.");     end     -- Upload data to PVoutput       UploadToPVoutput() end
return commandArray

Wat vond je van deze post?

Klik op een ster om deze te beoordelen!

Gemiddelde score 0 / 5. Aantal stemmen: 0

Tot nu toe geen stemmen! Wees de eerste die dit bericht beoordeelt.

5 gedachten over “Pvoutput systeem koppelen aan Domoticz”

  1. blank

    Ik heb alle stappen gevolgd maar krijg in m’n Domoticz log de volgende fouten:
    2020-04-12 17:27:00.242 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_upload_to_PVoutput.lua: …/domoticz/scripts/lua/script_time_upload_to_PVoutput.lua:22: module ‘socket.http’ not found:
    2020-04-12 17:27:00.242 no field package.preload[‘socket.http’]
    2020-04-12 17:27:00.242 no file ‘/usr/local/share/lua/5.3/socket/http.lua’
    2020-04-12 17:27:00.242 no file ‘/usr/local/share/lua/5.3/socket/http/init.lua’
    2020-04-12 17:27:00.242 no file ‘/usr/local/lib/lua/5.3/socket/http.lua’
    2020-04-12 17:27:00.242 no file ‘/usr/local/lib/lua/5.3/socket/http/init.lua’
    2020-04-12 17:27:00.242 no file ‘./socket/http.lua’
    2020-04-12 17:27:00.242 no file ‘./socket/http/init.lua’
    2020-04-12 17:27:00.242 no file ‘/usr/local/lib/lua/5.3/socket/http.so’
    2020-04-12 17:27:00.242 no file ‘/usr/local/lib/lua/5.3/loadall.so’
    2020-04-12 17:27:00.242 no file ‘./socket/http.so’
    2020-04-12 17:27:00.242 no file ‘/usr/local/lib/lua/5.3/socket.so’
    2020-04-12 17:27:00.242 no file ‘/usr/local/lib/lua/5.3/loadall.so’
    2020-04-12 17:27:00.242 no file ‘./socket.so’

    Ik heb de mappen echt 5.2 genoemd zoals in de instructies dus enig idee wat hier mis gaat? In het script zie ik ook geen verwijzing naar 5.3 die ik aan zou kunnen passen.
    Alvast bedankt,

    1. blank

      Hallo j,
      Dat probleem had ik ook nadat ik over ben gegaan naar buster en domoticz v2020.1 daarom ben ik op zoek gegaan naar een werkende situatie.
      Deze heb ik gevonden en komt zéér binnenkort online. Draait hier nu al een aantal dagen zonder problemen.

Laat een reactie achter

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Winkelwagen