mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
Fix entities Card toggle (#7192)
This commit is contained in:
parent
60969b0916
commit
47773e9cae
@ -204,7 +204,7 @@ class HuiEntitiesCard extends LitElement implements LovelaceCard {
|
||||
<hui-entities-toggle
|
||||
.hass=${this._hass}
|
||||
.entities=${(this._configEntities!.filter(
|
||||
(conf) => "type" in conf
|
||||
(conf) => !("type" in conf)
|
||||
) as EntityConfig[]).map((conf) => conf.entity)}
|
||||
></hui-entities-toggle>
|
||||
`}
|
||||
|
@ -3,9 +3,9 @@ import {
|
||||
CSSResult,
|
||||
customElement,
|
||||
html,
|
||||
internalProperty,
|
||||
LitElement,
|
||||
property,
|
||||
internalProperty,
|
||||
PropertyValues,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
@ -18,9 +18,9 @@ import { turnOnOffEntities } from "../common/entity/turn-on-off-entities";
|
||||
|
||||
@customElement("hui-entities-toggle")
|
||||
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[];
|
||||
|
||||
@ -36,7 +36,7 @@ class HuiEntitiesToggle extends LitElement {
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this._toggleEntities) {
|
||||
if (!this._toggleEntities?.length) {
|
||||
return html``;
|
||||
}
|
||||
|
||||
@ -45,11 +45,11 @@ class HuiEntitiesToggle extends LitElement {
|
||||
aria-label=${this.hass!.localize(
|
||||
"ui.panel.lovelace.card.entities.toggle"
|
||||
)}
|
||||
.checked="${this._toggleEntities!.some((entityId) => {
|
||||
.checked=${this._toggleEntities!.some((entityId) => {
|
||||
const stateObj = this.hass!.states[entityId];
|
||||
return stateObj && stateObj.state === "on";
|
||||
})}"
|
||||
@change="${this._callService}"
|
||||
})}
|
||||
@change=${this._callService}
|
||||
></ha-switch>
|
||||
`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user