How to remove decimal places?

Hi everyone a few of my items take pressure for an sample because it shows a precise measurement its too big for display on my habpannel how do i remove the decimal places and just display 997 or even 997.11

i’m assuming i need too use a proxy item and a rule im just unsure what goes inside the rule ect


Aaron, what widget did you use?
Can you post your item?

Hi again

Its just a simple dummy widget that shows the value provided by yahoo weather binding

there is no item file at the moment it was created in paperUI i can manually create it if needed im moving everything anyways

Move it to text file and format it like this

Number Pressure "[%.0f]" {binding.....}

In the widget choose the option use server provided format

Or directly in the widget, in the format box put: %.0f

Thanks for that i have other items that also need a slight edit could you explain how that worked and what it actually did and how to recreate it for my other items so i don’t need too ask again in the future

when using on some items it seems too just remove decimal places on others it seems too round the number

Well you have two options with HABpanel
You can specify a format in the format box of the dummy widget
The better way is to use the formatting in the item label in the item definition

You can use [%s] String
[%%] percent
[%.1f %%] percent to 1 decimal
[%d] or [%.0f] whole number
[%1$tH:%1$tM] hours and minutes for a datetime item

For examples:

My weather items:

Group Weather

// Weather Bindings
Number OutsideTemperature  "Outside Temperature [%.1f °C]"                <temperature>    (Weather, Temperatures) { weather="locationId=home, type=temperature, property=current", mqtt=">[mybroker:Outside/Temperature:state:*:default]" }
Number OutsideTempFeel     "Outside Temp Feel [%.1f°C]"                   <temperature>    (Weather) { weather="locationId=home, type=temperature, property=feel" }
Number OregonTemp          "Oregon Temp [%.1f °C]"                        <temperature>    (Weather) { mqtt="<[mybroker:Outside/OregonTemp:state:default]" }
Number OutsideHumidity     "Outside Humidity [%d %%]"                     <water>          (Weather, Humidity) { weather="locationId=home, type=atmosphere, property=humidity", mqtt=">[mybroker:Outside/Humidity:state:*:default]" }
Number WindSpeedMph        "Windspeed [%.0f mph]"                         <windspeed>      (Weather) { weather="locationId=home, type=wind, property=speed, unit=mps" }
Number WindSpeedBeaufort   "Windspeed [SCALE(beaufort.scale):%s]"         <windspeed>      (Weather) { weather="locationId=home, type=wind, property=speed, unit=mps" }
Number WindGustMph         "Wind Gust [%.0f mph]"                         <windspeed>      (Weather) { weather="locationId=home, type=wind, property=gust" }
Number WindDirection       "Wind direction [%d°]"                         <winddirection>  (Weather) { weather="locationId=home, type=wind, property=degree" }
String WindDirection2      "Wind direction [%s]"                          <winddirection>  (Weather) // Set by winddirection junction in nodered
Number AtmosphericPressure "Atmospheric Pressure [%.0f mbar]"                              (Weather) { weather="locationId=home, type=atmosphere, property=pressure" }
Number CloudCover          "Cloud Cover [%.0f %%]"                                         (Weather) { weather="locationId=home, type=clouds, property=percent" }
String WeatherIcon         "Current Conditions Icons"                                      (Weather) // Set in weather.rules
String WeatherConditions   "Current Conditions"                                            (Weather) { weather="locationId=home, type=condition, property=commonId", mqtt=">[mybroker:Outside/Conditions:state:*:MAP(]" }
String WeatherDay3                                                                         (Weather) { mqtt="<[mybroker:Misc/Day3:state:default]"}
String WeatherDay4                                                                         (Weather) { mqtt="<[mybroker:Misc/Day4:state:default]"}     
String WeatherDay5                                                                         (Weather) { mqtt="<[mybroker:Misc/Day5:state:default]"}     

String WeatherForecast0Conditions "Today [%s]"                  (Weather) { weather="locationId=home, forecast=0, type=condition, property=commonId" }
Number WeatherForecast0MinTemp    "Today min Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=0, type=temperature, property=min" }
Number WeatherForecast0MaxTemp    "Today max Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=0, type=temperature, property=max" }
String WeatherForecast1Conditions "Tomorrow [%s]"               (Weather) { weather="locationId=home, forecast=1, type=condition, property=commonId" }
Number WeatherForecast1MinTemp    "Tomorrow min Temp [%.1f °C]" (Weather) { weather="locationId=home, forecast=1, type=temperature, property=min" }
Number WeatherForecast1MaxTemp    "Tomorrow max Temp [%.1f °C]" (Weather) { weather="locationId=home, forecast=1, type=temperature, property=max" }
String WeatherForecast2Conditions "Day 2 [%s]"                  (Weather) { weather="locationId=home, forecast=2, type=condition, property=commonId" }
Number WeatherForecast2MinTemp    "Day 2 min Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=2, type=temperature, property=min" }
Number WeatherForecast2MaxTemp    "Day 2 max Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=2, type=temperature, property=max" }
String WeatherForecast3Conditions "Day 3 [%s]"                  (Weather) { weather="locationId=home, forecast=3, type=condition, property=commonId" }
Number WeatherForecast3MinTemp    "Day 3 min Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=3, type=temperature, property=min" }
Number WeatherForecast3MaxTemp    "Day 3 max Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=3, type=temperature, property=max" }
String WeatherForecast4Conditions "Day 4 [%s]"                  (Weather) { weather="locationId=home, forecast=4, type=condition, property=commonId" }
Number WeatherForecast4MinTemp    "Day 4 min Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=4, type=temperature, property=min" }
Number WeatherForecast4MaxTemp    "Day 4 max Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=4, type=temperature, property=max" }
String WeatherForecast5Conditions "Day 5 [%s]"                  (Weather) { weather="locationId=home, forecast=5, type=condition, property=commonId" }
Number WeatherForecast5MinTemp    "Day 5 min Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=5, type=temperature, property=min" }
Number WeatherForecast5MaxTemp    "Day 5 max Temp [%.1f °C]"    (Weather) { weather="locationId=home, forecast=5, type=temperature, property=max" }

Thanks for the detailed reply
tbh thats quite confusing i can normally get my head around that sort off stuff so i will save that for later reference too see if i can solve my other item myself if not i will post here


I have read over the items you sent me quite a few times now and can’t get my head around how too do this on my own i have tried a few variations none seem too work

14:10:21.726 [INFO ] [home.event.GroupItemStateChangedEvent] - Guslights changed from 0.00000000 to 63.00000000 through BULB3LAMAIN_Brightness
14:19:25.625 [INFO ] [home.event.GroupItemStateChangedEvent] - Gdslights changed from 100.00000000 to 75.00000000 through BULB4DSFDMAIN_Brightness
14:20:26.046 [INFO ] [home.event.GroupItemStateChangedEvent] - Ghouselights changed from 100.00000000 to 75.00000000 through BULB5USTOILET_Brightness 
14:11:22.307 [INFO ] [home.event.GroupItemStateChangedEvent] - Ghouse_Light_Level changed from 55.675843152439224 to 46.441272499314138 through HUE_Light4
14:16:23.071 [INFO ] [smarthome.event.ItemStateChangedEvent] - HUE_Light3 changed from 20.169726070331105 to 40.225365599868276

I would like too change all of these to 1 decimal places no rounding eg Ghouse_Light_Level changed from 55.675843152439224 would be 55.6

Group:Dimmer:MAX Ghouselights "All House Lights Group"
Group:Dimmer:MAX Gdslights "Downstairs Light Dimmer Group"
Group:Dimmer:MAX Guslights "Upstairs Light Dimmer Group"
Number	HUE_Light4 "Bathroom Light" (Ghouse_Light_Level)	{ http="<[http:**********

I don’t think that’s possible with the normal formatting like [%.1f] for example

1 Like

I have tried that one it seemed like nothing happened what would be possible?

Group:Dimmer:MAX Ghouselights "All House Lights Group [%d]"

i think i have tried that will try it again now too be sure

Group:Dimmer:MAX Ghouselights "All House Lights Group [%d]"

14:40:22.968 [INFO ] [home.event.GroupItemStateChangedEvent] - Ghouselights changed from 0.00000000 to 100.00000000 through BULB1DSKITCHEN_Brightness

same result nothing but it is reasuuring that you are sending me things that i have also tried i was starting too feel stupid :slight_smile:

Any suggestions appreciated

You will never get of the decimals in the item state itself. The state is a Number type like a decimal.
The [%d] is for formating the number in the sitemap label only.

1 Like


In theory, you could use a “workaround”: use “secondary” Item and a rule that postUpdates the state with only the rounded value… but this would be overkill :slight_smile:

Yes but the rounded value would also be a Number type so 100.000000000 would still be 100.000000000

1 Like

This is the first time I have heard something isn’t really possible using openhab in extremely supprised too be honest especially over something as simple as item formatting

Thanks for the replys I might have too implement some rules as you say as the size of the numbers look horrible in habpannel

What are you trying to do in habpanel?
What widgets are you using?


I’m trying too achieve what I posted above remove the decimal places for display in habpannel

removing the decimal would also make it easyer too create rules as I wouldent need too remember the amount of zeros and that’s a bonus

My habpannel is still basic so no custom widgets just a simple dummy widget displaying these items

I know you can change the formatting in the widget itself by using the %d but you said it was smarter too do it at the item level itself

Yes in the dummy widget tick the box “Use server-provided format if available”, that should do the trick!
It does for me

It’s not “smarter” and there are limitations to it with the new Quantity Types but it make sense to put all your item configurations in one place. It’s more for consistency than anything else.

If another way works for you, do that!!