mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Use switch for valve in entity row (#19342)
This commit is contained in:
parent
e8c1a34f3b
commit
a5630a4a7d
@ -129,6 +129,9 @@ export class HaEntityToggle extends LitElement {
|
|||||||
} else if (stateDomain === "cover") {
|
} else if (stateDomain === "cover") {
|
||||||
serviceDomain = "cover";
|
serviceDomain = "cover";
|
||||||
service = turnOn ? "open_cover" : "close_cover";
|
service = turnOn ? "open_cover" : "close_cover";
|
||||||
|
} else if (stateDomain === "valve") {
|
||||||
|
serviceDomain = "valve";
|
||||||
|
service = turnOn ? "open_valve" : "close_valve";
|
||||||
} else if (stateDomain === "group") {
|
} else if (stateDomain === "group") {
|
||||||
serviceDomain = "homeassistant";
|
serviceDomain = "homeassistant";
|
||||||
service = turnOn ? "turn_on" : "turn_off";
|
service = turnOn ? "turn_on" : "turn_off";
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
import {
|
import { LitElement, PropertyValues, html, nothing } from "lit";
|
||||||
css,
|
|
||||||
CSSResultGroup,
|
|
||||||
html,
|
|
||||||
LitElement,
|
|
||||||
PropertyValues,
|
|
||||||
nothing,
|
|
||||||
} from "lit";
|
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import "../../../components/ha-valve-controls";
|
import "../../../components/ha-valve-controls";
|
||||||
import { ValveEntity } from "../../../data/valve";
|
import { isUnavailableState } from "../../../data/entity";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||||
import "../components/hui-generic-entity-row";
|
import "../components/hui-generic-entity-row";
|
||||||
@ -37,7 +30,7 @@ class HuiValveEntityRow extends LitElement implements LovelaceRow {
|
|||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stateObj = this.hass.states[this._config.entity] as ValveEntity;
|
const stateObj = this.hass.states[this._config.entity];
|
||||||
|
|
||||||
if (!stateObj) {
|
if (!stateObj) {
|
||||||
return html`
|
return html`
|
||||||
@ -47,21 +40,30 @@ class HuiValveEntityRow extends LitElement implements LovelaceRow {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
const showToggle =
|
||||||
<hui-generic-entity-row .hass=${this.hass} .config=${this._config}>
|
stateObj.state === "open" ||
|
||||||
<ha-valve-controls
|
stateObj.state === "closed" ||
|
||||||
.hass=${this.hass}
|
isUnavailableState(stateObj.state);
|
||||||
.stateObj=${stateObj}
|
|
||||||
></ha-valve-controls>
|
|
||||||
</hui-generic-entity-row>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
return html`
|
||||||
return css`
|
<hui-generic-entity-row
|
||||||
ha-valve-controls {
|
.hass=${this.hass}
|
||||||
margin-right: -0.57em;
|
.config=${this._config}
|
||||||
}
|
.catchInteraction=${!showToggle}
|
||||||
|
>
|
||||||
|
${showToggle
|
||||||
|
? html`
|
||||||
|
<ha-entity-toggle
|
||||||
|
.hass=${this.hass}
|
||||||
|
.stateObj=${stateObj}
|
||||||
|
></ha-entity-toggle>
|
||||||
|
`
|
||||||
|
: html`
|
||||||
|
<div class="text-content">
|
||||||
|
${this.hass.formatEntityState(stateObj)}
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
|
</hui-generic-entity-row>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user