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.

Moderator: leecollings

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

Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

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 »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

1.jpg
1.jpg (50.23 KiB) Viewed 7980 times
Ja
Yes
sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr »

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 / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr »

Of cource i changed IP adress
niki_lauda
Posts: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

on a Pi look in /var/temp
sejonr
Posts: 16
Joined: Friday 05 May 2017 12:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

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 / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

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 / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

try to store the script on the sd card. And name it script_time_kostal.lua
niki_lauda
Posts: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

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 / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by sejonr »

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: 25
Joined: Sunday 31 December 2017 17:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by jonathan12 »

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: 115
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

jonathan12 wrote: Sunday 31 December 2017 17: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 219 times
twosteps
Posts: 2
Joined: Thursday 23 August 2018 7:41
Target OS: -
Domoticz version:
Contact:

Re: Domoticz logging the output of a Kostal Piko inverter

Post by twosteps »

Hi all,

I have a noob question regarding the connection to the Kostal Inverter:

On my Piko device, I have both Ethernet and RS485 (RJ45 both) connections.

To retrieve the data using the script, do I have to connect to RS485 or ethernet..?

I have a rapberry Pi 3. If RS485 is needed, I guess I need to connect to my Pi using a RS485 card, right?

Many thanks for your help and again sorry for this basic question

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

Re: Domoticz logging the output of a Kostal Piko inverter

Post by niki_lauda »

twosteps wrote: Thursday 23 August 2018 7:48 Hi all,

I have a noob question regarding the connection to the Kostal Inverter:

On my Piko device, I have both Ethernet and RS485 (RJ45 both) connections.

To retrieve the data using the script, do I have to connect to RS485 or ethernet..?

I have a rapberry Pi 3. If RS485 is needed, I guess I need to connect to my Pi using a RS485 card, right?

Many thanks for your help and again sorry for this basic question

Herve
If you reply to an message you will get an bnotification. I accendentally stumbled over your message.

I connected the PIKO via an Ethernet cable.
Don't excuse yourself for asking a question. Only by asking an question you can learn.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest