mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Fix entities Card toggle (#7192)
This commit is contained in:
parent
bfb5ee794e
commit
93d1b9a2d5
@ -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>
|
||||||
`}
|
`}
|
||||||
|
@ -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>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user