Skip to content

Instantly share code, notes, and snippets.

@cdrum
Last active August 29, 2015 14:08
Show Gist options
  • Save cdrum/1f81302c701af78b2b51 to your computer and use it in GitHub Desktop.
Save cdrum/1f81302c701af78b2b51 to your computer and use it in GitHub Desktop.
Simple script to check status of lifx bulbs using ruby http api, and display count and last check time
?php
$now = date("r");
// Change these settings to match your environment
const RESTAPI_URL = "http://192.168.1.221:56780";
$result = json_decode(file_get_contents(RESTAPI_URL . "/lights.json"));
if ($result) {
$number_bulbs = count($result);
} else {
$number_bulbs = "ERROR";
}
?>
<html>
<head>
<style>
.container {
background-color: #000000;
text-align: center;
}
.lifx-bulb-count {
color: crimson;
font-size: 80px;
}
.update-time {
color: white;
}
.title {
color: white;
font-size: 30px;
}
</style>
</head>
<body class="container">
<div class="title">LIFX Bulbs Status</div>
<div class="lifx-bulb-count"><?=$number_bulbs?></div>
<div class="update-time">Last Checked:<br /><?=$now?></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment