Compare commits

...
Author SHA1 Message Date
Simon LamonandPetar Petrov 502dcdc1a6 Fix getWeatherExtrema when either is 0° (#55687)
* Fix getWeatherExtrema when either is 0°

* Update src/data/weather.ts

Co-authored-by: Petar Petrov <[email protected]>

* Simplify tempLow assignment conditions

Refactor temperature low assignment logic in weather.ts

* Prettier

* Apply suggestion from @MindFreeze

Co-authored-by: Petar Petrov <[email protected]>

---------

Co-authored-by: Petar Petrov <[email protected]>
2026-11-15 17:19:50 +02:00
+13 -7
View File
@@ -364,19 +364,25 @@ const getWeatherExtrema = (
if (new Date(fc.datetime).getDate() !== today) {
break;
}
if (!tempHigh || fc.temperature > tempHigh) {
if (fc.temperature == null) {
continue;
}
if (tempHigh === undefined || fc.temperature > tempHigh) {
tempHigh =
temperatureFractionDigits === undefined
? fc.temperature
: round(fc.temperature, temperatureFractionDigits);
}
if (fc.templow !== undefined && (!tempLow || fc.templow < tempLow)) {
if (fc.templow != null && (tempLow === undefined || fc.templow < tempLow)) {
tempLow =
temperatureFractionDigits === undefined
? fc.templow
: round(fc.templow, temperatureFractionDigits);
}
if (!fc.templow && (!tempLow || fc.temperature < tempLow)) {
if (
fc.templow == null &&
(tempLow === undefined || fc.temperature < tempLow)
) {
tempLow =
temperatureFractionDigits === undefined
? fc.temperature
@@ -384,19 +390,19 @@ const getWeatherExtrema = (
}
}
if (!tempLow && !tempHigh) {
if (tempLow === undefined && tempHigh === undefined) {
return undefined;
}
return html`
${
tempHigh
tempHigh !== undefined
? formatEntityAttributeValue(stateObj, "temperature", tempHigh)
: ""
}
${tempLow && tempHigh ? " / " : ""}
${tempLow !== undefined && tempHigh !== undefined ? " / " : ""}
${
tempLow
tempLow !== undefined
? formatEntityAttributeValue(stateObj, "temperature", tempLow)
: ""
}