@@ -22,7 +22,7 @@ var devSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk68
2222var devFTDI = [ 'apa102_ftdi' , 'sk6812_ftdi' , 'ws2812_ftdi' ] ;
2323var devRPiPWM = [ 'ws281x' ] ;
2424var 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' ] ;
2626var devSerial = [ 'adalight' , 'dmx' , 'atmo' , 'sedu' , 'tpm2' , 'karate' ] ;
2727var devHID = [ 'hyperionusbasp' , 'lightpack' , 'paintpack' , 'rawhid' ] ;
2828
@@ -1100,6 +1100,7 @@ $(document).ready(function () {
11001100 switch ( ledType ) {
11011101 case "wled" :
11021102 case "cololight" :
1103+ case "homeassistant" :
11031104 case "nanoleaf" :
11041105 showAllDeviceInputOptions ( "hostList" , false ) ;
11051106 case "apa102" :
@@ -1279,7 +1280,21 @@ $(document).ready(function () {
12791280 if ( hostList !== "SELECT" ) {
12801281 const host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
12811282 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 ) {
12831298 canIdentify = true ;
12841299 canSave = true ;
12851300 }
@@ -1387,6 +1402,16 @@ $(document).ready(function () {
13871402 getProperties_device ( ledType , host , params ) ;
13881403 break ;
13891404
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+
13901415 case "nanoleaf" :
13911416 $ ( '#btn_wiz_holder' ) . show ( ) ;
13921417
@@ -1552,6 +1577,14 @@ $(document).ready(function () {
15521577
15531578 var host = "" ;
15541579 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+
15551588 case "nanoleaf" :
15561589 host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
15571590 if ( host === "" ) {
@@ -1654,6 +1687,16 @@ $(document).ready(function () {
16541687 default :
16551688 }
16561689 } ) ;
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+
16571700 } ) ;
16581701
16591702 //philipshueentertainment backward fix
@@ -1684,7 +1727,7 @@ $(document).ready(function () {
16841727 else if ( $ . inArray ( ledDevices [ idx ] , devHID ) != - 1 )
16851728 optArr [ 4 ] . push ( ledDevices [ idx ] ) ;
16861729 else if ( ledDevices [ idx ] . endsWith ( "_ftdi" ) ) {
1687- var title = ledDevices [ idx ] . replace ( '_ftdi' , '' ) ;
1730+ var title = ledDevices [ idx ] . replace ( '_ftdi' , '' ) ;
16881731 optArr [ 5 ] . push ( ledDevices [ idx ] + ":" + title ) ;
16891732 }
16901733 else
@@ -1744,6 +1787,13 @@ $(document).ready(function () {
17441787 params = { host : host } ;
17451788 break ;
17461789
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+
17471797 case "nanoleaf" :
17481798 var host = conf_editor . getEditor ( "root.specificOptions.host" ) . getValue ( ) ;
17491799 var token = conf_editor . getEditor ( "root.specificOptions.token" ) . getValue ( ) ;
@@ -1878,6 +1928,7 @@ function saveLedConfig(genDefLayout = false) {
18781928 }
18791929 break ;
18801930
1931+ case "homeassistant" :
18811932 case "nanoleaf" :
18821933 case "wled" :
18831934 case "yeelight" :
@@ -2311,6 +2362,12 @@ function updateElements(ledType, key) {
23112362 }
23122363 break ;
23132364
2365+ case "homeassistant" :
2366+ updateElementsHomeAssistant ( ledType , key ) ;
2367+ hardwareLedCount = 1 ;
2368+ conf_editor . getEditor ( "root.generalOptions.hardwareLedCount" ) . setValue ( hardwareLedCount ) ;
2369+ break ;
2370+
23142371 case "atmo" :
23152372 case "karate" :
23162373 var ledProperties = devicesProperties [ ledType ] [ key ] ;
@@ -2438,6 +2495,63 @@ function validateWledLedCount(hardwareLedCount) {
24382495 }
24392496}
24402497
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+
24412555function updateElementsWled ( ledType , key ) {
24422556
24432557 // Get configured device's details
@@ -2533,6 +2647,7 @@ function updateElementsWled(ledType, key) {
25332647 }
25342648 showInputOptionForItem ( conf_editor , "root.specificOptions.segments" , "switchOffOtherSegments" , showAdditionalOptions ) ;
25352649}
2650+
25362651function sortByPanelCoordinates ( arr , topToBottom , leftToRight ) {
25372652 arr . sort ( ( a , b ) => {
25382653 //Nanoleaf corodinates start at bottom left, therefore reverse topToBottom
@@ -2591,7 +2706,7 @@ function nanoleafGeneratelayout(panelLayout, panelOrderTopDown, panelOrderLeftRi
25912706 29 : { name : "4DLightstrip" , led : true , sideLengthX : 50 , sideLengthY : 50 } ,
25922707 30 : { name : "Skylight Panel" , led : true , sideLengthX : 180 , sideLengthY : 180 } ,
25932708 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 } ,
25952710 999 : { name : "Unknown" , led : true , sideLengthX : 100 , sideLengthY : 100 }
25962711 } ;
25972712
0 commit comments