Fehler bei SMA auslese Skript seit 4.0

Hallo zusammen ich habe seit dem Update auf Version 4.0 folgenden fehler und ich hoffe ihr könnt mir helfen;

Warning: bad lexical cast: source type value could not be interpreted as target in [Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Webbox auslesen] on line 64

das ganze passiert in dem SMA Ausleseskript was ich hier aus dem Forum habe. Alles wird genau richtig angezeigt nur die Tagesmenge an Kw/h nicht mehr.

Hier nochmal das ganze Skript:

<?

//IP der Webbox (SMA hat übrigends eine WebBox zu Demozwecken im Internet)
$webboxip = "192.168.178.181";
$timeout = 15;
include("JSON.ips.php");
$json = new Services_JSON();

//JSON Request im PHP Array Format (wird später umgewandelt durch die in PHP5 vvorhandene json_encode/decode Funktion)

$GetPlantOverView = array(
    'version'=>"1.0",
    'proc'=>"GetPlantOverview",
    'id'=>"1",
    'format'=>"JSON"
    );

$GetDevices = array(
    'version'=>"1.0",
    'proc'=>"GetDevices",
    'id'=>"1",
    'format'=>"JSON"
    );

//Wechselrichter Haus (Device Key 00b5:122c81df)
$device="00b5:122c81df";
$GetProcessDataWR1 = '{
"version": "1.0",
"proc": "GetProcessData",
"id": "1",
"format": "JSON",
"params":
{
"devices":
[
{
"key": "'.$device.'",
"channels": null
}
]
}
}';



//Aufruf der Funktion REQUEST mit GetPlantInfo
$requestarray = $GetPlantOverView;
request($webboxip,$requestarray);
//print_r($response);
$zustand=($response->result->overview[3]->value);
    SetValue(22930 /*[Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Anlagenzustand]*/, $zustand);

$meldung=($response->result->overview[4]->value);
    if ($meldung == "") $meldung="Keine Nachrichten.";
    SetValue(37869 /*[Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Anlagen-Nachricht]*/, $meldung);

$watt=($response->result->overview[0]->value);
if ($watt > 0 or GetValue(17692 /*[Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Leistung aktuell]*/)<>0)
{
    Setvalue (17692 /*[Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Leistung aktuell]*/, $watt);
}

$tagesertrag=(str_replace(".", ",", $response->result->overview[1]->value));
SetValue(10569 /*[Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Tagesertrag]*/, $tagesertrag);





// ANFANG FUNKTION DATEN AUS SUNNY WEBBOX ABRUFEN
function request($webboxip,$requestarray) {
   Global $timeout;
   Global $response;
    //codieren in JSON
    $request = json_encode($requestarray);

    // Hier der JSON request
    $request = 'RPC='.rawurlencode($request);

    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://".$webboxip."/rpc");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch, CURLOPT_HEADER , 0);
    curl_setopt($ch, CURLOPT_POST, 1 );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

    // Hier das Ergebnis
    $response = curl_exec ($ch);

    if (curl_errno($ch)) {
        $err=1;
         $errtext = curl_error($ch);
    }

    curl_close($ch);

    //Decodieren der Antwort
    $response = json_decode($response);
}

function request2($webboxip,$requestarray,$json) {

$request = $json->encode($requestarray);
$request = $requestarray;

// Hier der JSON request
$request = 'RPC='.rawurlencode($request);

$timeout=180;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$webboxip."/rpc");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,0);
curl_setopt($ch, CURLOPT_HEADER , 0);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);

// Hier das Ergebnis
$response = curl_exec ($ch);

if (curl_errno($ch)) {
    $err=1;
      $errtext = curl_error($ch);
}

curl_close($ch);

$response = $json->decode($response);

return($response);
}
function channels_data_all($webboxip,$device,$json)
{

$requestarray4 = '{
"version": "1.0",
"proc": "GetProcessData",
"id": "1",
"format": "JSON",
"params":
{
"devices":
[
{
"key": "'.$device.'",
"channels": null
}
]
}
}';

$response4 = request2($webboxip,$requestarray4,$json);

return($response4);
}
function channels_data($webboxip,$device,$value,$json)
{

$requestarray3 = '{
"version": "1.0",
"proc": "GetProcessData",
"id": "1",
"format": "JSON",
"params":
{
"devices":
[
{
"key": "'.$device.'",
"channels":
[
"'.$value.'"
]
}
]
}
}';

$response3 = request($webboxip,$requestarray3,$json);

return($response3);
}
function channels($webboxip,$device,$json)
{

$requestarray2 = '{
"version": "1.0",
"proc": "GetProcessDataChannels",
"id": "1",
"format": "JSON",
"params":
{
"device": "'.$device.'"
}
}';

$response2 = request($webboxip,$requestarray2,$json);

return($response2);
}

function getdevice($webboxip,$json)
{
$requestarray1 = '{
"version": "1.0",
"proc": "GetDevices",
"id": "1",
"format": "JSON"
}';

$response1 = request($webboxip,$requestarray1,$json);

return($response1);
}

function overview($webboxip,$json)
{
$requestarray0 = '{
"version": "1.0",
"proc": "GetPlantOverview",
"id": "1",
"format": "JSON"
}';


$response0 = request($webboxip,$requestarray0,$json);

return($response0);
}


// ====== ENDE FUNKTION DATEN AUS SUNNY WEBBOX ABRUFEN ======
//=========GEWINN VERLUST ERRECHNEN ========================





?>

Zeile 64 ist übrigens die hier:

SetValue(10569 /[Geräteverwaltung / Mobilansicht\Keller\Photovoltaik\SMA Wechselrichter\Tagesertrag]/, $tagesertrag);

Das klingt nach einem Fehler. Magst du mal den Inhalt von $tagesertrag hier posten??

paresy

Hallo paresy,

der Inhalt von $Tagesertrag ist einfach nur eine Gleitkommazahl , also z.b. 40,46 khw.

Oder was meinst du ?

Fehler gefunden und zum nächsten Update korrigiert.

paresy

Super :slight_smile:

Ich hoffe ich bekomme das Update mit,