ich habe die Vermutung, dass wetter.com bei mir doch noch funktioniert, und dass der Fehler irgendwo bei mir liegt. Denn wenn ich den Link im Skript mit meiner API, dem City Code und dem Projektnamen im IE ausführe, bekomme ich eine JSON Datei mit Werten!
In der JSON Datei steht:
Code: Alles auswählen
{"city":{"city_code":"DE00058xx","name":"mein Wohnort","url":"deutschland/mein Wohnort/DE00058xx.html","credit":{"info":"In order to use the free weather data from wetter.com you HAVE TO display at least two out of three of the following possibilities: text, link, logo","text":"Powered by wetter.com","link":"http:\/\/www.wetter.com","logo":"Download at http:\/\/www.wetter.com\/api\/downloads\/#logos"},"forecast":{"2017-07-27":{"p":"24","w":"2","tx":"20","tn":"13","d":"1501135200","06:00":{"p":"5","w":"60","tx":"15","tn":"13","d":"1501135200","w_txt":"leichter Regen"},"11:00":{"p":"6","w":"2","tx":"20","tn":"15","d":"1501153200","w_txt":"wolkig"},"17:00":{"p":"6","w":"81","tx":"19","tn":"16","d":"1501174800","w_txt":"Regen - Schauer"},"23:00":{"p":"6","w":"95","tx":"16","tn":"15","d":"1501196400","w_txt":"leichtes Gewitter"},"w_txt":"wolkig"}}}}
Hier mein Skript, dass alle 6 Stunden ausgeführt wird.
Code: Alles auswählen
! Idtittmar entwickelt
! von AndiN auf tmp-Variablen umgeschrieben v2.0.0 (Stand: 25.11.2015)
!-----------------------------------------------------------------------------
! Hier alle was man verändern kann/muss
! Voraussetzung: CUxD und ein Wetter.com Account
!-----------------------------------------------------------------------------
! Hier die MD5 Checksumme aus ProjektName APIKey CityCode eintragen
string tmpA = "xxx";
! Hier der City Code
string tmpB = "DE00058xx";
! Meine Projektnummer
string tmpC = "hm";
var tmpD = "CUxD.CUX2801001:10"; !CUxD Virtuelles Gerät
!Wetter heute Variablen-Namen (alles optional)
string tmpH = "Wetter_heute_zustand"; !Zahl 0 - 999
string tmpI = "Wetter_heute_tempMax"; !Zahl -50 - 50 °C
string tmpJ = "Wetter_heute_tempMin"; !Zahl -50 - 50 °C
string tmpK = "Wetter_heute_wind"; !Zahl 0 - 200 km/h
string tmpL = "Wetter_heute_zustand_txt"; !Zeichenkette
string tmpM = "Wetter_heute_regen"; !Logikwert
string tmpN = "Wetter_heute_regen_proz"; !Zahl 0 - 100 %
string tmpO = "Wetter_morgen_zustand"; !Zahl 0 - 999
string tmpS = "Wetter_morgen_tempMax"; !Zahl -50 - 50 °C
string tmpT = "Wetter_morgen_tempMin"; !Zahl -50 - 50 °C
string tmpU = "Wetter_morgen_wind"; !Zahl 0 - 200 km/h
string tmpV = "Wetter_morgen_zustand_txt"; !Zeichenkette
string tmpW = "Wetter_morgen_regen"; !Logikwert
string tmpX = "Wetter_morgen_regen_proz"; !Zahl 0 - 100 %
!-----------------------------------------------------------------------------
! Ab hier muss man nichts mehr beachten
!-----------------------------------------------------------------------------
string tmpE = "http://api.wetter.com/forecast/weather/city/" + tmpB +"/project/" + tmpC + "/cs/" + tmpA + "/output/json";
var stdout;
var tmpPosStart;
var tmpPosEnd;
var tmpL1;
var tmpF;
var tmpG;
var tmpY;
var tmpZ;
var tmpA1 = "\"23:00\"";
var tmpB1 = "},";
var tmpC1 = system.Date("%F");
var tmpK1= system.Date("%F ")#"00:00:00";
tmpK1 = tmpK1.ToTime().ToInteger() + 86400;
var tmpE1 = tmpK1.ToTime().Format("%F");
tmpK1 = tmpK1.ToTime().ToInteger() + 86400;
var tmpD1 = tmpK1.ToTime().Format("%F");
dom.GetObject(tmpD # ".CMD_SETS").State("wget -q -O - " # tmpE);
dom.GetObject(tmpD # ".CMD_QUERY_RET").State(1);
stdout = dom.GetObject(tmpD # ".CMD_RETS").State();
!-----------------------------------------------------------------------------
! Dekodierung der Umlaute
!-----------------------------------------------------------------------------
string tmpF1;
string tmpG1;
foreach(tmpG1, stdout.Split("Ã")){
tmpF1 = tmpF1+ tmpG1 + "";
}
stdout = tmpF1;
tmpF1 = "";
foreach(tmpG1, stdout.Split("¤")){
tmpF1 = tmpF1 + tmpG1 + "ä";
}
stdout = tmpF1;
tmpF1 = "";
foreach(tmpG1, stdout.Split("¶")){
tmpF1 = tmpF1 + tmpG1 + "ö";
}
stdout = tmpF1;
tmpF1 = "";
foreach(tmpG1, stdout.Split("¼")){
tmpF1 = tmpF1 + tmpG1 + "ü";
}
stdout = tmpF1;
tmpF1 = "";
!-----------------------------------------------------------------------------
! HEUTE
!-----------------------------------------------------------------------------
boolean tmpH1 = false;
tmpPosStart = "\"" + tmpC1 + "\":{";
tmpPosEnd = "\"" + tmpE1 + "\":{";
tmpF = stdout.Substr(stdout.Find(tmpPosStart), stdout.Find(tmpPosEnd));
!Wetterzustand
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
integer tmpE = tmpL1.ToInteger();
if(dom.GetObject(tmpH).IsTypeOf(OT_VARDP)){
dom.GetObject(tmpH).State(tmpE);
}
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
!Maximaltemperatur
if(dom.GetObject(tmpI).IsTypeOf(OT_VARDP)){
tmpG = "\"tx\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpI).State(tmpL1.ToInteger());
}
!Regenwahrscheinlichkeit
if(dom.GetObject(tmpN).IsTypeOf(OT_VARDP)){
tmpG = "\"pc\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpN).State(tmpL1.ToInteger());
}
!Wird überhaupt regnen
if(dom.GetObject(tmpM).IsTypeOf(OT_VARDP)){
if(!tmpH1){
var tmpJ1 = "\"06:00\"";
var tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
if(!tmpH1){
tmpJ1 = "\"11:00\"";
tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
if(!tmpH1){
tmpJ1 = "\"17:00\"";
tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
if(!tmpH1){
tmpJ1 = "\"23:00\"";
tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
}
}
}
}
dom.GetObject(tmpM).State(tmpH1);
}
tmpF = tmpF.Substr(tmpF .Find(tmpA1), tmpF.Length());
tmpF = tmpF.Substr(tmpF .Find(tmpB1), tmpF.Length());
!Minimaltemperatur
if(dom.GetObject(tmpJ).IsTypeOf(OT_VARDP)){
tmpG = "\"tn\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpJ).State(tmpL1.ToInteger());
}
!Windgeschwindigkeit
if(dom.GetObject(tmpK).IsTypeOf(OT_VARDP)){
tmpG = "\"ws\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpK).State(tmpL1.ToInteger());
}
!Wetterzustand Text
if(dom.GetObject(tmpL).IsTypeOf(OT_VARDP)){
tmpG = "\"w_txt\":\"";
tmpY = "\"},";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 20).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpL).State(tmpL1);
}
!-----------------------------------------------------------------------------
! MORGEN
!-----------------------------------------------------------------------------
tmpH1 = false;
tmpPosStart = "\"" + tmpE1 + "\":{";
tmpPosEnd = "\"" + tmpD1 + "\":{";
tmpF = stdout.Substr(stdout.Find(tmpPosStart), stdout.Find(tmpPosEnd));
!Wetterzustand
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
integer tmpE = tmpL1.ToInteger();
if(dom.GetObject(tmpO).IsTypeOf(OT_VARDP)){
dom.GetObject(tmpO).State(tmpE);
}
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
!Maximaltemperatur
if(dom.GetObject(tmpS).IsTypeOf(OT_VARDP)){
tmpG = "\"tx\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpS).State(tmpL1.ToInteger());
}
!Regenwahrscheinlichkeit
if(dom.GetObject(tmpX).IsTypeOf(OT_VARDP)){
tmpG = "\"pc\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpX).State(tmpL1.ToInteger());
}
!Wird überhaupt regnen
if(dom.GetObject(tmpW).IsTypeOf(OT_VARDP)){
if(!tmpH1){
var tmpJ1 = "\"06:00\"";
var tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
if(!tmpH1){
tmpJ1 = "\"11:00\"";
tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
if(!tmpH1){
tmpJ1 = "\"17:00\"";
tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
if(!tmpH1){
tmpJ1 = "\"23:00\"";
tmpI1 = tmpF.Substr(tmpF.Find(tmpJ1), tmpF.Length());
tmpG = "\"w\":\"";
tmpY = "\",";
tmpZ = tmpI1.Find(tmpG) + tmpG.Length();
tmpE = tmpI1.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0).ToInteger();
tmpH1 = ((tmpE > 5) && (tmpE < 10)) || (tmpE > 59);
}
}
}
}
dom.GetObject(tmpW).State(tmpH1);
}
tmpF = tmpF .Substr(tmpF .Find(tmpA1), tmpF.Length());
tmpF = tmpF .Substr(tmpF .Find(tmpB1), tmpF.Length());
!Minimaltemperatur
if(dom.GetObject(tmpT).IsTypeOf(OT_VARDP)){
tmpG = "\"tn\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpT).State(tmpL1.ToInteger());
}
!Windgeschwindigkeit
if(dom.GetObject(tmpU).IsTypeOf(OT_VARDP)){
tmpG = "\"ws\":\"";
tmpY = "\",";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 5).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpU).State(tmpL1.ToInteger());
}
!Wetterzustand Text
if(dom.GetObject(tmpV).IsTypeOf(OT_VARDP)){
tmpG = "\"w_txt\":\"";
tmpY = "\"},";
tmpZ = tmpF.Find(tmpG) + tmpG.Length();
tmpL1 = tmpF.Substr(tmpZ, 20).StrValueByIndex(tmpY, 0);
dom.GetObject(tmpV).State(tmpL1);
}