1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Fix water/gas total badge unit when sensor value is zero (#30279)

Fix water/gas badge when rate is 0

If there is only one flow rate sensor, and it has a value <=0, the badge would be displayed without a unit because the sensor gets skipped.

Instead of skipping <=0 values, continue to process sensor, but clamp the value to a minimum of 0. This ensures for single sensors we have a unit, and for multiple sensors the chosen unit is consistent even if the first sensor value drops to zero.
This commit is contained in:
Tom Carpenter
2026-03-23 11:36:15 +00:00
committed by GitHub
parent 09e4355451
commit 984b50bac7

View File

@@ -1526,11 +1526,15 @@ export const computeTotalFlowRate = (
return;
}
const rawValue = parseFloat(stateObj.state);
if (isNaN(rawValue) || rawValue <= 0) {
let rawValue = parseFloat(stateObj.state);
if (isNaN(rawValue)) {
return;
}
if (rawValue < 0) {
rawValue = 0;
}
const entityUnit = stateObj.attributes.unit_of_measurement;
if (!entityUnit) {
return;