AgM
March 10, 2025, 11:59am
1
Hi, I’m trying to use the configuration option “format" (Formatting rules to be applied when converting the value to string representation for UI purposes (number of decimal places, boolean as on/off etc.) to change the attribute number of decimal places to 4.
The wiki guide points me to this link:
/**
* Represents formatting rules to apply to date and number values when converting to {@link String} representation; based on
* HTML Intl API, see: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl">here</a>.
* {@link ValueFormat}s should be merged for UI consumption in the following priority order:
* <ol>
* <li>{@link Attribute} {@link MetaItemType#FORMAT}</li>
* <li>{@link AttributeDescriptor#getFormat}/{@link MetaItemDescriptor#getFormat}</li>
* <li>{@link ValueDescriptor#getFormat}</li>
* </ol>
*/
public class ValueFormat implements Serializable {
public enum StyleRepresentation {
NUMERIC("numeric"),
DIGIT_2("2-digit"),
FULL("full"),
LONG("long"),
MEDIUM("medium"),
SHORT("short"),
NARROW("narrow");
How do I use this to parse the data in json?
AgM
March 10, 2025, 12:26pm
2
I’ve tried this with no success:
{
“maximumFractionDigits”: 4
}
Hi!
I just attempted to reproduce your issue, and found out it’s a bug in our system
The field accepts JSON based on the ValueFormat
Java class.
So your format is correct, and written correctly.
It seems all other options like minimumFractionDigits
work fine;
However, the maximumFractionDigits
meta item does not seem to work;
I’ll create a GitHub PR to fix this issue, and link it here
Let me know if other issues arise!
I’ve created an GitHub issue for it;
opened 01:11PM - 13 Mar 25 UTC
Bug
### Describe the bug
The `maximumFractionDigits` number formatting does not work… in the Manager UI.
Referring to this forum post reported by a user on our forum;
https://forum.openremote.io/t/how-to-configure-a-number-attribute-using-format/3709
After reproducing the issue myself, I can confirm the issue.
All other number formatting options seem to work fine.
### To Reproduce
Steps to reproduce the behavior:
1. Create any asset and add a number attribute for that asset
2. Click on 'add configuration item', and click on `format`.
3. Add the following JSON data in the input field;
```
{
"minimumFractionDigits": 4,
"maximumFractionDigits": 8
}
```
4. Write a random value with more than 8 digits, like `1,23456789101112` in the value field.
5. Press the save button.
6. Bug appears
### Expected behavior
The value should be limited to the formatting configuration a user has set
### Screenshots

### Additional context
The incorrect maximum number of digits is caused by a hardcoded maximum of 20 in `or-mwc-input`.
See a reference to the code here;
https://github.com/openremote/openremote/blob/6a046ef064ba1579542bdfe6c44d5ffec3903c09/ui/component/or-mwc-components/src/or-mwc-input.ts#L1361
.
I've assigned this to myself, and I'll create a PR when I find the time.
AgM
March 17, 2025, 12:21pm
5
Hi Martin,
Thanks! I’m now using maximumSignificantDigits which works fine and I’ll switch to maximumFractionDigits when the issue has been resolved.
No problem!
The issue has been resolved, and will be included in the next release.
We have no date on that yet, but I’m expecting it sometime next week.