Create array variable with device attributes

I would like to set a variable with an array, but with device attributes, like this:
[Luxury : Fav1Delay],[Luxury : Fav2Delay],[Luxury : Fav3Delay]
Its not working in the evaluated value and when I try to get index.
Thanks!

I finally gotcha, I just built it like this in expression: [Luxury : Fav1Delay]+","+[Luxury : Fav2Delay]+","+[Luxury : Fav3Delay]
Thanks

1 Like

Interesting. I'd be interested in seeing how you implement one of the items in the list.

I was looking for a way to loop over a list of shade devices, windows contact sensors, and "open" levels (like 88% for the office, so not fully open). I ended up using three different arrays and $index to grab the other info I needed.

My original thought was that I should be able to do something like:
[Office Shade, 88, Office Window Sensor], [Kitchen Shade, 100, Back Door Sensor]...
Then for each device set to second value or close only if the associated sensor is closed.

I couldn't figure it out so I just made three different lists. Devices, sensors, openLevels. My way works just fine, but I have to make sure my list definitions are in the same order, otherwise shades will open and close at levels meant for other windows. :slight_smile:

not sure to fully understand but I think if you add your array inside this braces {} it would works. Sometimes in variable you must use it. Try to create a variable and in expression, enter your array and it will evaluate it and you will see if it gives the right things!

2 Likes

It’s a while since I did anything like this, but think items in the array are sorted in alphabetical order, so you need a naming standard that preserves the order. I used values like kitchen-light & kitchen-sensor, rather than sensor-kitchen, light-kitchen.

Yeah, the devices are in alphabetical order just based on the device list. I just have to make sure my sensor list and open percentage list are in the same order. I can put those in the right order explicitly and use $index to pick the next value for each in the loop. It works. It just needs a little attention when adding or removing devices to make sure the other two lists line up.