Skip to content

Commit

Permalink
fix(person): fix state not displayed on cast devices (#495)
Browse files Browse the repository at this point in the history
* fix(chip): fix entity chip avatar

* chore: add missing imports

* fix: fix name not displayed
  • Loading branch information
piitaya committed May 16, 2022
1 parent 727f0e4 commit 9fae0a5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/cards/chips-card/chips/entity-chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class EntityChip extends LitElement implements LovelaceChip {
hasHold: hasAction(this._config.hold_action),
hasDoubleClick: hasAction(this._config.double_tap_action),
})}
.avatar=${(this.hass as any).hassUrl(picture)}
.avatar=${picture ? (this.hass as any).hassUrl(picture) : undefined}
.avatarOnly=${picture && !content}
>
${!picture ? this.renderIcon(icon, iconColor, active) : null}
Expand Down
70 changes: 35 additions & 35 deletions src/cards/person-card/person-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import "../../shared/badge-icon";
import "../../shared/card";
import "../../shared/shape-avatar";
import "../../shared/shape-icon";
import "../../shared/state-info";
import "../../shared/state-item";
import { MushroomBaseElement } from "../../utils/base-element";
import { cardStyle } from "../../utils/card-styles";
import { registerCustomCard } from "../../utils/custom-cards";
Expand Down Expand Up @@ -101,41 +103,39 @@ export class PersonCard extends MushroomBaseElement implements LovelaceCard {
return html`
<ha-card class=${classMap({ "fill-container": this._config.fill_container ?? false })}>
<mushroom-card .layout=${layout} ?rtl=${rtl}>
<div class="container">
<mushroom-state-item
?rtl=${rtl}
.layout=${layout}
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config.hold_action),
hasDoubleClick: hasAction(this._config.double_tap_action),
})}
hide_info=${hideName && hideState}
>
${picture
? html`
<mushroom-shape-avatar
slot="icon"
.picture_url=${(this.hass as any).hassUrl(picture)}
></mushroom-shape-avatar>
`
: html`
<mushroom-shape-icon
slot="icon"
.icon=${icon}
.disabled=${!isActive(entity)}
></mushroom-shape-icon>
`}
${isAvailable(entity)
? this.renderStateBadge(stateIcon, stateColor)
: this.renderUnavailableBadge()}
<mushroom-state-info
slot="info"
.primary=${!hideName ? name : undefined}
.secondary=${!hideState && stateDisplay}
></mushroom-state-info>
</mushroom-state-item>
</div>
<mushroom-state-item
?rtl=${rtl}
.layout=${layout}
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config.hold_action),
hasDoubleClick: hasAction(this._config.double_tap_action),
})}
.hide_info=${hideName && hideState}
>
${picture
? html`
<mushroom-shape-avatar
slot="icon"
.picture_url=${(this.hass as any).hassUrl(picture)}
></mushroom-shape-avatar>
`
: html`
<mushroom-shape-icon
slot="icon"
.icon=${icon}
.disabled=${!isActive(entity)}
></mushroom-shape-icon>
`}
${isAvailable(entity)
? this.renderStateBadge(stateIcon, stateColor)
: this.renderUnavailableBadge()}
<mushroom-state-info
slot="info"
.primary=${!hideName ? name : undefined}
.secondary=${!hideState ? stateDisplay : undefined}
></mushroom-state-info>
</mushroom-state-item>
</mushroom-card>
</ha-card>
`;
Expand Down

0 comments on commit 9fae0a5

Please sign in to comment.