Hello OpenHAB community,
I’m currently working on a project where I need to display certain values in a specific format, but I’m encountering some issues. I thought I’d share my experience and ask for some guidance.
I’ve created a Thing that pulls data from a REST API, and it’s working well in terms of fetching the data. However, when it comes to formatting the numbers, I’m running into a problem. Specifically, I want to display a number with a thousand separator, such as 15,599 instead of 15599.
Here’s what I’ve done so far:
-
Configuration Setup: I configured the channel to use a state transformation with JSONPATH to extract the relevant data from the API response. This part works perfectly.
-
Formatting Attempt: I tried adding a metadata pattern to the item using
%1$,d
to format the number with thousand separators. However, this resulted in an error, and the value wasn’t displayed correctly. -
Current State: Without the formatting, the number displays correctly as 15599, but I really need it to show as 15,599 for better readability.
I’m wondering if there’s a different approach I should take. Maybe there’s a specific pattern or method within OpenHAB that I’m not aware of. I’ve checked the documentation, but I might have missed something.
If anyone has successfully formatted numbers in a similar way or has any tips, I’d greatly appreciate your input. Let’s collaborate to find a solution!
Best regards,
[Your Name]