Hi all
I have a some capabilities for my devices, and I’m struggling with correct formatting of numbers.
To be more specific, I’m looking for a way to apply formatting to large numbers.
VALUE (raw): 1000000.00 (example: 1 million with two decimals)
English format: 1000000.00 - which is how it’s display in the devices info
For my localization, danish in this example - local formatting: 1.000.000,00 is way more readable.
Thousand seperator: “.” (dot), and decimal seperator ‘,’ (comma)
Code:
this.setCapabilityValue(“x_capability”, inverterData.Power)
Does this community know a way to apply number formatting to numbers in Homey? I would like to support this for my app where values are displayed. I need the capability to still be number - so raw-values are applied in flows. But for the presentation of the values, I would like to display localized formatting with local-format applied. Same could apply for DateTime, yyyy-mm-dd vs dd-mm-yyyy.
I am aware of this:
this.setCapabilityOptions(“x_capability”, { “units”: { “en” : “kWh” }, “decimals”: 3 );