refactor: Align Phillips Hue to reworked device handling (#712)

* Align PhilipsHue (Classic)

* Minor Device corrections

* Have code working with Qt < 5.10

* Fixes on Hue Wizzard

* Fixes on Hue Wizzard

* Calculate Latchtime only for lights updated by hyperion

* Allow to disable restoring original light's state

* Fix - LightIDs / LightMap vectors were not cleared when reopening the device

* Reduce API Calls for state updates by consolidation
This commit is contained in:
LordGrey
2020-03-26 18:49:44 +01:00
committed by GitHub
parent 2739aec1e3
commit aaa4235cab
11 changed files with 1096 additions and 422 deletions

View File

@@ -567,23 +567,35 @@ function checkHueBridge(cb,hueUser){
timeout: 2000
})
.done( function( data, textStatus, jqXHR ) {
if(Array.isArray(data) && data[0].error && data[0].error.type == 4)
cb(true);
else if(Array.isArray(data) && data[0].error)
cb(false);
if( Array.isArray(data) && data[0].error)
{
if ( data[0].error.type == 3 || data[0].error.type == 4)
{
cb(true, usr);
}
else
{
cb(false);
}
}
else
cb(true);
{
cb(true, usr);
}
})
.fail( function( jqXHR, textStatus ) {
cb(false);
});
}
function checkUserResult(reply){
function checkUserResult(reply, usr){
if(reply)
{
$('#wiz_hue_usrstate').html("");
$('#wiz_hue_create_user').toggle(false);
$('#user').val(usr);
get_hue_lights();
}
else
@@ -640,17 +652,22 @@ function checkBridgeResult(reply){
function identHueId(id, off)
{
var on = true;
if(off !== true)
{
setTimeout(identHueId,1500,id,true);
var put_data = '{"on":true,"bri":254,"hue":47000,"sat":254}';
}
else
on = false;
{
var put_data = '{"on":false}';
}
$.ajax({
url: 'http://'+$('#ip').val()+'/api/'+$('#user').val()+'/lights/'+id+'/state',
type: 'PUT',
timeout: 2000,
data: ' {"on":'+on+', "sat":254, "bri":254,"hue":47000}'
data: put_data
})
}
@@ -686,7 +703,9 @@ function beginWizardHue()
//check if ip is empty/reachable/search for bridge
if(conf_editor.getEditor("root.specificOptions.output").getValue() == "")
{
getHueIPs();
}
else
{
var ip = conf_editor.getEditor("root.specificOptions.output").getValue();
@@ -719,6 +738,7 @@ function beginWizardHue()
}
}
var ledCount= Object.keys(lightIDs).length;
window.serverConfig.leds = hueLedConfig;
@@ -736,6 +756,7 @@ function beginWizardHue()
d.lightIds = finalLightIds;
d.username = $('#user').val();
d.type = "philipshue";
d.hardwareLedCount = ledCount;
d.transitiontime = 1;
d.switchOffOnBlack = true;
@@ -814,6 +835,7 @@ function get_hue_lights(){
for(var lightid in r)
{
$('.lidsb').append(createTableRow([lightid+' ('+r[lightid].name+')', '<select id="hue_'+lightid+'" class="hue_sel_watch form-control"><option value="disabled">'+$.i18n('wiz_hue_ids_disabled')+'</option><option value="top">'+$.i18n('conf_leds_layout_cl_top')+'</option><option value="bottom">'+$.i18n('conf_leds_layout_cl_bottom')+'</option><option value="left">'+$.i18n('conf_leds_layout_cl_left')+'</option><option value="right">'+$.i18n('conf_leds_layout_cl_right')+'</option><option value="entire">'+$.i18n('wiz_hue_ids_entire')+'</option></select>','<button class="btn btn-sm btn-primary" onClick=identHueId('+lightid+')>'+$.i18n('wiz_hue_blinkblue',lightid)+'</button>']));
}