diff --git a/get_smartme.php b/get_smartme.php new file mode 100644 index 0000000..0056987 --- /dev/null +++ b/get_smartme.php @@ -0,0 +1,46 @@ +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]);?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..ae54b7a --- /dev/null +++ b/index.php @@ -0,0 +1,38 @@ + + + smart-me metrics by m.reber + + + + +

Power stats

+ +
+ + + + + + \ No newline at end of file