I've got it working for the printing part of the data
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¶m=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')