Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/entity/ha-entity-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { STATES_OFF } from "../../common/const";
import { computeStateDomain } from "../../common/entity/compute_state_domain";
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 { HomeAssistant } from "../../types";
import "../ha-switch";
Expand Down Expand Up @@ -40,14 +40,14 @@ class HaEntityToggle extends LitElement {
<paper-icon-button
aria-label=${`Turn ${computeStateName(this.stateObj)} off`}
icon="hass:flash-off"
.disabled=${UNAVAILABLE_STATES.includes(this.stateObj.state)}
.disabled=${this.stateObj.state === UNAVAILABLE}
@click=${this._turnOff}
?state-active=${!this._isOn}
></paper-icon-button>
<paper-icon-button
aria-label=${`Turn ${computeStateName(this.stateObj)} on`}
icon="hass:flash"
.disabled=${UNAVAILABLE_STATES.includes(this.stateObj.state)}
.disabled=${this.stateObj.state === UNAVAILABLE}
@click=${this._turnOn}
?state-active=${this._isOn}
></paper-icon-button>
Expand Down
14 changes: 11 additions & 3 deletions src/components/ha-cover-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "@polymer/paper-icon-button/paper-icon-button";
import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import { UNAVAILABLE_STATES } from "../data/entity";
import { UNAVAILABLE } from "../data/entity";
import CoverEntity from "../util/cover-model";

class HaCoverControls extends PolymerElement {
Expand Down Expand Up @@ -30,6 +30,7 @@ class HaCoverControls extends PolymerElement {
icon="hass:stop"
on-click="onStopTap"
invisible$="[[!entityObj.supportsStop]]"
disabled="[[computStopDisabled(stateObj)]]"
></paper-icon-button>
<paper-icon-button
aria-label="Close cover"
Expand Down Expand Up @@ -81,16 +82,23 @@ class HaCoverControls extends PolymerElement {
}
}

computeStopDisabled(stateObj) {
if (stateObj.state === UNAVAILABLE) {
return true;
}
return false;
}

computeOpenDisabled(stateObj, entityObj) {
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
if (stateObj.state === UNAVAILABLE) {
return true;
}
var assumedState = stateObj.attributes.assumed_state === true;
return (entityObj.isFullyOpen || entityObj.isOpening) && !assumedState;
}

computeClosedDisabled(stateObj, entityObj) {
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
if (stateObj.state === UNAVAILABLE) {
return true;
}
var assumedState = stateObj.attributes.assumed_state === true;
Expand Down
14 changes: 11 additions & 3 deletions src/components/ha-cover-tilt-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "@polymer/paper-icon-button/paper-icon-button";
import { html } from "@polymer/polymer/lib/utils/html-tag";
/* eslint-plugin-disable lit */
import { PolymerElement } from "@polymer/polymer/polymer-element";
import { UNAVAILABLE_STATES } from "../data/entity";
import { UNAVAILABLE } from "../data/entity";
import CoverEntity from "../util/cover-model";

class HaCoverTiltControls extends PolymerElement {
Expand Down Expand Up @@ -31,6 +31,7 @@ class HaCoverTiltControls extends PolymerElement {
icon="hass:stop"
on-click="onStopTiltTap"
invisible$="[[!entityObj.supportsStopTilt]]"
disabled="[[computStopDisabled(stateObj)]]"
title="Stop tilt"
></paper-icon-button>
<paper-icon-button
Expand Down Expand Up @@ -63,16 +64,23 @@ class HaCoverTiltControls extends PolymerElement {
return new CoverEntity(hass, stateObj);
}

computeStopDisabled(stateObj) {
if (stateObj.state === UNAVAILABLE) {
return true;
}
return false;
}

computeOpenDisabled(stateObj, entityObj) {
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
if (stateObj.state === UNAVAILABLE) {
return true;
}
var assumedState = stateObj.attributes.assumed_state === true;
return entityObj.isFullyOpenTilt && !assumedState;
}

computeClosedDisabled(stateObj, entityObj) {
if (UNAVAILABLE_STATES.includes(stateObj.state)) {
if (stateObj.state === UNAVAILABLE) {
return true;
}
var assumedState = stateObj.attributes.assumed_state === true;
Expand Down