Fix entities Card toggle (#7192)

This commit is contained in:
Zack Barett 2020-10-02 03:12:55 -05:00 committed by GitHub
parent bfb5ee794e
commit 93d1b9a2d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -204,7 +204,7 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
<hui-entities-toggle <hui-entities-toggle
.hass=${this._hass} .hass=${this._hass}
.entities=${(this._configEntities!.filter( .entities=${(this._configEntities!.filter(
(conf) => "type" in conf (conf) => !("type" in conf)
) as EntityConfig[]).map((conf) => conf.entity)} ) as EntityConfig[]).map((conf) => conf.entity)}
></hui-entities-toggle> ></hui-entities-toggle>
`} `}

View File

@ -3,9 +3,9 @@ import {
CSSResult, CSSResult,
customElement, customElement,
html, html,
internalProperty,
LitElement, LitElement,
property, property,
internalProperty,
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
} from "lit-element"; } from "lit-element";
@ -18,9 +18,9 @@ import { turnOnOffEntities } from "../common/entity/turn-on-off-entities";
@customElement("hui-entities-toggle") @customElement("hui-entities-toggle")
class HuiEntitiesToggle extends LitElement { class HuiEntitiesToggle extends LitElement {
@property() public entities?: string[]; @property({ type: Array }) public entities?: string[];
@property() protected hass?: HomeAssistant; @property({ attribute: false }) protected hass?: HomeAssistant;
@internalProperty() private _toggleEntities?: string[]; @internalProperty() private _toggleEntities?: string[];
@ -36,7 +36,7 @@ class HuiEntitiesToggle extends LitElement {
} }
protected render(): TemplateResult { protected render(): TemplateResult {
if (!this._toggleEntities) { if (!this._toggleEntities?.length) {
return html``; return html``;
} }
@ -45,11 +45,11 @@ class HuiEntitiesToggle extends LitElement {
aria-label=${this.hass!.localize( aria-label=${this.hass!.localize(
"ui.panel.lovelace.card.entities.toggle" "ui.panel.lovelace.card.entities.toggle"
)} )}
.checked="${this._toggleEntities!.some((entityId) => { .checked=${this._toggleEntities!.some((entityId) => {
const stateObj = this.hass!.states[entityId]; const stateObj = this.hass!.states[entityId];
return stateObj && stateObj.state === "on"; return stateObj && stateObj.state === "on";
})}" })}
@change="${this._callService}" @change=${this._callService}
></ha-switch> ></ha-switch>
`; `;
} }