How can I set the accordionList in a oh-list-card dynammicall?
I tried these variants without success
accordionList: =(items[props.item_hue].state == 'ON')
accordionList: '=(items[props.item_hue].state == "ON") ? "true" : "false"'
Interesting. I would have expected that first option to work. It appears that the child items in the list only check a basic true/false on the
accordionList value and don’t actually parse the expression. A simple test demonstrates this is true:
accordionList: 0 deactivates the accordion, but
accordionList: =0 activates it.
I don’t know your particualr use case, but, I think you may get a result closer to what you are expecting if you don’t try to modify the list card anyway but the individual item. The problem here is that even if you do set
accordionList to false, by having any accordion slot at all, the list item will still show the chevron on the right side (
accordionList just determines whether or not that item actually expands when the chevron is clicked). You can make the chevron disappear by adding a
noChevron: true parameter. But that still allows the item to expand when clicked.
I think the easier workaround to both of these is just to use two different list items widgets that are identical except that one has the accordion slot with all the accordion items and one does not. Then set
visible: =(items[props.item_hue].state == 'ON') for the accordion one and
visible: =!(items[props.item_hue].state == 'ON') for the other.