Domoticz logging the output of a Kostal Piko inverter

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.
Post Reply
niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Sunday 28 June 2015 21:26

Hi
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

luusje
Posts: 3
Joined: Monday 28 March 2016 23:40
Target OS: Linux
Domoticz version: V3.5021
Location: Sintjut
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by luusje » Tuesday 29 March 2016 10:20

Hi,

Was just browsing the forum. Did you manage to get the Piko logging fully working? I have one also and would be nice to add to Domoticz.


Greetz


Verzonden vanaf mijn iPhone met Tapatalk
I'm trying
It just doesn't always work
:D

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Tuesday 29 March 2016 19:10

1.jpg
1.jpg (50.23 KiB) Viewed 2859 times
Ja
Yes

sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr » Friday 05 May 2017 12:42

Hi

I tryed to implement this code but i cant get any data from Kostal Inverter 4.2 that i have. I have stored the piko.py in right place and did exactlly as decribed in code above but i get nothing.

I realy need help!!!! I have tryed for several houers. This is my first LUA code.

sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr » Friday 05 May 2017 12:42

Of cource i changed IP adress

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Friday 05 May 2017 13:52

Hi
Do you run domitcz on a raspberry Pi?

What happens if you run from the commandline
python /home/pi/domoticz/scripts/piko.py --host=10.0.0.2 -p -i -d > /var/tmp/piko.tmp

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Friday 05 May 2017 13:52

on a Pi look in /var/temp

sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr » Friday 05 May 2017 22:42

Yes i got the file but i got this message when i run from commandline what is this? Do i need a new file?

Traceback (most recent call last):
File "Piko.py", line 40, in <module>
import MySQLdb as mdb
ImportError: No module named MySQLdb

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Saturday 06 May 2017 22:22

I think in your case this is the solution.
http://stackoverflow.com/questions/3504 ... ed-mysqldb

First ensure you have a python mysql driver installed:
sudo pip install pymysql

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Saturday 06 May 2017 22:31

sejonr wrote:Yes i got the file but i got this message when i run from commandline what is this? Do i need a new file?

Traceback (most recent call last):
File "Piko.py", line 40, in <module>
import MySQLdb as mdb
ImportError: No module named MySQLdb
I think in your case this is the solution.
http://stackoverflow.com/questions/3504 ... ed-mysqldb

First ensure you have a python mysql driver installed:
sudo pip install pymysql
OR
apt-get install python-mysqldb

sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr » Tuesday 16 May 2017 13:16

Thank you for your help :) :) Everything works now but not kwh.

The Kwh shows the day after (for example sunday kwh is shown on monday) and i cant see kwh per hour .??

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Tuesday 16 May 2017 21:16

Where is your luascript stored?
Mine is stored in /home/pi/domoticz/scripts/lua and is named script_time_kostal.lua so it runs every minute.

2017-05-16 21:09:02.655 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_kostal.lua
2017-05-16 21:10:04.107 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_kostal.lua
2017-05-16 21:11:01.995 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_kostal.lua
2017-05-16 21:12:02.227 EventSystem: Script event triggered: /home/pi/domoticz/scripts/lua/script_time_kostal.lua

You could try to upload your daily yield to Pvoutput http://www.domoticz.com/wiki/Upload_ene ... o_PVoutput

http://www.domoticz.com/wiki/Upload_ene ... o_PVoutput

sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr » Wednesday 17 May 2017 8:54

My Lua is stored under the right meny - settings / more settings/eventhandling

and i selected Lua in stead of Blockly and the lua script is on time (per min)

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Wednesday 17 May 2017 19:39

try to store the script on the sd card. And name it script_time_kostal.lua

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Thursday 18 May 2017 18:26

sejonr wrote:My Lua is stored under the right meny - settings / more settings/eventhandling

and i selected Lua in stead of Blockly and the lua script is on time (per min)
Did you set the time option under the Lua option in settings / more settings/eventhandling

sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr » Wednesday 11 October 2017 9:08

niki_lauda wrote:
Tuesday 29 March 2016 19:10
1.jpg
Ja
Yes
Hi niki

How did you do?? I copyed your lua but get the same problem as you.

Thank you for help :D

jonathan12
Posts: 1
Joined: Sunday 31 December 2017 18:30
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by jonathan12 » Sunday 31 December 2017 18:32

What am I doing wrong? The temp file is staying empty.

Error in de log:

2017-12-31 17:31:00.300 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_kostal.lua: /home/pi/domoticz/scripts/lua/script_time_kostal.lua:36: attempt to call global 'fileread' (a nil value)

niki_lauda
Posts: 124
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda » Tuesday 15 May 2018 21:01

jonathan12 wrote:
Sunday 31 December 2017 18:32
What am I doing wrong? The temp file is staying empty.

Error in de log:

2017-12-31 17:31:00.300 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_kostal.lua: /home/pi/domoticz/scripts/lua/script_time_kostal.lua:36: attempt to call global 'fileread' (a nil value)
Nothing an updated script is attached
Attachments
script_time_kostal.zip
(1.28 KiB) Downloaded 4 times

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests