Luxtronic Heatpump controller

For heating/cooling related questions in Domoticz
BobbyNL
Posts: 15
Joined: Monday 02 February 2015 17:15
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Luxtronic Heatpump controller

Post by BobbyNL » Monday 09 November 2015 0:19

I'm using a alpha innotec heatpump in my house. I can read and control it by connecting with a webbrowser at http://192.168.0.125:8889
Would it be possible to add this as hardware in domoticz? Or use json to read/write some values?

found this: https://github.com/pfandfrei/luxtronik2
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam

poostrom
Posts: 11
Joined: Tuesday 26 January 2016 15:00
Target OS: Raspberry Pi
Domoticz version: Latest
Location: Gorinchem - Netherlands
Contact:

Re: Luxtronic Heatpump controller

Post by poostrom » Wednesday 09 March 2016 17:49

Hi Bobby,

Did some stealing of code and managed to read values from a Luxtronik 2.0 in python.
It's very beta, but works for me though. Able to create a dummy sensor for kWh's and put the values with json to domoticz.... I only did the kWh, working on other things, just testing this now....
For the record in the json IDX 191 is my virtual sensor for kWh's.... You might want to comment this out first, first see if there's any output. There should be output like this:

Temperatuur buiten : 8.3
Temperatuur voorloop : 21.5
Temperatuur naloop : 21.5
Rucklauf Soll : 21.7
WQ Eingangstemp : 24.9
WA Ausgangstemp : 26.0
Betriebszeit Verdichter 1 : 314 days, 7:53:36
Impulse VD1 : 3863
Betriebsstunden WP : 314 days, 7:53:35
Betriebsstunden Heizung : 222 days, 21:58:30
Verbruik verwaming (kWh) : 48323.1
Verbruik heet water (kWh) : 8061.3
Betriebsstunden WW Erzeugung : 91 days, 9:55:05
Status Zeile 1 (code) : 1
Status Zeile 2 (code) : 0
Status Zeile 3 (code) : 1
Status seit : 5:14:26
WMZ Durchfluss l/h : 0.0


Below the python code:

#!/usr/bin/python

import socket
import struct
import datetime
import httplib

#####################
# Luxtronik 2.0 IP
hostHeatpump = '192.168.200.107'
# Luxtronik 2.0 port (standard 8888)
portHeatpump = 8888
#####################


s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect( (hostHeatpump, portHeatpump))

######################################################
s.send( struct.pack( '!i', 3004))
s.send( struct.pack( '!i', 0))
if struct.unpack( '!i', s.recv(4))[0] != 3004:
print 'Error: REQ_CALCULATED CMD'
exit()
stat = struct.unpack( '!i', s.recv(4))[0]
len = struct.unpack( '!i', s.recv(4))[0]
array_calculated = []
for i in xrange(len):
array_calculated.append(struct.unpack( '!i', s.recv(4))[0])
print 'Calculated'
print stat
print len
print array_calculated
print '\n\n'

print "Temperatuur buiten : ", (str(float(array_calculated[15])/10))
print "Temperatuur voorloop : ", (str(float(array_calculated[10])/10))
print "Temperatuur naloop : ", (str(float(array_calculated[11])/10))
print "Rucklauf Soll : ", (str(float(array_calculated[12])/10))
print "WQ Eingangstemp : ", (str(float(array_calculated[19])/10))
print "WA Ausgangstemp : ", (str(float(array_calculated[20])/10))
print "Betriebszeit Verdichter 1 : ", (str(datetime.timedelta(seconds=int(array_calculated[56]))))
print "Impulse VD1 : ", (str(array_calculated[57]))
print "Betriebsstunden WP : ", (str(datetime.timedelta(seconds=int(array_calculated[63]))))
print "Betriebsstunden Heizung : ", (str(datetime.timedelta(seconds=int(array_calculated[64]))))
print "Verbruik verwaming (kWh) : ", (str(float(array_calculated[151])/10))
print "Verbruik heet water (kWh) : ", (str(float(array_calculated[152])/10))
print "Betriebsstunden WW Erzeugung : ", (str(datetime.timedelta(seconds=int(array_calculated[65]))))
print "Status Zeile 1 (code) : ", (str(array_calculated[117]))
print "Status Zeile 2 (code) : ", (str(array_calculated[118]))
print "Status Zeile 3 (code) : ", (str(array_calculated[119]))
print "Status seit : ", (str(datetime.timedelta(seconds=int(array_calculated[120]))))
print "WMZ Durchfluss l/h : ", (str(float(array_calculated[155])))


conn = httplib.HTTPConnection("192.168.200.15:8080")
conn.request("HEAD","/json.htm?type=command&param=udevice&idx=191&svalue=" + (str(float(array_calculated[151])*100)))
# res = conn.getresponse()
#print res.status, res.reason


s.close()

tweakertje
Posts: 12
Joined: Saturday 18 March 2017 10:05
Target OS: -
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by tweakertje » Tuesday 11 April 2017 14:32

Is there any progress on the alpha innotec luxtronic pump
Im using it for 6 months now and I love to get it in domotics
Fluxtronic in the playstore is a nice program to change temps and read values but an automation would be nice



Verstuurd vanaf mijn SM-G930F met Tapatalk

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Wednesday 26 April 2017 10:29

I am also curious whether there is progress in this project.
Is there someone how could explain how to use/install the Python code?

tweakertje
Posts: 12
Joined: Saturday 18 March 2017 10:05
Target OS: -
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by tweakertje » Saturday 29 April 2017 21:53

I'm trying now to get the script working but i'll get
File "luxtronic.py", line 24
print 'Error: REQ_CALCULATED CMD'
^
IndentationError: expected an indented block



What am i doing wrong Python 2.7.12

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Friday 05 May 2017 8:23

I've got it working for the printing part of the data 8-)

When you make a new script file, change permissions so you are able to execute it.

I'm using Python 3.4 and had to change some coding.
The script:
#!/usr/bin/python

import socket
import struct
import datetime
#import httplib # This is not working yet and gives an error

#####################
# Luxtronik 2.0 IP
hostHeatpump = '192.168.1.12'
# Luxtronik 2.0 port (standard 8888)
portHeatpump = 8888
#####################
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect( (hostHeatpump, portHeatpump))
######################################################
s.send( struct.pack( '!i', 3004))
s.send( struct.pack( '!i', 0))
if struct.unpack( '!i', s.recv(4))[0] != 3004:
print("Error: REQ_CALCULATED CMD")
#exit() #Removed this because it give an error but have to look in to this.
stat = struct.unpack( '!i', s.recv(4))[0]
len = struct.unpack( '!i', s.recv(4))[0]
array_calculated = []
for i in range(len):
array_calculated.append(struct.unpack( '!i', s.recv(4))[0])

print("Calculated")
print(stat)
print(len)
print(array_calculated)
print("\n\n")

print("Temperatuur buiten : ", (str(float(array_calculated[15])/10)))
print("Temperatuur voorloop : ", (str(float(array_calculated[10])/10)))
print("Temperatuur naloop : ", (str(float(array_calculated[11])/10)))
print("Rucklauf Soll : ", (str(float(array_calculated[12])/10)))
print("WQ Eingangstemp : ", (str(float(array_calculated[19])/10)))
print("WA Ausgangstemp : ", (str(float(array_calculated[20])/10)))
print("Betriebszeit Verdichter 1 : ", (str(datetime.timedelta(seconds=int(array_calculated[56])))))
print("Impulse VD1 : ", (str(array_calculated[57])))
print("Betriebsstunden WP : ", (str(datetime.timedelta(seconds=int(array_calculated[63])))))
print("Betriebsstunden Heizung : ", (str(datetime.timedelta(seconds=int(array_calculated[64])))))
print("Verbruik verwaming (kWh) : ", (str(float(array_calculated[151])/10)))
print("Verbruik heet water (kWh) : ", (str(float(array_calculated[152])/10)))
print("Betriebsstunden WW Erzeugung : ", (str(datetime.timedelta(seconds=int(array_calculated[65])))))
print("Status Zeile 1 (code) : ", (str(array_calculated[117])))
print("Status Zeile 2 (code) : ", (str(array_calculated[118])))
print("Status Zeile 3 (code) : ", (str(array_calculated[119])))
print("Status seit : ", (str(datetime.timedelta(seconds=int(array_calculated[120])))))
print("WMZ Durchfluss l/h : ", (str(float(array_calculated[155]))))

#Haven't got this below running yet.
#conn = httplib.HTTPConnection("192.168.1.5:8080")
#conn.request("HEAD","/json.htm?type=command&param=udevice&idx=191&svalue=" + (str(float(array_calculated[151])*100)))
# res = conn.getresponse()
#print res.status, res.reason

s.close()

The command to run the script:
pi@raspberrypi:~ $ sudo /home/pi/domoticz/scripts/WP.py

The output results looks like this:
Calculated
1
183
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 540, 402, 279, 329, 741, 75, 101, 481, 475, 98, 87, 750, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24306508, 24307, 0, 0, 31, 0, 0, 24306508, 18093265, 6208256, 0, 0, 0, 0, 0, 168, 0, 132, 0, 99, 0, 0, 11, 1, 5, 86, 49, 46, 54, 49, 0, 0, 0, 0, 0, -1062731508, -256, -1062731265, -1062731266, 1478479227, 1478341711, 1478093318, 1477767105, 1477387553, 715, 715, 715, 715, 715, 5, 9, 9, 9, 0, 9, 1493951602, 1493954767, 1493957919, 1493962391, 1493948480, 0, 1, 0, 1, 132, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1493962522, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]



('Temperatuur buiten : ', '7.5')
('Temperatuur voorloop : ', '54.0')
('Temperatuur naloop : ', '40.2')
('Rucklauf Soll : ', '27.9')
('WQ Eingangstemp : ', '9.8')
('WA Ausgangstemp : ', '8.7')
('Betriebszeit Verdichter 1 : ', '281 days, 7:48:28')
('Impulse VD1 : ', '24307')
('Betriebsstunden WP : ', '281 days, 7:48:28')
('Betriebsstunden Heizung : ', '209 days, 9:54:25')
('Verbruik verwaming (kWh) : ', '0.0')
('Verbruik heet water (kWh) : ', '0.0')
('Betriebsstunden WW Erzeugung : ', '71 days, 20:30:56')
('Status Zeile 1 (code) : ', '1')
('Status Zeile 2 (code) : ', '0')
('Status Zeile 3 (code) : ', '1')
('Status seit : ', '0:02:12')
('WMZ Durchfluss l/h : ', '0.0')

User avatar
Westcott
Posts: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Luxtronic Heatpump controller

Post by Westcott » Friday 05 May 2017 11:14

Hi Aandegrens,

I use the 'requests' lib to send data to, and get data from, Domoticz.
Each request runs in its own thread.
Here's a snippette-

Code: Select all

import threading
import requests

URL_DOMOTICZ = 'http://localhost:8080/json.htm?type='

def DomoticzData(cmd, get=False):
    try:
        url = URL_DOMOTICZ + cmd
        response = requests.get(url)
        if response.ok:
            jsonData = response.json()
            if get == True:
                return jsonData
            elif jsonData["status"] != "OK":
                Log("Status " + jsonData["status"] + " for " + cmd)
        else:
            print("GET failed with " + str(response.status_code))

    except(requests.ConnectionError, e):
        Log('Request Failed %s - %s' % (e, url) )
        
def UpdateDevice(idx, val):
    data = 'command&param=udevice&idx=PARAM_IDX&svalue=PARAM_CMD'
    data = data.replace('PARAM_IDX', idx)
    data = data.replace('PARAM_CMD', str(val))

    threadReqHome = threading.Thread(target=DomoticzData, args=(data,))
    threadReqHome.start()

Zwave - Sigma Z+ stick, Fibaro 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

tweakertje
Posts: 12
Joined: Saturday 18 March 2017 10:05
Target OS: -
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by tweakertje » Tuesday 09 May 2017 21:57

hi all
I've got it working
the scripts keeps running and updates every 30 seconds
the first sleep is 90 seconds so you can make an cron for start @boot





# !/usr/bin/python

import socket
import struct
import datetime
import httplib

#####################
# Luxtronik 2.0 IP
hostHeatpump = '192.168.1.5'
# Luxtronik 2.0 port (standard 8888)
portHeatpump = 8888
#####################

import time
time.sleep(90)
while 1==1:
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect( (hostHeatpump, portHeatpump))

######################################################
s.send( struct.pack( '!i', 3004))
s.send( struct.pack( '!i', 0))
if struct.unpack( '!i', s.recv(4))[0] != 3004:print 'Error: REQ_CALCULATED CMD'
#exit()
stat = struct.unpack( '!i', s.recv(4))[0]
len = struct.unpack( '!i', s.recv(4))[0]
array_calculated = []
for i in xrange(len):array_calculated.append(struct.unpack( '!i', s.recv(4))[0])
print 'Calculated'
print stat
print len
print array_calculated
print '\n\n'

print "Temperatuur buiten : ", (str(float(array_calculated[15])/10))
print "Temperatuur voorloop : ", (str(float(array_calculated[10])/10))
print "Temperatuur naloop : ", (str(float(array_calculated[11])/10))
print "Temp boiler : ", (str(float(array_calculated[17])/10))
print "Tapwater Ingesteld : ", (str(float(array_calculated[18])/10))
print "Temperatuur Retour Berekend : ", (str(float(array_calculated[12])/10))
print "Temperatuur Bron In : ", (str(float(array_calculated[19])/10))
print "WA Ausgangstemp : ", (str(float(array_calculated[20])/10))
print "Temperatuur Zuiggasleiding Comp. : ", (str(float(array_calculated[176])/10))
print "Betriebszeit Verdichter 1 : ", (str(datetime.timedelta(seconds=int(array_calculated[56]))))
print "Compressor 1 inschakelpulsen : ", (str(array_calculated[57]))
print "Bedrijfsuren WP : ", (str(datetime.timedelta(seconds=int(array_calculated[63]))))
print "Bedrijfsuren Verwarmen : ", (str(datetime.timedelta(seconds=int(array_calculated[64]))))
print "Bedrijfsuren WW : ", (str(datetime.timedelta(seconds=int(array_calculated[65]))))
print "Verbruik verwaming (kWh) : ", (str(float(array_calculated[151])/10))
print "Verbruik heet water (kWh) : ", (str(float(array_calculated[152])/10))
print "Status Zeile 1 (code) : ", (str(array_calculated[117]))
print "Status Zeile 2 (code) : ", (str(array_calculated[118]))
print "Status Zeile 3 (code) : ", (str(array_calculated[119]))
print "Status seit : ", (str(datetime.timedelta(seconds=int(array_calculated[120]))))
print "WMZ Durchfluss l/h : ", (str(float(array_calculated[155])))


conn = httplib.HTTPConnection("192.168.1.10:8084")
# conn.request("HEAD","/json.htm?type=command&param=udevice&idx=141&svalue=" + (str(float(array_calculated[151])*100)))
conn.request("HEAD","/json.htm?type=command&param=udevice&idx=142&svalue=" + (str(float(array_calculated[17])/10)))

conn = httplib.HTTPConnection("192.168.1.10:8084")
conn.request("HEAD","/json.htm?type=command&param=udevice&idx=143&svalue=" + (str(float(array_calculated[15])/10)))
# res = conn.getresponse()
# print res.status, res.reason

time.sleep(30)


s.close()

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Thursday 11 May 2017 20:21

Hi,

I can't get it working to write the data from Python to Domoticz.

Code: Select all

    strDomoticz = '192.168.1.5:8080'
    strJson='/json.htm?type=command&param=udevice&idx='+str(idxTempBuiten)+'&svalue='+TempBuiten
    print(strDomoticz+strJson)

    conn = http.client.HTTPConnection(strDomoticz)
    conn.request("HEAD",strJson)
    res = conn.getresponse()
    print('Status: '+str(res.status)+' Reason: '+str(res.reason))
When I enter contents of the strings strDomoticz+strJson directly in the browser the value in Domoticz is changed.

192.168.1.5:8080/json.htm?type=command&param=udevice&idx=82&svalue=16.5

So I'm guessing the strings are correct.

Because i'm using Python 3.4.2 i had to change httplib to http.client
I'm not getting error messages in Python itself but this is what the last printcommand returns:
Status: 401 Reason: Unauthorized

What's going wrong, anyone?

User avatar
Westcott
Posts: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Luxtronic Heatpump controller

Post by Westcott » Thursday 11 May 2017 20:45

You could try using the 'requests' library instead.
Here's an incomplete fragment -

Code: Select all

import requests
            url = 'http://localhost:8080/json.htm?type=' + cmd
            response = requests.get(url)
            if response.ok:
                jsonData = response.json()
                if f jsonData["status"] != "OK":
                    print("Status " + jsonData["status"] + " for " + cmd)
            else:
                print("GET failed with " + str(response.status_code))
Zwave - Sigma Z+ stick, Fibaro 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Thursday 11 May 2017 21:23

Hi Westcott,

I tried the following:

Code: Select all

    strDomoticz = 'http://localhost:8080'
    print(strDomoticz+strJson)
    response = requests.get(strDomoticz+strJson)
    if response.ok:
        jsonData = response.json()
        if jsonData["status"] != "OK":
            print("Status " + jsonData["status"] + " for " + strJson)
        else:
            print("GET failed with " + str(response.status_code))
    else:
        print('Response not OK!!!'str(response.status_code))
It returns no errors from Python but print the message "Response not OK!!!: 401"
When I enter strDomoticz+strJson in the browser directly i'm getting the 401 error also.
When I change localhost to the ip adres of Domoticz it works in the browser, but not in Python. Same Response not OK!!! 401 error in Python.

Looks like Python doesn't have any rights to write directly to Domoticz.

tweakertje
Posts: 12
Joined: Saturday 18 March 2017 10:05
Target OS: -
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by tweakertje » Thursday 11 May 2017 23:54

In domoticz go to setings system and put the ipadres of your server in ip adres without authentication

Verstuurd vanaf mijn SM-G930F met Tapatalk

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Friday 12 May 2017 0:21

Yip, That's it.
Or removing the username for the website does the trick also.
But adding an ip range is a beter solution.

Made a function that does the writing to Domoticz form me now:

Code: Select all

import socket
import struct
import datetime
import http.client
import time
import requests

#########################################################################################
#Schrijf data naar Domoticz
#########################################################################################
def Domoticz(strIdx, strVal):
    strDomoticz = '192.168.1.5:8080'
    strJson='/json.htm?type=command&param=udevice&idx='+strIdx+'&svalue='+strVal
    #print(strDomoticz+strJson)

    conn = http.client.HTTPConnection(strDomoticz)
    conn.request("HEAD",strJson)
    res = conn.getresponse()
    if str(res.status) == '200':
        x=1
        #print(Tijd+"  Ok")
    else:
        print(Tijd+"  IDX = "+strIdx+" ("+strVal+")   "+str(res.status)+' Reason: '+str(res.reason))
    return
#########################################################################################
#\Schrijf data naar Domoticz
#########################################################################################
Thank you all for your assistance.

vaevictis
Posts: 12
Joined: Thursday 26 May 2016 7:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by vaevictis » Friday 02 June 2017 11:33

Is this script compatible with Python 2 or 3?

When I run this script with Python 3.2 and the correct IP addresses and dummy device ids it just hangs. When I break it off with CTRL-C:

/luxtronic.py: line 12: portHeatpump: command not found
./luxtronic.py: line 14: syntax error near unexpected token `('
./luxtronic.py: line 14: `s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)'

Can someone post the integral working version of this script? Thanks.

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Friday 02 June 2017 16:55

My script is running on Python 3.4

vaevictis
Posts: 12
Joined: Thursday 26 May 2016 7:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by vaevictis » Friday 02 June 2017 18:37

Aandegrens wrote:My script is running on Python 3.4
Can you post your latest version?
The webserver is protected with a default password 888888 and got recently an update to firmware V3.79 can this be the reason the script doesn't work?

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Friday 02 June 2017 18:55

Code: Select all

#!/usr/bin/python

import socket
import struct
import datetime
import http.client
import time
import requests
import json
import sys
import codecs

#########################################################################################
#Write data to Domoticz
#########################################################################################
def Domoticz(strIdx, strVal, strDesc = '', strWP_ID = ''):
    strDomoticz = '192.168.1.5:8080'
    strJson='/json.htm?type=command&param=udevice&idx='+strIdx+'&svalue='+strVal
    #print(strDomoticz+strJson)

    conn = http.client.HTTPConnection(strDomoticz)
    conn.request("HEAD",strJson)
    res = conn.getresponse()
    if str(res.status) == '200':
        x=1
        #print(Tijd+"  Ok")
        print(strDesc+'; '+strVal+'; DomoticzID; '+strIdx+'; WP_ID; '+strWP_ID+'; Upload')
    else:
        print(Tijd+"  IDX = "+strIdx+" ("+strVal+")   "+str(res.status)+' Reason: '+str(res.reason))
    return
#########################################################################################
#\Write data to Domoticz
#########################################################################################

#########################################################################################
#Read data from Domoticz
#########################################################################################
def DomoticzRead(strIdx, strVal = ''):
    intS = 0
    intE = 0
    intFound = 0
    strCont = "" 
    strDomoticz = '192.168.1.5:8080'
    strJson='/json.htm?type=devices&rid='+strIdx
    #print(strDomoticz+strJson)

    conn = http.client.HTTPConnection(strDomoticz)
    conn.request("GET",strJson)
    res = conn.getresponse()
    conn.close
    strCont = str(res.read())

    intS = strCont.find('"Data" : "',0)+10
    intFound = strCont.find(strVal,intS)
    print('Waarde voor '+strIdx+' gevonden op positie:'+str(intFound))
    return str(intFound)
#########################################################################################
#\Read data from Domoticz
#########################################################################################


#########################################################################################
#Settings of the Heatpump
#########################################################################################
# Luxtronik 2.0 IP
hostHeatpump = '192.168.1.12'
# Luxtronik 2.0 port (standard 8889)
portHeatpump = 8888
#########################################################################################
#/Settings of the Heatpump
#########################################################################################



Tijd = str(time.asctime(time.localtime(time.time())))
#########################################################################################
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
s.connect( (hostHeatpump, portHeatpump))
#########################################################################################
s.send( struct.pack( '!i', 3004))
s.send( struct.pack( '!i', 0))

if struct.unpack( '!i', s.recv(4))[0] != 3004:
    print(Tijd+"  Error: REQ_CALCULATED CMD")
    exit()

stat = struct.unpack( '!i', s.recv(4))[0]
len = struct.unpack( '!i', s.recv(4))[0]
array_calculated = []
for i in range(len):
    array_calculated.append(struct.unpack( '!i', s.recv(4))[0])
    
print('\n'+Tijd+'\n')
print(array_calculated)
print("\n")

#########################################################################################
#Data to variabelen and Domoticz
#########################################################################################
val = str(float(array_calculated[10])/10)
Domoticz('86', val, 'Temperatuur Aanvoer', '10')

val = str(float(array_calculated[11])/10)
Domoticz('87', val, 'Temperatuur Retour', '11')

val = str(float(array_calculated[12])/10)
Domoticz('88', val, 'Temperatuur Retour Berekend', '12')

val = str(float(array_calculated[13])/10)
Domoticz('89', val, 'Temperatuur Retour Extern', '13')
 
val = str(float(array_calculated[14])/10)
Domoticz('90', val, 'Temperatuur Heetgas', '14')

val = str(float(array_calculated[15])/10)
Domoticz('91', val, 'Temperatuur Buiten', '15')

val = str(float(array_calculated[16])/10)
Domoticz('92', val, 'Temperatuur Gemiddeld', '16')

val = str(float(array_calculated[17])/10)
Domoticz('93', val, 'Temperatuur Tapwater', '17')

val = str(float(array_calculated[18])/10)
Domoticz('94', val, 'Temperatuur Tapwater ingesteld', '18')

val = str(float(array_calculated[19])/10)
Domoticz('95', val, 'Temperatuur Bron-in', '19')

val = str(float(array_calculated[20])/10)
Domoticz('96', val, 'Temperatuur Bron-uit', '20')

val = '-1.5'
Domoticz('97', val, 'Temperatuur VW Offset', '--')

val = str(round(int(array_calculated[56]/3600),0))
if DomoticzRead('100',val) == '-1': 
    Domoticz('100', val, 'Uren compressor', '56')

val = str(array_calculated[57])
if DomoticzRead('101',val) == '-1': 
    Domoticz('101', val, 'Impulsen compressor', '57')

val = str(round(int(array_calculated[63]/3600),0))
if DomoticzRead('102',val) == '-1': 
    Domoticz('102', val, 'Uren WP', '63')

val = str(round(int(array_calculated[64]/3600),0))
if DomoticzRead('103',val) == '-1': 
    Domoticz('103', val, 'Uren Verwarming', '64')

val = str(round(int(array_calculated[65]/3600),0))
if DomoticzRead('104',val) == '-1': 
    Domoticz('104', val, 'Uren Tapwater', '65')

##idx = ''
##wp = '116' 
##val = str(datetime.timedelta(seconds=int(array_calculated[116])))
##print('; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '117' 
##val = str(datetime.timedelta(seconds=int(array_calculated[117])))
##print('; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '118' 
##val = str(datetime.timedelta(seconds=int(array_calculated[118])))
##print('; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)

val = str(int(array_calculated[119]))
if val == '0':
    omschr = 'Verwarmen'
elif val == '1':
    omschr = 'Geen_Vraag'
elif val == '2':
    omschr = 'Netz-Einschaltverzoegerung'
elif val == '3':
    omschr = 'SSP-zeit'
elif val == '4':
    omschr = 'Sperrzeit'
elif val == '5':
    omschr = 'Tapwater'
elif val == '6':
    omschr = 'Estrich-programm'
elif val == '7':
    omschr = 'Abtauen'
elif val == '8':
    omschr = 'Pumpenvorlauf'
elif val == '9':
    omschr = 'Thermische_Desinfectie'
elif val == '10':
    omschr = 'Koelen'
elif val == '11':
    omschr = '11:???'
elif val == '12':
    omschr = 'Zwembad'
elif val == '13':
    omschr = 'Verwarmen_Ext.'
elif val == '14':
    omschr = 'Tapwater_Ext.'
elif val == '15':
    omschr = '15:???'
elif val == '16':
    omschr = 'Durchflussueberwachung'
elif val == '17':
    omschr = 'ZWE-betrieb'
 
if DomoticzRead('106',omschr) == '-1': 
##    print("Reslutaat lees "+DomoticzRead('106', omschr))
    Domoticz('106',omschr,'WP Status','119')
##    print('Status; '+val+'; '+omschr+' ; DomoticzID; '+idx+'; WP_ID; '+wp)

##idx = ''
##wp = '120' 
##val = str(datetime.timedelta(seconds=int(array_calculated[120])))
##print('VD-stand; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '121'
##val = str(datetime.timedelta(seconds=int(array_calculated[121])))
##print('HRM-tijd; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '122'
##val = str(datetime.timedelta(seconds=int(array_calculated[122])))
##print('HRW-tijd; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '123'
##val = str(datetime.timedelta(seconds=int(array_calculated[123])))
##print('TDI-tijd; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '124'
##val = str(datetime.timedelta(seconds=int(array_calculated[124])))
##print('Blok. tapwater; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##idx = ''
##wp = '125'
##val = str(datetime.timedelta(seconds=int(array_calculated[124])))
##print('; '+val+'; DomoticzID; '+idx+'; WP_ID; '+wp)
##
##kWhVerwarming = str(float(array_calculated[151])/10)
##kWhHeetWater = str(float(array_calculated[152])/10)
##StatusZeile1 = str(array_calculated[117])
##StatusZeile2 = str(array_calculated[118])
##StatusZeile3 = str(array_calculated[119])
##LphDurchflussWMZ = str(float(array_calculated[155]))
##

Tijd = str(time.asctime(time.localtime(time.time())))[11:-5]
val = str(Tijd)
Domoticz('105', val, 'Script laatste run', '--')
#########################################################################################
#\Data to variabelen and Domoticz
#########################################################################################

print("Klaar")
s.close()

vaevictis
Posts: 12
Joined: Thursday 26 May 2016 7:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by vaevictis » Friday 02 June 2017 19:37

Ok, got it working by using port 8889 and indenting the script with tabs.
However when the script prints out the text I still get some error:

print("Temperatuur buiten : ", (str(float(array_calculated[15])/10)))
IndexError: list index out of range

Aandegrens
Posts: 18
Joined: Saturday 08 April 2017 19:36
Target OS: Windows
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by Aandegrens » Friday 02 June 2017 19:49

Does the print(array_calculated) command return any values?

It should return something like this:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 403, 385, 150, 360, 333, 261, 208, 465, 475, 293, 306, 750, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24508085, 24460, 0, 0, 31, 0, 0, 24508085, 18218266, 6284792, 0, 0, 0, 0, 0, 0, 0, 42625, 0, 353876, 0, 0, 11, 1, 5, 86, 49, 46, 54, 49, 0, 0, 0, 0, 0, -1062731508, -256, -1062731265, -1062731266, 1478479227, 1478341711, 1478093318, 1477767105, 1477387553, 715, 715, 715, 715, 715, 5, 9, 9, 9, 9, 9, 1496326851, 1496383675, 1496118204, 1496168953, 1496240691, 0, 1, 0, 1, 42625, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1496426298, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

vaevictis
Posts: 12
Joined: Thursday 26 May 2016 7:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Luxtronic Heatpump controller

Post by vaevictis » Friday 02 June 2017 20:54

Aandegrens wrote:Does the print(array_calculated) command return any values?

It should return something like this:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 403, 385, 150, 360, 333, 261, 208, 465, 475, 293, 306, 750, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24508085, 24460, 0, 0, 31, 0, 0, 24508085, 18218266, 6284792, 0, 0, 0, 0, 0, 0, 0, 42625, 0, 353876, 0, 0, 11, 1, 5, 86, 49, 46, 54, 49, 0, 0, 0, 0, 0, -1062731508, -256, -1062731265, -1062731266, 1478479227, 1478341711, 1478093318, 1477767105, 1477387553, 715, 715, 715, 715, 715, 5, 9, 9, 9, 9, 9, 1496326851, 1496383675, 1496118204, 1496168953, 1496240691, 0, 1, 0, 1, 42625, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1496426298, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Yes but different positions in the array. The output is:"

Calculated
0
249
[1077014636, 1077014636, 0, 0, 7043360, 263938, 32, 16, 0, 117575680, 179, 200, 150, 50, 244, 247, 214, 537, 580, 143, 158, 750, 0, -32, 179, 180, 50, 1500, 50, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3163640, 1244, 0, 0, 697987, 342041, 0, 3163640, 2588492, 574936, 373931, 1, 0, 0, 0, 0, 0, 39031, 0, 8714, 0, 0, 59, 1, 5, 86, 51, 46, 55, 57, 0, 0, 0, 0, 0, 171049632, -256, 171049727, 171049473, 1482491133, 1482161448, 1481642408, 1481636688, 1481207735, 751, 751, 751, 733, 751, 5, 9, 0, 9, 0, 9, 1496295401, 1496357693, 1496357694, 1496385802, 1496385803, 1, 1, 0, 10, 39031, 0, 0, 207966, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1496424834, 0, 180, 750, 0, 0, 1, 0, -32, -32, 3, 0, 1, 1, 0, 0, 0, 62609, 12217, 0, 4159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 800, 1, 0, 248, 0, 83, 60, 1216, 1210, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 232, 200, 0, 0, 0, 165, 166, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 640, 0, 0, 0, 0]

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests