mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Don't disable controls when state is unknown (#5687)
This commit is contained in:
parent
04a2ff7506
commit
fa8bd30e83
@ -12,7 +12,7 @@ import {
|
|||||||
import { STATES_OFF } from "../../common/const";
|
import { STATES_OFF } from "../../common/const";
|
||||||
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
import { computeStateDomain } from "../../common/entity/compute_state_domain";
|
||||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
import { UNAVAILABLE_STATES } from "../../data/entity";
|
import { UNAVAILABLE_STATES, UNAVAILABLE } from "../../data/entity";
|
||||||
import { forwardHaptic } from "../../data/haptics";
|
import { forwardHaptic } from "../../data/haptics";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import "../ha-switch";
|
import "../ha-switch";
|
||||||
@ -40,14 +40,14 @@ class HaEntityToggle extends LitElement {
|
|||||||
<paper-icon-button
|
<paper-icon-button
|
||||||
aria-label=${`Turn ${computeStateName(this.stateObj)} off`}
|
aria-label=${`Turn ${computeStateName(this.stateObj)} off`}
|
||||||
icon="hass:flash-off"
|
icon="hass:flash-off"
|
||||||
.disabled=${UNAVAILABLE_STATES.includes(this.stateObj.state)}
|
.disabled=${this.stateObj.state === UNAVAILABLE}
|
||||||
@click=${this._turnOff}
|
@click=${this._turnOff}
|
||||||
?state-active=${!this._isOn}
|
?state-active=${!this._isOn}
|
||||||
></paper-icon-button>
|
></paper-icon-button>
|
||||||
<paper-icon-button
|
<paper-icon-button
|
||||||
aria-label=${`Turn ${computeStateName(this.stateObj)} on`}
|
aria-label=${`Turn ${computeStateName(this.stateObj)} on`}
|
||||||
icon="hass:flash"
|
icon="hass:flash"
|
||||||
.disabled=${UNAVAILABLE_STATES.includes(this.stateObj.state)}
|
.disabled=${this.stateObj.state === UNAVAILABLE}
|
||||||
@click=${this._turnOn}
|
@click=${this._turnOn}
|
||||||
?state-active=${this._isOn}
|
?state-active=${this._isOn}
|
||||||
></paper-icon-button>
|
></paper-icon-button>
|
||||||
|
@ -2,7 +2,7 @@ import "@polymer/paper-icon-button/paper-icon-button";
|
|||||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||||
/* eslint-plugin-disable lit */
|
/* eslint-plugin-disable lit */
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
import { UNAVAILABLE_STATES } from "../data/entity";
|
import { UNAVAILABLE } from "../data/entity";
|
||||||
import CoverEntity from "../util/cover-model";
|
import CoverEntity from "../util/cover-model";
|
||||||
|
|
||||||
class HaCoverControls extends PolymerElement {
|
class HaCoverControls extends PolymerElement {
|
||||||
@ -30,6 +30,7 @@ class HaCoverControls extends PolymerElement {
|
|||||||
icon="hass:stop"
|
icon="hass:stop"
|
||||||
on-click="onStopTap"
|
on-click="onStopTap"
|
||||||
invisible$="[[!entityObj.supportsStop]]"
|
invisible$="[[!entityObj.supportsStop]]"
|
||||||
|
disabled="[[computStopDisabled(stateObj)]]"
|
||||||
></paper-icon-button>
|
></paper-icon-button>
|
||||||
<paper-icon-button
|
<paper-icon-button
|
||||||
aria-label="Close cover"
|
aria-label="Close cover"
|
||||||
@ -81,8 +82,15 @@ class HaCoverControls extends PolymerElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
computeStopDisabled(stateObj) {
|
||||||
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
computeOpenDisabled(stateObj, entityObj) {
|
computeOpenDisabled(stateObj, entityObj) {
|
||||||
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var assumedState = stateObj.attributes.assumed_state === true;
|
var assumedState = stateObj.attributes.assumed_state === true;
|
||||||
@ -90,7 +98,7 @@ class HaCoverControls extends PolymerElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeClosedDisabled(stateObj, entityObj) {
|
computeClosedDisabled(stateObj, entityObj) {
|
||||||
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var assumedState = stateObj.attributes.assumed_state === true;
|
var assumedState = stateObj.attributes.assumed_state === true;
|
||||||
|
@ -3,7 +3,7 @@ import "@polymer/paper-icon-button/paper-icon-button";
|
|||||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||||
/* eslint-plugin-disable lit */
|
/* eslint-plugin-disable lit */
|
||||||
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
import { PolymerElement } from "@polymer/polymer/polymer-element";
|
||||||
import { UNAVAILABLE_STATES } from "../data/entity";
|
import { UNAVAILABLE } from "../data/entity";
|
||||||
import CoverEntity from "../util/cover-model";
|
import CoverEntity from "../util/cover-model";
|
||||||
|
|
||||||
class HaCoverTiltControls extends PolymerElement {
|
class HaCoverTiltControls extends PolymerElement {
|
||||||
@ -31,6 +31,7 @@ class HaCoverTiltControls extends PolymerElement {
|
|||||||
icon="hass:stop"
|
icon="hass:stop"
|
||||||
on-click="onStopTiltTap"
|
on-click="onStopTiltTap"
|
||||||
invisible$="[[!entityObj.supportsStopTilt]]"
|
invisible$="[[!entityObj.supportsStopTilt]]"
|
||||||
|
disabled="[[computStopDisabled(stateObj)]]"
|
||||||
title="Stop tilt"
|
title="Stop tilt"
|
||||||
></paper-icon-button>
|
></paper-icon-button>
|
||||||
<paper-icon-button
|
<paper-icon-button
|
||||||
@ -63,8 +64,15 @@ class HaCoverTiltControls extends PolymerElement {
|
|||||||
return new CoverEntity(hass, stateObj);
|
return new CoverEntity(hass, stateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
computeStopDisabled(stateObj) {
|
||||||
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
computeOpenDisabled(stateObj, entityObj) {
|
computeOpenDisabled(stateObj, entityObj) {
|
||||||
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var assumedState = stateObj.attributes.assumed_state === true;
|
var assumedState = stateObj.attributes.assumed_state === true;
|
||||||
@ -72,7 +80,7 @@ class HaCoverTiltControls extends PolymerElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
computeClosedDisabled(stateObj, entityObj) {
|
computeClosedDisabled(stateObj, entityObj) {
|
||||||
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
|
if (stateObj.state === UNAVAILABLE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var assumedState = stateObj.attributes.assumed_state === true;
|
var assumedState = stateObj.attributes.assumed_state === true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user