mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 14:07:55 +00:00
Make states that are numbers line graphs by default
This commit is contained in:
parent
a9192ae2e1
commit
aaf65e0599
@ -200,6 +200,15 @@ const processLineChartEntities = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isNumberValued = (states: HassEntity[]): boolean => {
|
||||||
|
for (const state of states) {
|
||||||
|
if (isNaN(parseFloat(state.state))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
export const computeHistory = (
|
export const computeHistory = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
stateHistory: HassEntity[][],
|
stateHistory: HassEntity[][],
|
||||||
@ -231,6 +240,8 @@ export const computeHistory = (
|
|||||||
unit = hass.config.unit_system.temperature;
|
unit = hass.config.unit_system.temperature;
|
||||||
} else if (computeStateDomain(stateInfo[0]) === "humidifier") {
|
} else if (computeStateDomain(stateInfo[0]) === "humidifier") {
|
||||||
unit = "%";
|
unit = "%";
|
||||||
|
} else if (isNumberValued(stateInfo)) {
|
||||||
|
unit = " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!unit) {
|
if (!unit) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user