Do not render info tooltip if we have an error (#9869)

This commit is contained in:
Paulus Schoutsen 2021-08-22 23:47:03 -07:00 committed by GitHub
parent e963735dba
commit bd8f436c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 35 deletions

View File

@ -124,16 +124,17 @@ class HuiEnergyCarbonGaugeCard
return html` return html`
<ha-card> <ha-card>
${value !== undefined
? html`
<ha-svg-icon id="info" .path=${mdiInformation}></ha-svg-icon> <ha-svg-icon id="info" .path=${mdiInformation}></ha-svg-icon>
<paper-tooltip animation-delay="0" for="info" position="left"> <paper-tooltip animation-delay="0" for="info" position="left">
<span> <span>
This card represents how much of the energy consumed by your home This card represents how much of the energy consumed by your
was generated using non-fossil fuels like solar, wind and nuclear. home was generated using non-fossil fuels like solar, wind and
nuclear.
</span> </span>
</paper-tooltip> </paper-tooltip>
<ha-gauge
${value !== undefined
? html` <ha-gauge
min="0" min="0"
max="100" max="100"
.value=${value} .value=${value}
@ -143,7 +144,8 @@ class HuiEnergyCarbonGaugeCard
"--gauge-color": this._computeSeverity(value), "--gauge-color": this._computeSeverity(value),
})} })}
></ha-gauge> ></ha-gauge>
<div class="name">Non-fossil energy consumed</div>` <div class="name">Non-fossil energy consumed</div>
`
: html`Consumed non-fossil energy couldn't be calculated`} : html`Consumed non-fossil energy couldn't be calculated`}
</ha-card> </ha-card>
`; `;

View File

@ -97,18 +97,20 @@ class HuiEnergyGridGaugeCard
return html` return html`
<ha-card> <ha-card>
${value !== undefined
? html`
<ha-svg-icon id="info" .path=${mdiInformation}></ha-svg-icon> <ha-svg-icon id="info" .path=${mdiInformation}></ha-svg-icon>
<paper-tooltip animation-delay="0" for="info" position="left"> <paper-tooltip animation-delay="0" for="info" position="left">
<span> <span>
This card represents your energy dependency. This card represents your energy dependency.
<br /><br /> <br /><br />
If it's green, it means you produced more energy than that you If it's green, it means you produced more energy than that you
consumed from the grid. If it's in the red, it means that you relied consumed from the grid. If it's in the red, it means that you
on the grid for part of your home's energy consumption. relied on the grid for part of your home's energy consumption.
</span> </span>
</paper-tooltip> </paper-tooltip>
${value !== undefined
? html`<ha-gauge <ha-gauge
min="-1" min="-1"
max="1" max="1"
.value=${value} .value=${value}
@ -126,7 +128,8 @@ class HuiEnergyGridGaugeCard
${returnedToGrid! >= consumedFromGrid! ${returnedToGrid! >= consumedFromGrid!
? "Net returned to the grid" ? "Net returned to the grid"
: "Net consumed from the grid"} : "Net consumed from the grid"}
</div>` </div>
`
: "Grid neutrality could not be calculated"} : "Grid neutrality could not be calculated"}
</ha-card> </ha-card>
`; `;

View File

@ -86,19 +86,20 @@ class HuiEnergySolarGaugeCard
return html` return html`
<ha-card> <ha-card>
${value !== undefined
? html`
<ha-svg-icon id="info" .path=${mdiInformation}></ha-svg-icon> <ha-svg-icon id="info" .path=${mdiInformation}></ha-svg-icon>
<paper-tooltip animation-delay="0" for="info" position="left"> <paper-tooltip animation-delay="0" for="info" position="left">
<span> <span>
This card represents how much of the solar energy was used by your This card represents how much of the solar energy was used by
home and was not returned to the grid. your home and was not returned to the grid.
<br /><br /> <br /><br />
If you frequently produce more than you consume, try to conserve If you frequently produce more than you consume, try to
this energy by installing a battery or buying an electric car to conserve this energy by installing a battery or buying an
charge. electric car to charge.
</span> </span>
</paper-tooltip> </paper-tooltip>
${value !== undefined <ha-gauge
? html`<ha-gauge
min="0" min="0"
max="100" max="100"
.value=${value} .value=${value}
@ -108,7 +109,8 @@ class HuiEnergySolarGaugeCard
"--gauge-color": this._computeSeverity(value), "--gauge-color": this._computeSeverity(value),
})} })}
></ha-gauge> ></ha-gauge>
<div class="name">Self consumed solar energy</div>` <div class="name">Self consumed solar energy</div>
`
: totalSolarProduction === 0 : totalSolarProduction === 0
? "You have not produced any solar energy" ? "You have not produced any solar energy"
: "Self consumed solar energy couldn't be calculated"} : "Self consumed solar energy couldn't be calculated"}