Skip to content

Commit

Permalink
Added stub page for getting device/room information
Browse files Browse the repository at this point in the history
  • Loading branch information
bren1818 committed Aug 16, 2016
1 parent d6abbb4 commit d594933
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Binary file added images/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

foreach($DATA as $room){
echo '<div class="roomContainer" data-room-id="'. $room["rid"].'">';
echo '<h3>'.$room["name"].'</h3>';
echo '<h3>'.$room["name"].' <a href="info.php?rid='.$room["rid"].'"><img src="/images/info.png"/></a></h3>';

$DEVICES = array();

Expand Down Expand Up @@ -87,7 +87,7 @@
echo '<div class="'.( (isset($device['offline']) && $device['offline'] == 1) ? 'unplugged' : 'plugged' ).' device '.($device['state'] == 1 ? 'light-on' : 'light-off' ).' '.($device['prodtype'] == 'Light Fixture' ? 'light-fixture' : '' ).'" data-device-id="'.$device['did'].'">'; //power > 0 then enabled
//level = brightness
//state = on or off
echo '<p>'.$device['name'].'</p>';
echo '<p>'.$device['name'].' <a href="info.php?did='.$device['did'].'"><img src="/images/info.png"/></a></p>';
echo '<button data-device-id="'.$device['did'].'" class="onOffDeviceToggleButton buttonOn">On</button> | <button data-device-id="'.$device['did'].'" class="onOffDeviceToggleButton buttonOff">Off</button>';
echo '<div class="clear"></div>';
echo '<p>Brightness:</p>';
Expand Down
38 changes: 38 additions & 0 deletions info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/*
*
* TCP Ligthing Web UI Test Script - By Brendon Irwin
*
*/

include "include.php";

if( isset($_REQUEST['did']) && $_REQUEST['did'] != "" ){
$did = $_REQUEST['did'];
echo '<h2>Device Info</h2>';
echo '<p><b>Device ID:'.$did.'</b></p>';
$CMD = "cmd=DeviceGetInfo&data=<gip><version>1</version><token>".TOKEN."</token><did>".$did."</did><fields>name,power,product,class,image,control,realtype,other,status</fields></gip>";

$result = getCurlReturn($CMD);
$array = xmlToArray($result);
if( isset( $array["image"] ) && ! is_array( $array["image"]) ){
echo '<p><img src="data:image/png;base64,'.$array["image"].'" /></p>';
}

pa( $array );

}

if( isset($_REQUEST['rid']) && $_REQUEST['rid'] != "" ){
$rid = $_REQUEST['rid'];
echo '<h2>Room Information</h2>';
echo '<p><b>Room ID:'.$rid.'</b></p>';

$CMD = "cmd=RoomGetInfoAll&data=<gip><version>1</version><token>".TOKEN."</token><rid>".$rid."</rid><fields>name,power,product,class,image,imageurl,control,other</fields></gip>";

$result = getCurlReturn($CMD);
$array = xmlToArray($result);

pa( $array );
}
?>

0 comments on commit d594933

Please sign in to comment.