Servus @zoernert ,
offensichtlich hat sich etwas an den Rohdaten geändert.
Aktuell erhalte ich über „Tarifinfo“ keine Daten sondern Fehlermeldungen.
Missing
Notice: Trying to get property 'forecast' of non-object in C:\ProgramData\Symcon\scripts\27986.ips.php on line 57
Notice: Trying to access array offset on value of type null in C:\ProgramData\Symcon\scripts\27986.ips.php on line 57
Notice: Trying to get property 'forecast' of non-object in C:\ProgramData\Symcon\scripts\27986.ips.php on line 58
Notice: Trying to access array offset on value of type null in C:\ProgramData\Symcon\scripts\27986.ips.php on line 58
Notice: Trying to get property 'forecast' of non-object in C:\ProgramData\Symcon\scripts\27986.ips.php on line 59
Notice: Trying to access array offset on value of type null in C:\ProgramData\Symcon\scripts\27986.ips.php on line 59
Notice: Trying to get property 'forecast' of non-object in C:\ProgramData\Symcon\scripts\27986.ips.php on line 61
Warning: Invalid argument supplied for foreach() in C:\ProgramData\Symcon\scripts\27986.ips.php on line 61
Notice: Trying to get property 'epochtime' of non-object in C:\ProgramData\Symcon\scripts\27986.ips.php on line 68
Notice: Trying to get property 'epochtime' of non-object in C:\ProgramData\Symcon\scripts\27986.ips.php on line 71
FEHLER: Letzter Wert im Grünstromindex zu alt (1655830736 Sekunden)Abort Processing during exceed of maximal ErrorCount: Trying to get property 'epochtime' of non-object
Error in Script C:\ProgramData\Symcon\scripts\27986.ips.php on Line 40
Aktuell läuft folgendes Skript:
> <?
>
> /**
>
> Strompreis Abfrage für dynamische Tarife
>
> ============================================================================
>
> Dieses Script ruft die dynamischen Tarife von https://stromhaltig.de/
>
> durch Änderung der Abruffunktion "fetchSignal" kann allerdings auch jeder
>
> andere Anbieter von dynamischen Tarifen verwendet werden.
>
> Idee des Scripts ist es, zu zeigen, wie man Strompreise in einer
>
> Automatisierung verwenden kann, um Schaltzeiten zu optimieren.
>
> Selbstverstöndlich kann dieses Script auch für eigene Versuche getestet
>
> werden, auch wenn man selbst keinen dynamischen Stromtarif hat.
>
> Limitierungen:
>
> Signatur wird nicht geprüft! D.h. über die Tarifapi wird ein Angebot
>
> abgerufen, aber nicht geprüft ob dieses Angebot tatsächlich vom
>
> Stromanbieter stammt. Da wir bei https Abrufen vertrauen darauf, dass
>
> der Inhaber der Domain gültig ist, ist dies auch nicht zwingend notwendig
>
> Fragen und Anregungen:
>
> Bitte bei Fragen direkt an thorsten.zoerner@stromdao.com schreiben, oder
>
> per PM im Symcon-Forum Benutzername: zoernert
>
> */
>
> //neu eingerichtet 20.6.2022 17:09Uhr
>
> function setUpdateSchedule() {
>
> if(!IPS_GetEventIDByName("Verarbeite GSI",$_IPS['SELF'])) {
>
> $EreignisID=IPS_CreateEvent ( 1 );
>
> IPS_SetParent($EreignisID, $_IPS['SELF']);
>
> IPS_SetEventActive($EreignisID, true);
>
> IPS_SetName($EreignisID,"Verarbeite GSI");
>
> IPS_SetEventCyclic ($EreignisID, 0,0,0,0,3,1);
>
> }
>
> }
>
> function setSlots($indicator,$values) {
>
> SetValue(getVariableID($indicator." Zeitpunkt",3), date("d.m.y H:i",$values->epochtime));
>
> SetValue(getVariableID($indicator." Unix Time",1),$values->epochtime);
>
> SetValue(getVariableID($indicator." Grünstromindex",1),$values->eevalue);
>
> SetValue(getVariableID($indicator." Arbeitspreis (Cent)",2),$values->energyprice);
>
> SetValue(getVariableID($indicator." CO2 (EE)",1),$values->co2_g_oekostrom); //ergänzt 20.6.2022 17:15Uhr
>
> SetValue(getVariableID($indicator." Solar (EE)",1),$values->ensolar); //ergänzt 20.6.2022 17:15Uhr
>
> }
>
> function processSignal() {
>
> $signal=json_decode(GetValue(getVariableID("raw_signal",3)));
>
> if(!isset($signal->forecast)) {
>
> echo "Missing";
>
> print_r($signal);
>
> fetchSignal(GetValueString(getVariableID("Postleitzahl",3)));
>
> processSignal();
>
> }
>
> $ts=time();
>
> $current=$signal->forecast[0];
>
> $best=$signal->forecast[0];
>
> $worst=$signal->forecast[0];
>
> $i=0;
>
> foreach($signal->forecast as $o) {
>
> if($o->epochtime<$ts) { $current=$o; $i++; } else {
>
> if($o->eevalue>$best->eevalue) $best=$o;
>
> if($o->eevalue<$worst->eevalue) $worst=$o;
>
> }
>
> }
>
> if($i>6) fetchSignal(GetValueString(getVariableID("Postleitzahl",3)));
>
> if(time()<$current->epochtime+7200) {
>
> setSlots("Aktuell",$current);
>
> } else {
>
> echo "FEHLER: Letzter Wert im Grünstromindex zu alt (".(time()-($current->epochtime+7200))." Sekunden)";
>
> SetValue(getVariableID("Aktuell Zeitpunkt",3), "-");
>
> SetValue(getVariableID("Aktuell Unix Time",1),0);
>
> SetValue(getVariableID("Aktuell Grünstromindex",1),50);
>
> fetchSignal(GetValueString(getVariableID("Postleitzahl",3)));
>
> processSignal();
>
> }
>
> setSlots("Grün",$best);
>
> setSlots("Grau",$worst);
>
> }
>
> function fetchSignal($plz) {
>
> $signal_raw=file_get_contents("https://api.corrently.io/core/gsi?plz=".$plz);
>
> SetValueString(getVariableID("raw_signal",3),$signal_raw);
>
> }
>
> function getVariableID($name,$type) {
>
> $id=0;
>
> if(!IPS_GetObjectIDByName($name,$_IPS['SELF'])) {
>
> $id=IPS_CreateVariable($type);
>
> IPS_SetName($id,$name);
>
> IPS_SetParent($id,$_IPS["SELF"]);
>
> } else {
>
> $id=IPS_GetObjectIDByName($name,$_IPS['SELF']);
>
> }
>
> return $id;
>
> }
>
> // Generelle Aktualisierungs Logik
>
> $plz=GetValueString(getVariableID("Postleitzahl",3));
>
> if(strlen($plz)!=5) {
>
> $plz="83352";
>
> SetValueString(getVariableID("Postleitzahl",3),$plz);
>
> }
>
> setUpdateSchedule();
>
> processSignal();
>
> ?>