Handle unavailable vacuums in more-info (#9974)

This commit is contained in:
Philip Allgaier 2021-09-07 10:14:05 +02:00 committed by GitHub
parent d55bade070
commit 321f441b63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ import "../../../components/ha-attributes";
import "../../../components/ha-icon"; import "../../../components/ha-icon";
import "../../../components/ha-icon-button"; import "../../../components/ha-icon-button";
import "../../../components/ha-paper-dropdown-menu"; import "../../../components/ha-paper-dropdown-menu";
import { UNAVAILABLE } from "../../../data/entity";
import { import {
VacuumEntity, VacuumEntity,
VACUUM_SUPPORT_BATTERY, VACUUM_SUPPORT_BATTERY,
@ -98,7 +99,8 @@ class MoreInfoVacuum extends LitElement {
"fan_speed,fan_speed_list,status,battery_level,battery_icon"; "fan_speed,fan_speed_list,status,battery_level,battery_icon";
return html` return html`
<div class="flex-horizontal"> ${stateObj.state !== UNAVAILABLE
? html` <div class="flex-horizontal">
${supportsFeature(stateObj, VACUUM_SUPPORT_STATUS) ${supportsFeature(stateObj, VACUUM_SUPPORT_STATUS)
? html` ? html`
<div> <div>
@ -111,18 +113,21 @@ class MoreInfoVacuum extends LitElement {
</div> </div>
` `
: ""} : ""}
${supportsFeature(stateObj, VACUUM_SUPPORT_BATTERY) ${supportsFeature(stateObj, VACUUM_SUPPORT_BATTERY) &&
stateObj.attributes.battery_level
? html` ? html`
<div> <div>
<span> <span>
<ha-icon .icon=${stateObj.attributes.battery_icon}></ha-icon>
${stateObj.attributes.battery_level} % ${stateObj.attributes.battery_level} %
<ha-icon
.icon=${stateObj.attributes.battery_icon}
></ha-icon>
</span> </span>
</div> </div>
` `
: ""} : ""}
</div> </div>`
: ""}
${VACUUM_COMMANDS.some((item) => item.isVisible(stateObj)) ${VACUUM_COMMANDS.some((item) => item.isVisible(stateObj))
? html` ? html`
<div> <div>
@ -145,6 +150,7 @@ class MoreInfoVacuum extends LitElement {
.title=${this.hass!.localize( .title=${this.hass!.localize(
`ui.dialogs.more_info_control.vacuum.${item.translationKey}` `ui.dialogs.more_info_control.vacuum.${item.translationKey}`
)} )}
.disabled=${stateObj.state === UNAVAILABLE}
></ha-icon-button> ></ha-icon-button>
</div> </div>
` `
@ -161,6 +167,7 @@ class MoreInfoVacuum extends LitElement {
.label=${this.hass!.localize( .label=${this.hass!.localize(
"ui.dialogs.more_info_control.vacuum.fan_speed" "ui.dialogs.more_info_control.vacuum.fan_speed"
)} )}
.disabled=${stateObj.state === UNAVAILABLE}
> >
<paper-listbox <paper-listbox
slot="dropdown-content" slot="dropdown-content"