From a3274b64290f129c954107d95fd2e377b5dfa7f0 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Sat, 11 Aug 2018 15:18:23 -0600 Subject: [PATCH] Added refresh function and AJAX/JSON data loader. --- www/where/index.php | 52 +++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/www/where/index.php b/www/where/index.php index 024d096..4c2fdca 100644 --- a/www/where/index.php +++ b/www/where/index.php @@ -1,17 +1,24 @@ array( - 'method' => 'GET', - 'header' => 'x-ha-access: nXa7LiR1PG' - ) - ); + if (isset($_GET["data"])): + $options = array( + 'http' => array( + 'method' => 'GET', + 'header' => 'x-ha-access: nXa7LiR1PG' + ) + ); - $context = stream_context_create($options); - $data = json_decode(file_get_contents("http://192.168.0.25:8123/api/states", false, $context), true); + $context = stream_context_create($options); + $data = json_decode(file_get_contents("http://192.168.0.25:8123/api/states", false, $context), true); - foreach($data as $item) { - $output[$item["entity_id"]] = $item; - } + foreach($data as $item) { + $output[$item["entity_id"]] = $item; + } + + header('Content-Type: application/json'); + echo json_encode($output['device_tracker.jasonsphone_jason']); + exit(); + + else: ?> @@ -33,25 +40,42 @@

Where tf is Jason?

-

+

Nobody Knows

+