array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Authorization: Basic " . base64_encode("$smartmeUserName:$smartmePassword") ) ); $context = stream_context_create($opts); // Open the file using the HTTP headers set above $smartme_output = file_get_contents($smartmeQuery, false, $context); $response = json_decode($smartme_output, true); $powerstate = $response[0]['SwitchOn']; echo "Last updated: " . date('Y-m-d H:i:s', strtotime($response[0]['ValueDate'])) . "

"; echo "Name: " . $response[0]['Name'] . "
"; echo "Zählerstand komplett: " . $response[0]['CounterReading'] . " " . $response[0]['CounterReadingUnit'] . "

"; //echo "SwitchOn: " . $response[0]['SwitchOn'] . "
"; echo "

Aktuelle Daten

"; echo "Leistung: " . $response[0]['ActivePower'] . " " . $response[0]['ActivePowerUnit'] . "
"; echo "Spannung: " . $response[0]['Voltage'] . " V
"; echo "Strom: " . $response[0]['Current'] . " A
"; echo "Leistungsfaktor: " . $response[0]['PowerFactor'] . "
"; //echo "Active Power Unit: " . $response[0]['ActivePowerUnit'] . "
"; //echo "Counter Reading Unit: " . $response[0]['CounterReadingUnit'] . "
"; //echo "Counter Reading Import: " . $response[0]['CounterReadingImport'] . "
"; echo "Temperatur: " . $response[0]['Temperature'] . " °C
"; echo "
"; if ($powerstate == "1"){ echo "
Power ON
"; } else { echo "
Power OFF
"; } //var_dump($response[0]);?>