I'm still struggling to figure out the color codes and the clear screen code doesn't work for me, but apart from that it works nicely. Here is the script in case anybody is interested. Obviously you need to change the queries to your own database, but its a starting point.
If anybody can get the clear screen code to work or figured out how to do the colours then let me know.
Code: Select all
<?
require_once( "lib/database.php" );
connect_sql();
echo chr(0x1); // goto home
echo chr(0x0); // this is not working so we do our own clear
for ( $c = 0; $c < 12; $c++ )
{
for ( $d = 0; $d < 10; $d++ )
echo chr(0x09);
}
echo chr(0x1); // goto home
echo " GeekHouse Dashboard ";
echo chr(0xD);
echo "Temperatures:";
echo chr(0xD);
echo chr(0x09).chr(0x09)."Cur".chr(0x09)."Min".chr(0x09)."Max".chr(0x0D);
// temp sensor outside
$sql = "SELECT value FROM `sensor_readings` where sensor_id='109D4EF800080050' ORDER BY `timestamp` DESC limit 0,1";
$result = mysql_query( $sql );
$data = mysql_fetch_row( $result );
echo "Outside: ".chr(0x09).$data[0]." C".chr(0x09);
$sql = "SELECT value FROM `sensor_readings` where sensor_id='109D4EF800080050' order by value ASC ";
$result = mysql_query( $sql );
$data = mysql_fetch_row( $result );
echo "".$data[0]." C".chr(0x09);
$sql = "SELECT value FROM `sensor_readings` where sensor_id='109D4EF800080050' order by value DESC limit 0,1";
$result = mysql_query( $sql );
$data = mysql_fetch_row( $result );
echo "".$data[0]." C".chr(0x09);
// temp sensor bedroom
$sql = "SELECT value FROM `sensor_readings` where sensor_id='1023983F00080039' ORDER BY `timestamp` DESC limit 0,1";
$result = mysql_query( $sql );
$data = mysql_fetch_row( $result );
echo "Bedroom: ".chr(0x09).$data[0]." C".chr(0x09);
$sql = "SELECT value FROM `sensor_readings` where sensor_id='1023983F00080039' order by value ASC limit 0,1";
$result = mysql_query( $sql );
$data = mysql_fetch_row( $result );
echo "".$data[0]." C".chr(0x09);
$sql = "SELECT value FROM `sensor_readings` where sensor_id='1023983F00080039' order by value DESC limit 0,1";
$result = mysql_query( $sql );
$data = mysql_fetch_row( $result );
echo "".$data[0]." C".chr(0x09);
?>