I made a lua script that logs the output from my solar panels. The actual output I use as a kind lux meter to switch on lights.
It makes use off a Python script piko.py. You can find it here. http://sourceforge.net/projects/piko/files/
I have one problem to solve. Some string manupilation.
And a question how can I get the total energy in Domoticz. Currently only the Current watts and the energy generated today is shown.
By the way if I look in the log at the chart for today it shows the same data as yesterday. Tomorrow it shows the correct data.
Here is it.
Code: Select all
----------------------------------------------------------------------------------------------------------------
-- Get the actual production data from a Kostal Piko Inverter
-- Base lua used IsItGonnaRain
--
-- Uses Piko.py http://sourceforge.net/projects/piko/files/
--
-- Written in LUA by Hans Roijmans
-- summer 2015
-- 26-06-2015 v0.1 Initial release
--
-- Todo: routine to get the data between ':' and 'W(h)'
-- Output of tempfilename = '/var/tmp/piko.tmp'
-- Total energy : 11651331 Wh
-- Today energy : 13104 Wh
-- DC Power : 1454 W
-- AC Power : 1342 W
-- Efficiency : 92.3%
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
-- Domoticz IDX and names of the needed device
----------------------------------------------------------------------------------------------------------
local PIKOIDX = 1121
----------------------------------------------------------------------------------------------------------
-- Script parameter
----------------------------------------------------------------------------------------------------------
tempfilename = '/var/tmp/piko.tmp'
----------------------------------------------------------------------------------------------------------
-- CommandArray
----------------------------------------------------------------------------------------------------------
commandArray = {}
read = os.execute('python /home/pi/domoticz/scripts/piko.py --host=10.0.0.2 -p -i -d > /var/tmp/piko.tmp') --
file = io.open(tempfilename, "r")
-- Read lines.
line = file:read("*line")
-- Total energy : 11651331 Wh
total=string.sub(tostring(line),18,27)
line = file:read("*line")
-- Today energy : 13104 Wh
today=string.sub(tostring(line),18,23)
line = file:read("*line")
-- DC Power : 1454 W
nowdc=string.sub(tostring(line),18,22)
line = file:read("*line")
-- AC Power : 1342 W
nowac=string.sub(tostring(line),18,22)
file:close()
commandArray = {['UpdateDevice'] = PIKOIDX .. '|0|' .. nowac .. ';' .. today }
return commandArray