nachdem mir das Forum (speziell Baxxy & Tyfys) wiedermal prima geholfen hat, hier das fuer mich finale Ergebnis.
Ich hatte das universal JSON abfrage file gesehen, aber das war ziemlich maechtig und ich wollte meine simple Loesung kurz mit Euch teilen.
Was wollte ich machen?
Ich wollte die openWB morgens zw. 5-9 Uhr auf Sofortladen stellen (damit die Standheizung nicht den Akku vom Auto leerzieht, da ich zu 99% mit Min+PV lade)
Vorbereitung (CuXD und Variablen anlegen)
Ich frage die openWB per lokalem API ab ohne MQTT.
oWB Timestamp Zeichenkette Datum im Json:date
oWB Lade-Leistung Zahl Watt im Json:llgesamt
oWB Lademodus Werteliste sofort;Min+PV;PV;Stop;Standby im Json:ladestatusLP1
oWB Auto Werteliste abgesteckt;angesteckt im Json:plugstatLP1
Wer noch mehr braucht kann sich die Befehle aus der openWB API ziehen (google)
zum abfrage Script:
Code: Alles auswählen
! Daten von openwb holen
var url ="http://IP-der-openWB/openWB/web/api.php?get=all";
! Abfrage der openwb mit CUxD und Antwort in string schreiben
dom.GetObject("CUxD.CUX2801001:4.CMD_SETS").State("wget --no-check-certificate -q -O - '"#url#"'");
dom.GetObject("CUxD.CUX2801001:4.CMD_QUERY_RET").State(1);
string openwb_xml = dom.GetObject("CUxD.CUX2801001:4.CMD_RETS").State();
! Schlüsselwoerter im String finden und Daten in Systemvariablen schreiben
! Beispiel: Position plus 3 Stellen - plus 19 Stellen Wert
!oWB Timestamp Zeichenkette Datum im Json:date
string word = "date";
integer word_laenge = word.Length();
integer word_position = openwb_xml.Find(word);
string daten = openwb_xml.Substr((word_position + word_laenge +3), 19);
integer word_position = daten.Find(word);
daten = daten.Substr(0, (word_position -2));
dom.GetObject("oWB Timestamp").State(daten);
!oWB Lade-Leistung Zahl Watt im Json:pvw
string word = "llgesamt";
integer word_laenge = word.Length();
integer word_position = openwb_xml.Find(word);
string daten = openwb_xml.Substr((word_position + word_laenge +3), 10);
integer word_position = daten.Find(word);
daten = daten.Substr(0, (word_position -2));
real zahl = daten.ToFloat();
dom.GetObject("oWB Lade-Leistung").State(zahl);
!oWB Auto Werteliste abgesteckt;angesteckt im Json:plugstatLP1
string word = "plugstatLP1";
integer word_laenge = word.Length();
integer word_position = openwb_xml.Find(word);
string daten = openwb_xml.Substr((word_position + word_laenge +3), 1);
WriteLine(daten);
integer zahl = daten.ToInteger();
dom.GetObject("oWB Auto").State(zahl);
!oWB Lademodus Werteliste sofort;Min+PV;PV;Stop;Standby im Json:ladestatusLP1
string word = "lademodus";
integer word_laenge = word.Length();
integer word_position = openwb_xml.Find(word);
string daten = openwb_xml.Substr((word_position + word_laenge +3), 1);
integer zahl = daten.ToInteger();
dom.GetObject("oWB Lademodus").State(zahl);
Code: Alles auswählen
!MIN und PV
var url= "http://IP-der-openWB/openWB/web/api.php?lademodus=minundpv";
var cURL="LD_LIBRARY_PATH=/usr/local/addons/cuxd /usr/local/addons/cuxd/curl";
dom.GetObject("CUxD.CUX2801001:4.CMD_EXEC").State(cURL#" -X POST -H 'Content-Type: text/xml; charset=UTF-8' -d '' '"#url#"'");
!Sofort
var url= "http://IP-der-openWB/openWB/web/api.php?lademodus=jetzt";
var cURL="LD_LIBRARY_PATH=/usr/local/addons/cuxd /usr/local/addons/cuxd/curl";
dom.GetObject("CUxD.CUX2801001:4.CMD_EXEC").State(cURL#" -X POST -H 'Content-Type: text/xml; charset=UTF-8' -d '' '"#url#"'");
!Ueberschuss
var url= "http://IP-der-openWB/openWB/web/api.php?lademodus=pvuberschuss";
var cURL="LD_LIBRARY_PATH=/usr/local/addons/cuxd /usr/local/addons/cuxd/curl";
dom.GetObject("CUxD.CUX2801001:4.CMD_EXEC").State(cURL#" -X POST -H 'Content-Type: text/xml; charset=UTF-8' -d '' '"#url#"'");
!Standby
var url= "http://IP-der-openWB/openWB/web/api.php?lademodus=standby";
var cURL="LD_LIBRARY_PATH=/usr/local/addons/cuxd /usr/local/addons/cuxd/curl";
dom.GetObject("CUxD.CUX2801001:4.CMD_EXEC").State(cURL#" -X POST -H 'Content-Type: text/xml; charset=UTF-8' -d '' '"#url#"'");
!Stop
var url= "http://IP-der-openWB/openWB/web/api.php?lademodus=stop";
var cURL="LD_LIBRARY_PATH=/usr/local/addons/cuxd /usr/local/addons/cuxd/curl";
dom.GetObject("CUxD.CUX2801001:4.CMD_EXEC").State(cURL#" -X POST -H 'Content-Type: text/xml; charset=UTF-8' -d '' '"#url#"'");
Vielleicht kann´s ja noch jemand brauchen.
Gruss
N