mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
support for unknown value and uom
This commit is contained in:
@@ -27,12 +27,16 @@ const formatDurationMin = (LL: TranslationFunctions, duration_min: number) => {
|
|||||||
|
|
||||||
export function formatValue(
|
export function formatValue(
|
||||||
LL: TranslationFunctions,
|
LL: TranslationFunctions,
|
||||||
value: unknown,
|
value?: unknown,
|
||||||
uom: DeviceValueUOM
|
uom?: DeviceValueUOM
|
||||||
) {
|
) {
|
||||||
if (typeof value !== 'number') {
|
if (typeof value !== 'number' || uom === undefined || value === undefined) {
|
||||||
return (value === undefined ? '' : value) as string;
|
if (value === undefined || typeof value === 'boolean') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return value as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (uom) {
|
switch (uom) {
|
||||||
case DeviceValueUOM.HOURS:
|
case DeviceValueUOM.HOURS:
|
||||||
return value ? formatDurationMin(LL, value * 60) : LL.NUM_HOURS({ num: 0 });
|
return value ? formatDurationMin(LL, value * 60) : LL.NUM_HOURS({ num: 0 });
|
||||||
|
|||||||
Reference in New Issue
Block a user