Ik probeerde een SAJ omvormer uit te lezen en te koppelen aan Domoticz, maar dat lukte niet. In in een andere thread heb ik gelezen dat je in de omvormer de url real_time_data.xml kunt uitlezen, maar die url bestaat kennelijk niet in alle SAJ WiFi converters (ik heb de indruk dat hij niet in de nieuwere bestaat, maar wel in de oudere).
Het volgende heb ik gevonden:
Status van SAJ INVERTERs (in dit geval een SAJ Sununo Plus 3K-M) kan via de volgende URLs worden opgevraagd
Status of SAJ solar inverters (in this case a SAJ Sununo Plus 3K-M) can be requested via the following URLs
Uiteraard dien je de tekst tussen <> te vervangen door je eigen gegegevens
Naturally you need to replace the text betweeen <> with your own data
Device Info
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/i18n/en/info.xml
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/info.php
Device Status
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/i18n/en/status.xml
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/status/status.php
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/status/chart.php
Event Log
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/i18n/en/log.xml
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/log.php
WiFi Status
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/i18n/en/wifi.xml
http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/wifi.php
If you request the status of the SAJ inverter via http://<LOGIN_INVERTER>:<PASSWORD_INVERTER>@<IP_INVERTER>/status/status.php , then the values that will be returned are described below.
Value Description Notation
1 Statistics 1
2 Total Generated (2 decimals, unit kWh)
3 Total Running Time (1 decimal, unit h)
4 Today Generated (2 decimals, unit kWh)
5 Today Running Time (1 decimal, unit h)
6 PV1 Voltage (1 decimal, unit V)
7 PV1 Current (2 decimals, unit A)
8 PV2 Voltage (1 decimal, unit V)
9 PV2 Current (2 decimals, unit A)
10 PV3 Voltage (1 decimal, unit V)
11 PV3 Current (2 decimals, unit A)
12 PV1 StrCurr1 (2 decimals, unit A)
13 PV1 StrCurr2 (2 decimals, unit A)
14 PV1 StrCurr3 (2 decimals, unit A)
15 PV1 StrCurr4 (2 decimals, unit A)
16 PV2 StrCurr1 (2 decimals, unit A)
17 PV2 StrCurr2 (2 decimals, unit A)
18 PV2 StrCurr3 (2 decimals, unit A)
19 PV2 StrCurr4 (2 decimals, unit A)
20 PV3 StrCurr1 (2 decimals, unit A)
21 PV3 StrCurr2 (2 decimals, unit A)
22 PV3 StrCurr3 (2 decimals, unit A)
23 PV3 StrCurr4 (2 decimalen, eenheid A)
24 Grid-connected Power (1 decimal, unit W)
25 Grid-connected Frequency (2 decimals, unit Hz)
26 Line1 Voltage (1 decimal, unit V)
27 Line1 Current (2 decimals, unit A)
28 Line2 Voltage (1 decimal, unit V)
29 Line2 Current (2 decimals, unit A)
30 Line3 Voltage (1 decimal, unit V)
31 Line3 Current (2 decimals, unit A)
32 Bus Voltage (1 decimal, unit V)
33 Device Temperature (1 decimal, unit Celsius)
34 CO2emission reduction (1 decimal, unit KG)
35 Other Status 2
Note: value 65535 is status NA (Not Available)
Op basis van deze gegevens heb ik samen met een vriend een (misschien niet bijzonder efficiënte, maar wel duidelijke) Python script gemaakt o.b.v. Python 2.7, waarmee je de SAJ inverters kunt uitlezen en via een cron job bijvoorbeeld elke minuut in Domoticz kunt wegschrijven.
Python:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
| #!/usr/bin/python
# (C) 2018 by proc
# This script reads the output of SAJ Solar Inverters and parses it so that it can be used in a meaningful way in Domoticz
# Import libraries
import csv
import urllib2
import urllib
import base64
import sys
def main():
global username,password
try:
username = 'SAJ_INVERTER_USERNAME_FILL-IN;'
password = 'SAJ_INVERTER_PASSWORD_FILL-IN;'
domoticzUrl = 'http://DOMOTICZ_ADDRESS_FILL-IN:DOMOTICZ_PORT_FILL-IN/json.htm'
##data configuration##
#It is required that create a dummy hardware sensor in Domoticz, and that you create virtual sensors within this Dummy sensor. For every idxict entry below there needs to be a corresponding virtual sensor.
#This is the order in which the values will be read. Index starts with 0
#'Statistics,Total_Generated,Total_Running_Time,Today_Generated,Today_Running_Time,PV1_Voltage,PV1_Current,PV2_Voltage,PV2_Current,PV3_Voltage,PV3_Current,PV1_StrCurr1,PV1_StrCurr2,PV1_StrCurr3,PV1_StrCurr4,PV2_StrCurr1,PV2_StrCurr2,PV2_StrCurr3,PV2_StrCurr4,PV3_StrCurr1,PV3_StrCurr2,PV3_StrCurr3,PV3_StrCurr4,Grid_connected_Power,Grid_connected_Frequency,Line1_Voltage,Line1_Current,Line2_Voltage,Line2_Current,Line3_Voltage,Line3_Current,Bus_Voltage,Device_Temperature,CO2emission_Reduction,Other_Status'
indexdict = {'Total_Generated': 1
,'Total_Running_Time': 2
,'Today_Generated': 3
,'Today_Running_Time': 4
,'PV1_Voltage': 5
,'PV1_Current': 6
,'Grid_connected_Power': 23
,'Grid_connected_Frequency': 24
,'Line1_Voltage': 25
,'Line1_Current': 26
,'Bus_Voltage': 31
,'Device_Temperature': 32
,'CO2emission_Reduction': 33}
#Every virtual sensors that you created needs to have a matching idxict; you need to adjust the script so that the idxict matches the virtual sensors you created.
idxdict = {'Total_Generated': 27
,'Total_Running_Time': 28
,'Today_Generated': 29
,'Today_Running_Time': 30
,'PV1_Voltage': 31
,'PV1_Current': 32
,'Grid_connected_Power': 33
,'Grid_connected_Frequency': 34
,'Line1_Voltage': 35
,'Line1_Current': 36
,'Bus_Voltage': 37
,'Device_Temperature': 38
,'CO2emission_Reduction': 39}
request = urllib2.Request("http://SAJ_INVERTER_ADDRESS_FILL-IN/status/status.php")
base64string = base64.b64encode('%s:%s' % (username, password))
request.add_header("Authorization", "Basic %s" % base64string)
response = urllib2.urlopen(request)
status = response.read()
status = status.replace("'", "")
status = status.replace("[", "")
status = status.replace("]", "")
status = status.replace(" ", "")
status_array = status.split(",")
##values that are delivered are not in the preferred format and will be adjusted here
status_array[indexdict['Total_Generated']] = float(status_array[indexdict['Total_Generated']]) * 0.01
status_array[indexdict['Total_Running_Time']] = float(status_array[indexdict['Total_Running_Time']]) * 0.1
status_array[indexdict['Today_Generated']] = float(status_array[indexdict['Today_Generated']]) * 0.01
status_array[indexdict['Today_Running_Time']] = float(status_array[indexdict['Today_Running_Time']]) * 0.1
status_array[indexdict['PV1_Voltage']] = float(status_array[indexdict['PV1_Voltage']]) * 0.1
status_array[indexdict['PV1_Current']] = float(status_array[indexdict['PV1_Current']]) * 0.01
status_array[indexdict['Grid_connected_Power']] = float(status_array[indexdict['Grid_connected_Power']]) * 1.0
status_array[indexdict['Grid_connected_Frequency']] = float(status_array[indexdict['Grid_connected_Frequency']]) * 0.01
status_array[indexdict['Line1_Voltage']] = float(status_array[indexdict['Line1_Voltage']]) * 0.1
status_array[indexdict['Line1_Current']] = float(status_array[indexdict['Line1_Current']]) * 0.01
status_array[indexdict['Bus_Voltage']] = float(status_array[indexdict['Bus_Voltage']]) * 0.1
status_array[indexdict['Device_Temperature']] = float(status_array[indexdict['Device_Temperature']]) * 0.1
status_array[indexdict['CO2emission_Reduction']] = float(status_array[indexdict['CO2emission_Reduction']]) * 0.1
#build and call Domoticz url to write data to
for key in indexdict:
get_data = {
'svalue': status_array[indexdict[key]],
'type': 'command',
'param': 'udevice',
'idx' : idxdict[key]
}
get_data_encoded = urllib.urlencode(get_data)
full_url = domoticzUrl + '?' + get_data_encoded
urllib.urlopen(full_url)
#print full_url
except Exception as e:
print e
sys.exit() |