@@ -22,7 +22,7 @@ var devSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk68
22
22
var devFTDI = [ 'apa102_ftdi' , 'sk6812_ftdi' , 'ws2812_ftdi' ] ;
23
23
var devRPiPWM = [ 'ws281x' ] ;
24
24
var devRPiGPIO = [ 'piblaster' ] ;
25
- var devNET = [ 'atmoorb' , 'cololight' , 'fadecandy' , 'philipshue' , 'nanoleaf' , 'razer' , 'tinkerforge' , 'tpm2net' , 'udpe131' , 'udpartnet' , 'udpddp' , 'udph801' , 'udpraw' , 'wled' , 'yeelight' ] ;
25
+ var devNET = [ 'atmoorb' , 'cololight' , 'fadecandy' , 'homeassistant' , ' philipshue', 'nanoleaf' , 'razer' , 'tinkerforge' , 'tpm2net' , 'udpe131' , 'udpartnet' , 'udpddp' , 'udph801' , 'udpraw' , 'wled' , 'yeelight' ] ;
26
26
var devSerial = [ 'adalight' , 'dmx' , 'atmo' , 'sedu' , 'tpm2' , 'karate' ] ;
27
27
var devHID = [ 'hyperionusbasp' , 'lightpack' , 'paintpack' , 'rawhid' ] ;
28
28
@@ -1100,6 +1100,7 @@ $(document).ready(function () {
1100
1100
switch ( ledType ) {
1101
1101
case "wled" :
1102
1102
case "cololight" :
1103
+ case "homeassistant" :
1103
1104
case "nanoleaf" :
1104
1105
showAllDeviceInputOptions ( "hostList" , false ) ;
1105
1106
case "apa102" :
@@ -1279,7 +1280,21 @@ $(document).ready(function () {
1279
1280
if ( hostList !== "SELECT" ) {
1280
1281
const host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
1281
1282
const token = conf_editor . getEditor ( "root.specificOptions.token" ) . getValue ( ) ;
1282
- if ( host !== "" && token !== "" ) {
1283
+ if ( host !== "" && token !== "" && entityIds ) {
1284
+ canIdentify = true ;
1285
+ canSave = true ;
1286
+ }
1287
+ }
1288
+ }
1289
+ break ;
1290
+
1291
+ case "homeassistant" : {
1292
+ const hostList = conf_editor . getEditor ( "root.specificOptions.hostList" ) . getValue ( ) ;
1293
+ if ( hostList !== "SELECT" ) {
1294
+ const host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
1295
+ const token = conf_editor . getEditor ( "root.specificOptions.token" ) . getValue ( ) ;
1296
+ const entityIds = conf_editor . getEditor ( "root.specificOptions.entityIds" ) . getValue ( ) ;
1297
+ if ( host !== "" && token !== "" && entityIds ) {
1283
1298
canIdentify = true ;
1284
1299
canSave = true ;
1285
1300
}
@@ -1387,6 +1402,16 @@ $(document).ready(function () {
1387
1402
getProperties_device ( ledType , host , params ) ;
1388
1403
break ;
1389
1404
1405
+ case "homeassistant" :
1406
+ var token = conf_editor . getEditor ( "root.specificOptions.token" ) . getValue ( ) ;
1407
+ if ( token === "" ) {
1408
+ return ;
1409
+ }
1410
+
1411
+ params = { host : host , token : token , filter : "states" } ;
1412
+ getProperties_device ( ledType , host , params ) ;
1413
+ break ;
1414
+
1390
1415
case "nanoleaf" :
1391
1416
$ ( '#btn_wiz_holder' ) . show ( ) ;
1392
1417
@@ -1552,6 +1577,14 @@ $(document).ready(function () {
1552
1577
1553
1578
var host = "" ;
1554
1579
switch ( ledType ) {
1580
+ case "homeassistant" :
1581
+ host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
1582
+ if ( host === "" ) {
1583
+ return
1584
+ }
1585
+ params = { host : host , token : token , filter : "states" } ;
1586
+ break ;
1587
+
1555
1588
case "nanoleaf" :
1556
1589
host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
1557
1590
if ( host === "" ) {
@@ -1654,6 +1687,16 @@ $(document).ready(function () {
1654
1687
default :
1655
1688
}
1656
1689
} ) ;
1690
+
1691
+ conf_editor . watch ( 'root.specificOptions.entityIds' , ( ) => {
1692
+ var entityIds = conf_editor . getEditor ( "root.specificOptions.entityIds" ) . getValue ( ) ;
1693
+ if ( entityIds . length > 0 ) {
1694
+ $ ( '#btn_test_controller' ) . prop ( 'disabled' , false ) ;
1695
+ } else {
1696
+ $ ( '#btn_test_controller' ) . prop ( 'disabled' , true ) ;
1697
+ }
1698
+ } ) ;
1699
+
1657
1700
} ) ;
1658
1701
1659
1702
//philipshueentertainment backward fix
@@ -1684,7 +1727,7 @@ $(document).ready(function () {
1684
1727
else if ( $ . inArray ( ledDevices [ idx ] , devHID ) != - 1 )
1685
1728
optArr [ 4 ] . push ( ledDevices [ idx ] ) ;
1686
1729
else if ( ledDevices [ idx ] . endsWith ( "_ftdi" ) ) {
1687
- var title = ledDevices [ idx ] . replace ( '_ftdi' , '' ) ;
1730
+ var title = ledDevices [ idx ] . replace ( '_ftdi' , '' ) ;
1688
1731
optArr [ 5 ] . push ( ledDevices [ idx ] + ":" + title ) ;
1689
1732
}
1690
1733
else
@@ -1744,6 +1787,13 @@ $(document).ready(function () {
1744
1787
params = { host : host } ;
1745
1788
break ;
1746
1789
1790
+ case "homeassistant" :
1791
+ var host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
1792
+ var token = conf_editor . getEditor ( "root.specificOptions.token" ) . getValue ( ) ;
1793
+ const entityIds = conf_editor . getEditor ( "root.specificOptions.entityIds" ) . getValue ( ) ;
1794
+ params = { host : host , token : token , entity_id : entityIds } ;
1795
+ break ;
1796
+
1747
1797
case "nanoleaf" :
1748
1798
var host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
1749
1799
var token = conf_editor . getEditor ( "root.specificOptions.token" ) . getValue ( ) ;
@@ -1878,6 +1928,7 @@ function saveLedConfig(genDefLayout = false) {
1878
1928
}
1879
1929
break ;
1880
1930
1931
+ case "homeassistant" :
1881
1932
case "nanoleaf" :
1882
1933
case "wled" :
1883
1934
case "yeelight" :
@@ -2311,6 +2362,12 @@ function updateElements(ledType, key) {
2311
2362
}
2312
2363
break ;
2313
2364
2365
+ case "homeassistant" :
2366
+ updateElementsHomeAssistant ( ledType , key ) ;
2367
+ hardwareLedCount = 1 ;
2368
+ conf_editor . getEditor ( "root.generalOptions.hardwareLedCount" ) . setValue ( hardwareLedCount ) ;
2369
+ break ;
2370
+
2314
2371
case "atmo" :
2315
2372
case "karate" :
2316
2373
var ledProperties = devicesProperties [ ledType ] [ key ] ;
@@ -2438,6 +2495,63 @@ function validateWledLedCount(hardwareLedCount) {
2438
2495
}
2439
2496
}
2440
2497
2498
+ function updateElementsHomeAssistant ( ledType , key ) {
2499
+
2500
+ // Get configured device's details
2501
+ var configuredDeviceType = window . serverConfig . device . type ;
2502
+ var configuredHost = window . serverConfig . device . host ;
2503
+ var host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
2504
+
2505
+ // New light selection list values
2506
+ var enumVals = [ ] ;
2507
+ var enumTitleVals = [ ] ;
2508
+ var enumDefaultVal = [ ] ;
2509
+
2510
+ if ( devicesProperties [ ledType ] && devicesProperties [ ledType ] [ key ] ) {
2511
+ var ledDeviceProperties = devicesProperties [ ledType ] [ key ] ;
2512
+
2513
+ if ( ! jQuery . isEmptyObject ( ledDeviceProperties ) ) {
2514
+ if ( ledDeviceProperties && ledDeviceProperties . lightEntities ) {
2515
+
2516
+
2517
+ for ( const light of ledDeviceProperties . lightEntities ) {
2518
+ enumVals . push ( light . entity_id ) ;
2519
+ enumTitleVals . push ( light . attributes . friendly_name ) ;
2520
+ }
2521
+
2522
+ }
2523
+ }
2524
+ }
2525
+
2526
+ // Select configured device
2527
+ if ( configuredDeviceType == ledType && configuredHost == host ) {
2528
+ let configuredEntityIds = window . serverConfig . device . entityIds ;
2529
+ for ( const light of configuredEntityIds ) {
2530
+ if ( $ . inArray ( enumVals , light ) != - 1 ) {
2531
+ enumVals . push ( light ) ;
2532
+ }
2533
+ enumDefaultVal . push ( light ) ;
2534
+ }
2535
+ }
2536
+
2537
+ if ( enumVals . length < 1 ) {
2538
+ enumVals . push ( "NONE" ) ;
2539
+ enumTitleVals . push ( $ . i18n ( 'edt_dev_spec_lights_discovered_none' ) ) ;
2540
+ }
2541
+ else {
2542
+ $ ( '#btn_wiz_holder' ) . show ( ) ;
2543
+ }
2544
+
2545
+
2546
+ let addSchemaElements = {
2547
+ "uniqueItems" : true ,
2548
+ "minItems" : 1 ,
2549
+ "required" : true
2550
+ } ;
2551
+
2552
+ updateJsonEditorMultiSelection ( conf_editor , 'root.specificOptions' , 'entityIds' , addSchemaElements , enumVals , enumTitleVals , enumDefaultVal ) ;
2553
+ }
2554
+
2441
2555
function updateElementsWled ( ledType , key ) {
2442
2556
2443
2557
// Get configured device's details
@@ -2533,6 +2647,7 @@ function updateElementsWled(ledType, key) {
2533
2647
}
2534
2648
showInputOptionForItem ( conf_editor , "root.specificOptions.segments" , "switchOffOtherSegments" , showAdditionalOptions ) ;
2535
2649
}
2650
+
2536
2651
function sortByPanelCoordinates ( arr , topToBottom , leftToRight ) {
2537
2652
arr . sort ( ( a , b ) => {
2538
2653
//Nanoleaf corodinates start at bottom left, therefore reverse topToBottom
@@ -2591,7 +2706,7 @@ function nanoleafGeneratelayout(panelLayout, panelOrderTopDown, panelOrderLeftRi
2591
2706
29 : { name : "4DLightstrip" , led : true , sideLengthX : 50 , sideLengthY : 50 } ,
2592
2707
30 : { name : "Skylight Panel" , led : true , sideLengthX : 180 , sideLengthY : 180 } ,
2593
2708
31 : { name : "SkylightControllerPrimary" , led : true , sideLengthX : 180 , sideLengthY : 180 } ,
2594
- 32 : { name : "SkylightControllerPassive" , led : true , sideLengthX : 180 , sideLengthY : 180 } ,
2709
+ 32 : { name : "SkylightControllerPassive" , led : true , sideLengthX : 180 , sideLengthY : 180 } ,
2595
2710
999 : { name : "Unknown" , led : true , sideLengthX : 100 , sideLengthY : 100 }
2596
2711
} ;
2597
2712
0 commit comments