das mit den "SV_..." Variablen betraf einen anderen Beitrag von mir (http://homematic-forum.de/forum/viewtop ... 50#p302617). Normalerweise achte ich schon darauf, dass die in vor übernommenen Skripten angesprochenen Variablen auch existieren bzw. richtig angepasst sind.
Sorry wenn ich hier noch mal nachhake, aber ich sehe den Wald vor lauter Bäumen nicht...
Ich nutze das Skript mit den Tmp-Variablen ohne "SC_...". Die SysVars stimmen mit den Skript Deklarationen überein. Die Wetter_heute_tempMin und ...Max Werte, die das Skript abholt stimmen auch. Das Skript funktioniert also teilweise.
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 = "a469b8ef5ce208cabee5f7f8b9c262f6";
! Hier der City Code
string tmpB = "DE0005842";
! 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);
}