HP inputs #600, custom entity bool display

This commit is contained in:
MichaelDvP
2023-04-28 14:36:35 +02:00
parent 5f87718deb
commit 90ce8bc8ce
7 changed files with 53 additions and 62 deletions

View File

@@ -226,13 +226,11 @@ const SettingsEntities: FC = () => {
};
function formatValue(value: any, uom: number) {
if (value === undefined) {
return '';
}
if (uom === 0) {
return new Intl.NumberFormat().format(value);
}
return new Intl.NumberFormat().format(value) + ' ' + DeviceValueUOM_s[uom];
return value === undefined || uom === undefined
? ''
: typeof value === 'number'
? new Intl.NumberFormat().format(value) + (uom === 0 ? '' : ' ' + DeviceValueUOM_s[uom])
: value;
}
function showHex(value: string, digit: number) {