@@ -567,23 +567,35 @@ function checkHueBridge(cb,hueUser){
567567 timeout : 2000
568568 } )
569569 . done ( function ( data , textStatus , jqXHR ) {
570- if ( Array . isArray ( data ) && data [ 0 ] . error && data [ 0 ] . error . type == 4 )
571- cb ( true ) ;
572- else if ( Array . isArray ( data ) && data [ 0 ] . error )
573- cb ( false ) ;
570+ if ( Array . isArray ( data ) && data [ 0 ] . error )
571+ {
572+ if ( data [ 0 ] . error . type == 3 || data [ 0 ] . error . type == 4 )
573+ {
574+ cb ( true , usr ) ;
575+ }
576+ else
577+ {
578+ cb ( false ) ;
579+ }
580+ }
574581 else
575- cb ( true ) ;
582+ {
583+ cb ( true , usr ) ;
584+ }
585+
576586 } )
577587 . fail ( function ( jqXHR , textStatus ) {
578588 cb ( false ) ;
579589 } ) ;
580590}
581591
582- function checkUserResult ( reply ) {
592+ function checkUserResult ( reply , usr ) {
593+
583594 if ( reply )
584595 {
585596 $ ( '#wiz_hue_usrstate' ) . html ( "" ) ;
586597 $ ( '#wiz_hue_create_user' ) . toggle ( false ) ;
598+ $ ( '#user' ) . val ( usr ) ;
587599 get_hue_lights ( ) ;
588600 }
589601 else
@@ -640,17 +652,22 @@ function checkBridgeResult(reply){
640652
641653function identHueId ( id , off )
642654{
643- var on = true ;
644655 if ( off !== true )
656+ {
645657 setTimeout ( identHueId , 1500 , id , true ) ;
658+ var put_data = '{"on":true,"bri":254,"hue":47000,"sat":254}' ;
659+ }
646660 else
647- on = false ;
661+ {
662+ var put_data = '{"on":false}' ;
663+ }
648664
649665 $ . ajax ( {
650666 url : 'http://' + $ ( '#ip' ) . val ( ) + '/api/' + $ ( '#user' ) . val ( ) + '/lights/' + id + '/state' ,
651667 type : 'PUT' ,
652668 timeout : 2000 ,
653- data : ' {"on":' + on + ', "sat":254, "bri":254,"hue":47000}'
669+
670+ data : put_data
654671 } )
655672}
656673
@@ -686,7 +703,9 @@ function beginWizardHue()
686703
687704 //check if ip is empty/reachable/search for bridge
688705 if ( conf_editor . getEditor ( "root.specificOptions.output" ) . getValue ( ) == "" )
706+ {
689707 getHueIPs ( ) ;
708+ }
690709 else
691710 {
692711 var ip = conf_editor . getEditor ( "root.specificOptions.output" ) . getValue ( ) ;
@@ -719,6 +738,7 @@ function beginWizardHue()
719738 }
720739 }
721740
741+ var ledCount = Object . keys ( lightIDs ) . length ;
722742
723743 window . serverConfig . leds = hueLedConfig ;
724744
@@ -736,6 +756,7 @@ function beginWizardHue()
736756 d . lightIds = finalLightIds ;
737757 d . username = $ ( '#user' ) . val ( ) ;
738758 d . type = "philipshue" ;
759+ d . hardwareLedCount = ledCount ;
739760 d . transitiontime = 1 ;
740761 d . switchOffOnBlack = true ;
741762
@@ -814,6 +835,7 @@ function get_hue_lights(){
814835
815836 for ( var lightid in r )
816837 {
838+
817839 $ ( '.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>' ] ) ) ;
818840 }
819841
0 commit comments