@@ -24,6 +24,20 @@ Hue Bridge Status: <span id="ophom_generalstatus" class="badge badge-danger" sty
24
24
</div >
25
25
</div >
26
26
27
+ <!-- ###### BRIDGE RE FIND ###### -->
28
+ <div id =" ophom_bridgeunreachable" style =" display : none ;" >
29
+ <h4 >Looking for the Bridge</h4 >
30
+ <p >Click on the button below to start searching for your Philips Hue Bridge</p >
31
+ <button id =" ophom_researchbridgebutton" type =" button" class =" btn" ><i class =" fa fa-search" ></i > Search my bridge</button >
32
+ <br /><br />
33
+ <span id =" ophom_researchbridgestatus" style =" display : none ;" ></span >
34
+ <br />
35
+ <div id =" ophom_bridgerefound" style =" display : none ;" >
36
+ <br />
37
+ <button id =" ophom_researchbridgesave" type =" button" class =" btn" ><i class =" fa fa-save" ></i > Apply new IP</button >
38
+ </div >
39
+ </div >
40
+
27
41
<!-- ###### BRIDGE CONFIGURATION ###### -->
28
42
<div id =" ophom_bridgenotconfigured" style =" display : none ;" >
29
43
<h4 >Bridge Configuration</h4 >
@@ -48,8 +62,6 @@ Hue Bridge Status: <span id="ophom_generalstatus" class="badge badge-danger" sty
48
62
49
63
<br />
50
64
<button id =" ophom_validplugselection" class =" btn" ><i class =" fa fa-save" ></i > Save Configuration</button >
51
-
52
-
53
65
</div >
54
66
55
67
<!-- #### AUTO OFF CONFIGURATION ####-->
@@ -260,6 +272,9 @@ Hue Bridge Status: <span id="ophom_generalstatus" class="badge badge-danger" sty
260
272
else if (data[' reponse' ] == 2 ) {
261
273
autOffConfiguration ();
262
274
}
275
+ else if (data[' reponse' ] == 3 ) {
276
+ refindBridge ();
277
+ }
263
278
})
264
279
});
265
280
@@ -377,6 +392,60 @@ Hue Bridge Status: <span id="ophom_generalstatus" class="badge badge-danger" sty
377
392
}
378
393
});
379
394
395
+ function refindBridge ()
396
+ {
397
+ general_status .innerHTML = " Bridge configured but unreachable" ;
398
+ general_status .style .backgroundColor = " rgb(17, 99, 255)" ;
399
+ document .getElementById (" ophom_bridgenotlinked" ).style .display = " none" ;
400
+ document .getElementById (" ophom_bridgenotconfigured" ).style .display = " none" ;
401
+ document .getElementById (" ophom_bridgeunreachable" ).style .display = " " ;
402
+
403
+ document .getElementById (" ophom_researchbridgebutton" ).addEventListener (' click' , function () {
404
+ var search_button = this
405
+ search_button .innerHTML = ' <i class="fa fa-search"></i> Searching...' ;
406
+ search_button .disabled = true ;
407
+ document .getElementById (" ophom_researchbridgestatus" ).style .display = " none" ;
408
+ document .getElementById (" ophom_bridgerefound" ).style .display = " none" ;
409
+
410
+ fetch (API_BASEURL + " plugin/ophom?action=discover" ).then (function (response ) {
411
+ response .json ().then (function (data ) {
412
+ console .log (data);
413
+ if (data .length == 0 )
414
+ {
415
+ search_button .innerHTML = ' <i class="fa fa-search"></i> Search my bridge' ;
416
+ search_button .disabled = false ;
417
+ document .getElementById (" ophom_researchbridgestatus" ).style .display = " " ;
418
+ document .getElementById (" ophom_researchbridgestatus" ).innerHTML = " <font color='red'>Unable to find your Hue Bridge. Are you on the same network ?</font>" ;
419
+ }
420
+ else
421
+ {
422
+ bridge_ip_address = data[0 ].internalipaddress ;
423
+ search_button .innerHTML = ' <i class="fa fa-search"></i> Search my bridge' ;
424
+ search_button .disabled = false ;
425
+ document .getElementById (" ophom_researchbridgestatus" ).style .display = " " ;
426
+ document .getElementById (" ophom_researchbridgestatus" ).innerHTML = " <font color='green'>Brige found (<i>" + data[0 ].internalipaddress + " </i>) !</font>" ;
427
+ document .getElementById (" ophom_bridgerefound" ).style .display = " " ;
428
+ }
429
+ });
430
+ });
431
+ });
432
+
433
+ document .getElementById (" ophom_researchbridgesave" ).addEventListener (' click' , function () {
434
+ fetch (API_BASEURL + " plugin/ophom" , {
435
+ method: " POST" ,
436
+ body : JSON .stringify ({command: " changeip" , ip: bridge_ip_address}),
437
+ headers: { ' Content-Type' : ' application/json' }
438
+ }).then (function (response ) {
439
+ response .json ().then (function (data ) {
440
+ if (data .reponse == " success" )
441
+ {
442
+ document .location .reload (true );
443
+ }
444
+ });
445
+ })
446
+ })
447
+ }
448
+
380
449
function autOffConfiguration ()
381
450
{
382
451
general_status .innerHTML = " Linked and Configured" ;
0 commit comments