Schnittstelle der ahoy-DTU (JSON)
{"menu":{"name":["Live","Serial Console","Settings","-","REST API","-","Update","System","-","Logout"],"link":["/live","/serial","/setup",null,"/api",null,"/update","/system",null,"/logout"],"trgt":[null,null,null,null,"_blank"]},"system":{"ssid":"FRITZ!Box","device_name":"AHOY-DTU","version":"0.5.41","build":"dec333f","ts_uptime":471455,"ts_now":1680104147,"ts_sunrise":1680066964,"ts_sunset":1680112471,"ts_sun_upd":1680044400,"wifi_rssi":-26,"mac":"EC:FA:BC:41:3E:7C","hostname":"AHOY-DTU","pwd_set":true,"sdk":"2.2.2-dev(38a443e)","cpu_freq":80,"heap_free":12584,"sketch_total":2662400,"sketch_used":468,"core_version":"3.0.2","flash_size":4096,"heap_frag":1,"max_free_blk":12488,"reboot_reason":"Exception","esp_type":"ESP8266"},"inverter":[{"name":"HM-1500 Dach1","channels":4,"power_limit_read":100,"last_alarm":"Inverter start","ts_last_success":1680104123,"ch":[[236.6,0.77,182.7,49.97,0.993,30.3,234.021,1807,192.4,94.958,21.8],[34.8,1.47,51,457,61.816,13.247],[34.8,1.46,50.7,478,62.332,13.169],[35.1,1.27,44.6,427,54.126,11.584],[35.1,1.31,46.1,445,55.747,11.974]],"ch_names":["AC","hinten 1","vorne 3","vorne 2","vorne 1"]},{"name":"HM-1500 Balkon","channels":4,"power_limit_read":100,"last_alarm":"Inverter start","ts_last_success":1680104093,"ch":[[235.6,0.87,205.8,49.99,0.994,30.1,284.323,1733,216.7,94.97,21.8],[33.8,1.36,46,420,81.783,11.948],[33.8,1.36,45.8,416,84.592,11.896],[34,1.85,62.6,450,45.408,16.26],[34,1.84,62.3,447,72.54,16.182]],"ch_names":["AC","sued west","sued ost","west nord","west sued"]}],"refresh_interval":30,"ch0_fld_units":["V","A","W","Hz","","°C","kWh","Wh","W","%","var"],"ch0_fld_names":["U_AC","I_AC","P_AC","F_AC","PF_AC","Temp","YieldTotal","YieldDay","P_DC","Efficiency","Q_AC"],"fld_units":["V","A","W","Wh","kWh","%"],"fld_names":["U_DC","I_DC","P_DC","YieldDay","YieldTotal","Irradiation"]}
Umwandlung der JSON-Daten in ein Array
Array
(
[menu] => Array
(
[name] => Array
(
[0] => Live
[1] => Serial Console
[2] => Settings
[3] => -
[4] => REST API
[5] => -
[6] => Update
[7] => System
[8] => -
[9] => Logout
)
[link] => Array
(
[0] => /live
[1] => /serial
[2] => /setup
[3] =>
[4] => /api
[5] =>
[6] => /update
[7] => /system
[8] =>
[9] => /logout
)
[trgt] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] => _blank
)
)
[system] => Array
(
[ssid] => FRITZ!Box
[device_name] => AHOY-DTU
[version] => 0.5.41
[build] => dec333f
[ts_uptime] => 471455
[ts_now] => 1680104147
[ts_sunrise] => 1680066964
[ts_sunset] => 1680112471
[ts_sun_upd] => 1680044400
[wifi_rssi] => -26
[mac] => EC:FA:BC:41:3E:7C
[hostname] => AHOY-DTU
[pwd_set] => 1
[sdk] => 2.2.2-dev(38a443e)
[cpu_freq] => 80
[heap_free] => 12584
[sketch_total] => 2662400
[sketch_used] => 468
[core_version] => 3.0.2
[flash_size] => 4096
[heap_frag] => 1
[max_free_blk] => 12488
[reboot_reason] => Exception
[esp_type] => ESP8266
)
[inverter] => Array
(
[0] => Array
(
[name] => HM-1500 Dach1
[channels] => 4
[power_limit_read] => 100
[last_alarm] => Inverter start
[ts_last_success] => 1680104123
[ch] => Array
(
[0] => Array
(
[0] => 236.6
[1] => 0.77
[2] => 182.7
[3] => 49.97
[4] => 0.993
[5] => 30.3
[6] => 234.021
[7] => 1807
[8] => 192.4
[9] => 94.958
[10] => 21.8
)
[1] => Array
(
[0] => 34.8
[1] => 1.47
[2] => 51
[3] => 457
[4] => 61.816
[5] => 13.247
)
[2] => Array
(
[0] => 34.8
[1] => 1.46
[2] => 50.7
[3] => 478
[4] => 62.332
[5] => 13.169
)
[3] => Array
(
[0] => 35.1
[1] => 1.27
[2] => 44.6
[3] => 427
[4] => 54.126
[5] => 11.584
)
[4] => Array
(
[0] => 35.1
[1] => 1.31
[2] => 46.1
[3] => 445
[4] => 55.747
[5] => 11.974
)
)
[ch_names] => Array
(
[0] => AC
[1] => hinten 1
[2] => vorne 3
[3] => vorne 2
[4] => vorne 1
)
)
[1] => Array
(
[name] => HM-1500 Balkon
[channels] => 4
[power_limit_read] => 100
[last_alarm] => Inverter start
[ts_last_success] => 1680104093
[ch] => Array
(
[0] => Array
(
[0] => 235.6
[1] => 0.87
[2] => 205.8
[3] => 49.99
[4] => 0.994
[5] => 30.1
[6] => 284.323
[7] => 1733
[8] => 216.7
[9] => 94.97
[10] => 21.8
)
[1] => Array
(
[0] => 33.8
[1] => 1.36
[2] => 46
[3] => 420
[4] => 81.783
[5] => 11.948
)
[2] => Array
(
[0] => 33.8
[1] => 1.36
[2] => 45.8
[3] => 416
[4] => 84.592
[5] => 11.896
)
[3] => Array
(
[0] => 34
[1] => 1.85
[2] => 62.6
[3] => 450
[4] => 45.408
[5] => 16.26
)
[4] => Array
(
[0] => 34
[1] => 1.84
[2] => 62.3
[3] => 447
[4] => 72.54
[5] => 16.182
)
)
[ch_names] => Array
(
[0] => AC
[1] => sued west
[2] => sued ost
[3] => west nord
[4] => west sued
)
)
)
[refresh_interval] => 30
[ch0_fld_units] => Array
(
[0] => V
[1] => A
[2] => W
[3] => Hz
[4] =>
[5] => °C
[6] => kWh
[7] => Wh
[8] => W
[9] => %
[10] => var
)
[ch0_fld_names] => Array
(
[0] => U_AC
[1] => I_AC
[2] => P_AC
[3] => F_AC
[4] => PF_AC
[5] => Temp
[6] => YieldTotal
[7] => YieldDay
[8] => P_DC
[9] => Efficiency
[10] => Q_AC
)
[fld_units] => Array
(
[0] => V
[1] => A
[2] => W
[3] => Wh
[4] => kWh
[5] => %
)
[fld_names] => Array
(
[0] => U_DC
[1] => I_DC
[2] => P_DC
[3] => YieldDay
[4] => YieldTotal
[5] => Irradiation
)
)
Auslesen von einzelnen Daten zur Speicherung
Tagesertrag Inverter 0 [AC Wh]: 1807
Tagesertrag Inverter 0 Platte 1 [DC Wh]: 457
Tagesertrag Inverter 0 Platte 2 [DC Wh]: 478
Tagesertrag Inverter 0 Platte 3 [DC Wh]: 427
Tagesertrag Inverter 0 Platte 4 [DC Wh]: 445
Tagesertrag Inverter 1 [AC Wh]: 1733
Tagesertrag Inverter 1 Platte 1 [DC Wh]: 420
Tagesertrag Inverter 1 Platte 2 [DC Wh]: 416
Tagesertrag Inverter 1 Platte 3 [DC Wh]: 450
Tagesertrag Inverter 1 Platte 4 [DC Wh]: 447
Letzter Fehler: No error
Cloud zur Datenspeicherung der Hoymiles Wechselrichter
PHP Beispiel:
<?php
header("Content-Type: text/html; charset=utf-8");
// ##################### //
//$url="DIE-IP-DER-DTU/api/live";
//oder
$url="http://DYNDNS-Service:FreigegebenerPortImRouter/api/live";
$curl_session = curl_init();
curl_setopt($curl_session ,CURLOPT_URL, $url);
curl_setopt($curl_session, CURLOPT_HEADER, 0);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl_session);
curl_close($curl_session);
echo "<hr><b>Schnittstelle der ahoy-DTU (JSON)</b><br>".$result."";
$json_array = json_decode($result, true);
echo "<hr><b>Umwandlung der JSON-Daten in ein Array</b><br>";
print_r($json_array);
echo "<hr><b>Auslesen von einzelnen Daten zur Speicherung</b>";
//echo $json_array['menu']['name']['0'];
echo "<hr>";
echo "Tagesertrag Inverter 0 [AC Wh]: ";
echo $json_array['inverter']['0']['ch']['0']['7'];
echo "<br>Tagesertrag Inverter 0 Platte 1 [DC Wh]: ";
echo $json_array['inverter']['0']['ch']['1']['3'];
echo "<br>Tagesertrag Inverter 0 Platte 2 [DC Wh]: ";
echo $json_array['inverter']['0']['ch']['2']['3'];
echo "<br>Tagesertrag Inverter 0 Platte 3 [DC Wh]: ";
echo $json_array['inverter']['0']['ch']['3']['3'];
echo "<br>Tagesertrag Inverter 0 Platte 4 [DC Wh]: ";
echo $json_array['inverter']['0']['ch']['4']['3'];
echo "<hr>";
echo "Tagesertrag Inverter 1 [AC Wh]: ";
echo $json_array['inverter']['1']['ch']['0']['7'];
echo "<br>Tagesertrag Inverter 1 Platte 1 [DC Wh]: ";
echo $json_array['inverter']['1']['ch']['1']['3'];
echo "<br>Tagesertrag Inverter 1 Platte 2 [DC Wh]: ";
echo $json_array['inverter']['1']['ch']['2']['3'];
echo "<br>Tagesertrag Inverter 1 Platte 3 [DC Wh]: ";
echo $json_array['inverter']['1']['ch']['3']['3'];
echo "<br>Tagesertrag Inverter 1 Platte 4 [DC Wh]: ";
echo $json_array['inverter']['1']['ch']['4']['3'];
echo "<hr>";
echo "Letzter Fehler: " ,json_last_error_msg();
?>
Cloud zur Datenspeicherung der Hoymiles Wechselrichter