Skip to content

Commit

Permalink
fix: display issue without battery_charge entity (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulic75 authored May 3, 2022
1 parent babdc7a commit 79f84ca
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/power-distribution-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
mdiArrowLeft,
mdiArrowRight,
mdiArrowUp,
mdiBattery,
mdiBatteryHigh,
mdiBatteryLow,
mdiBatteryMedium,
mdiBatteryOutline,
mdiBatteryUnknown,
mdiHome,
mdiSolarPower,
mdiTransmissionTower,
Expand Down Expand Up @@ -105,7 +105,7 @@ export class PowerDistributionCard extends LitElement {

let batteryIcon = mdiBatteryHigh;
if (batteryChargeState === null) {
batteryIcon = mdiBatteryUnknown;
batteryIcon = mdiBattery;
} else if (batteryChargeState <= 72 && batteryChargeState > 44) {
batteryIcon = mdiBatteryMedium;
} else if (batteryChargeState <= 44 && batteryChargeState > 16) {
Expand Down Expand Up @@ -252,17 +252,19 @@ export class PowerDistributionCard extends LitElement {
>
</div>
</div>
${hasBattery && batteryChargeState !== null
${hasBattery
? html`<div class="row">
<div class="spacer"></div>
<div class="circle-container battery">
<div class="circle">
<span>
${formatNumber(batteryChargeState, this.hass.locale, {
maximumFractionDigits: 0,
minimumFractionDigits: 0,
})}%
</span>
${batteryChargeState !== null
? html`<span>
${formatNumber(batteryChargeState, this.hass.locale, {
maximumFractionDigits: 0,
minimumFractionDigits: 0,
})}%
</span>`
: null}
<ha-svg-icon .path=${batteryIcon}></ha-svg-icon>
<span class="battery-in">
<ha-svg-icon
Expand Down

0 comments on commit 79f84ca

Please sign in to comment.