diff --git a/collapsable-cards.js b/collapsable-cards.js index 57873dd..d90bfcd 100644 --- a/collapsable-cards.js +++ b/collapsable-cards.js @@ -64,14 +64,17 @@ class VerticalStackInCard extends HTMLElement { styleTag.innerHTML = this.getStyles() card.appendChild(styleTag); - if ( - config.defaultOpen === 'contain-toggled' && - config.cards.filter((c) => this._hass.states[c.entity]?.state !== "off") - .length > 0 - ) { + if (config.defaultOpen === 'contain-toggled' && config.cards.filter((c) => this.checkActiveCard(c)).length > 0) { toggleButton.click(); } } + + checkActiveCard(card) { + const containers = ["grid", "vertical-stack", "horizontal-stack"]; + return containers.includes(card.type) + ? card.cards.filter((c) => this.checkActiveCard(c)).length > 0 + : this._hass.states[card.entity]?.state !== "off" + } createToggleButton() { const toggleButton = document.createElement('button');