Skip to content

Commit

Permalink
Show buttons in cover and valve more info if it supports position (#2…
Browse files Browse the repository at this point in the history
…2569)

* Show buttons in cover more info if the cover supports position

* Same for valve

* Refactor
  • Loading branch information
piitaya authored Oct 28, 2024
1 parent 1542095 commit 3180747
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/dialogs/more-info/controls/more-info-cover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ class MoreInfoCover extends LitElement {
supportsFeature(this.stateObj, CoverEntityFeature.CLOSE_TILT) ||
supportsFeature(this.stateObj, CoverEntityFeature.STOP_TILT);

const supportsOpenCloseWithoutStop =
const supportsOpenCloseOnly =
supportsFeature(this.stateObj, CoverEntityFeature.OPEN) &&
supportsFeature(this.stateObj, CoverEntityFeature.CLOSE) &&
!supportsFeature(this.stateObj, CoverEntityFeature.STOP) &&
!supportsFeature(this.stateObj, CoverEntityFeature.OPEN_TILT) &&
!supportsFeature(this.stateObj, CoverEntityFeature.CLOSE_TILT);
!supportsTilt &&
!supportsPosition &&
!supportsTiltPosition;

return html`
<ha-more-info-state-header
Expand Down Expand Up @@ -133,7 +134,7 @@ class MoreInfoCover extends LitElement {
${
this._mode === "button"
? html`
${supportsOpenCloseWithoutStop
${supportsOpenCloseOnly
? html`
<ha-state-control-cover-toggle
.stateObj=${this.stateObj}
Expand Down
7 changes: 4 additions & 3 deletions src/dialogs/more-info/controls/more-info-valve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ class MoreInfoValve extends LitElement {
supportsFeature(this.stateObj, ValveEntityFeature.CLOSE) ||
supportsFeature(this.stateObj, ValveEntityFeature.STOP);

const supportsOpenCloseWithoutStop =
const supportsOpenCloseOnly =
supportsFeature(this.stateObj, ValveEntityFeature.OPEN) &&
supportsFeature(this.stateObj, ValveEntityFeature.CLOSE) &&
!supportsFeature(this.stateObj, ValveEntityFeature.STOP);
!supportsFeature(this.stateObj, ValveEntityFeature.STOP) &&
!supportsPosition;

return html`
<ha-more-info-state-header
Expand All @@ -113,7 +114,7 @@ class MoreInfoValve extends LitElement {
${
this._mode === "button"
? html`
${supportsOpenCloseWithoutStop
${supportsOpenCloseOnly
? html`
<ha-state-control-valve-toggle
.stateObj=${this.stateObj}
Expand Down

0 comments on commit 3180747

Please sign in to comment.