Skip to content

Commit

Permalink
V 0.62
Browse files Browse the repository at this point in the history
renamed
BridgeGet to BridgeGetData
GroupGet to GroupsGetData
LightGet to LightsGetData
UsernameWhitelisted to BridgeUsernameWhitelisted
  • Loading branch information
ArndBrugman committed Mar 6, 2014
1 parent 6e7425c commit c24fa02
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
14 changes: 7 additions & 7 deletions HUEMediate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@

// look for bridge
// wait for BridgeName
// check if UsernameWhitelisted
// check if BridgeUsernameWhitelisted
// NO? -> whitelist
// play
function DiscoverBridgeAndTryWhitelisting()
{
if (!localStorage.HUEPIBridgeIP) { // No Cached BridgeIP?
$('#HUEStatus').text('Trying to Discover HUE Bridge via HUE Portal');
MyHue.PortalDiscoverLocalBridges().then(function GetBridgeConfig() {
MyHue.BridgeGet().then(function EnsureWhitelisting() {
MyHue.BridgeGetData().then(function EnsureWhitelisting() {
$('#HUEBridgeIP').text('Bridge IP: ' + MyHue.BridgeIP);
if (!MyHue.UsernameWhitelisted) {
if (!MyHue.BridgeUsernameWhitelisted) {
$('#HUEStatus').text('Please press connect button on the Hue Bridge');
MyHue.BridgeCreateUser().then(function ReReadBridgeConfiguration() {
return setTimeout(GetBridgeConfig, 1000);
Expand All @@ -154,8 +154,8 @@
{
MyHue.BridgeIP = localStorage.HUEPIBridgeIP;
$('#HUEBridgeIP').text('Cached Bridge IP: ' + MyHue.BridgeIP);
MyHue.BridgeGet().then(function CheckWhitelisting() {
if (MyHue.UsernameWhitelisted) {
MyHue.BridgeGetData().then(function CheckWhitelisting() {
if (MyHue.BridgeUsernameWhitelisted) {
return LightsOnAndStartHeartbeat();
}
});
Expand All @@ -175,7 +175,7 @@
}

function StatusHeartbeat() {
MyHue.BridgeGet().then(function UpdateUI() {
MyHue.BridgeGetData().then(function UpdateUI() {
$('#brightnessslider').val(MyHue.Lights[1].state.bri); // Get 1st light brightness for now...
$('#brightnessslider').slider('refresh');
setTimeout(StatusHeartbeat, 2500);
Expand Down Expand Up @@ -218,8 +218,8 @@

<div class='footer'>
<div data-role='controlgroup' data-type='horizontal' data-inline='true' data-mini='true' >
<a href='#' id='onbutton' data-role='button' data-icon='' data-inline='false' class='ui-btn ui-btn-d' data-mini='true' onclick='JavaScript:MyHue.GroupOn(0)'>All On</a>
<a href='#' id='offbutton' data-role='button' data-icon='' data-inline='false' class='ui-btn ui-btn-b' data-mini='true' onclick='JavaScript:MyHue.GroupOff(0)'>All Off</a>
<a href='#' id='onbutton' data-role='button' data-icon='' data-inline='false' class='ui-btn ui-btn-d' data-mini='true' onclick='JavaScript:MyHue.GroupOn(0)'>All On</a>
</div>
<div id='HUEInfoBar'>
<div id='HUEBridgeIP'>
Expand Down
23 changes: 15 additions & 8 deletions HUEPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ HUEPI = function() {

this.LocalBridges = [];

this.BridgeConfig = [];
this.BridgeIP = '';
this.BridgeConfig = [];
this.BridgeName = '';
this.UsernameWhitelisted = false; // Will be checked on Bridge in BridgeGet()
this.BridgeUsernameWhitelisted = false; // Will be checked on Bridge in BridgeGet()

this.Lights = [];
this.Groups = [];
Expand Down Expand Up @@ -53,7 +53,7 @@ HUEPI.prototype.PortalDiscoverLocalBridges = function()
* Bridge
*
*/
HUEPI.prototype.BridgeGet = function()
HUEPI.prototype.BridgeGetData = function()
{ // GET /api/username -> data.config.whitelist.username
var That = this;
var url = 'http://' + this.BridgeIP + '/api/' + this.Username;
Expand All @@ -66,8 +66,9 @@ HUEPI.prototype.BridgeGet = function()
if (That.BridgeConfig !== undefined) {
That.BridgeName = That.BridgeConfig.name;
// if able to read Config, Username must be Whitelisted
That.UsernameWhitelisted = true;
}
That.BridgeUsernameWhitelisted = true;
} else
That.BridgeUsernameWhitelisted = false;
});
};

Expand Down Expand Up @@ -432,7 +433,7 @@ HUEPI.Lightstate = function()
* Light
*
*/
HUEPI.prototype.LightGet = function()
HUEPI.prototype.LightsGetData = function()
{ // GET /api/username/lights
var That = this;
var url = 'http://' + this.BridgeIP + '/api/' + this.Username + '/lights';
Expand Down Expand Up @@ -627,7 +628,7 @@ HUEPI.prototype.LightEffectNone = function(LightNr, Transitiontime)
* Group
*
*/
HUEPI.prototype.GroupGet = function()
HUEPI.prototype.GroupsGetData = function()
{ // GET /api/username/lights
var That = this;
var url = 'http://' + this.BridgeIP + '/api/' + this.Username + '/groups';
Expand Down Expand Up @@ -914,5 +915,11 @@ HUEPI.prototype.GroupEffectNone = function(GroupNr, Transitiontime)
// LightSetCT = CT->RGB->XY to ignore Brightness in RGB
// changed " string to ' string
//
// 0.62
// renamed
// BridgeGet to BridgeGetData
// GroupGet to GroupsGetData
// LightGet to LightsGetData
// UsernameWhitelisted to BridgeUsernameWhitelisted
//
//
//

0 comments on commit c24fa02

Please sign in to comment.