[SOLVED] How to use no decimal place on a temperature Item

Hey everyone!

I have been trying to find a workaround for this little issue to no avail.

I have an item:

Number:Temperature   HueTemperatureSensor1_Temperature    "Temperature"     {channel="hue:0302:00178846d391:2:temperature"}

I am trying to format it to use no decimal place as it currently reads as 10.456°C

when I try this, it doesn’t work, it still shows the decimal places:

Number   HueTemperatureSensor1_Temperature    "Temperature [%.0f °C]"     {channel="hue:0302:00178846d391:2:temperature"}

I had some issues in rules as well as its a string not a number.

My question is what is the best way to have a temperature sensor output a number with no decimal places?

Thanks for any tips.

1 Like

Where are you looking, though?
If at a sitemap based UI, be aware that any label= parameter with its own [format] element will override the label in the base Item.
If in PaperUI, this is an admin interface and ideally should show you the actual state of the Item, not the sugar coated version.

This is most likely because it is a Quantity Type i.e. a number with units.
Show us the problem and we can help.
“UoM” with “Number” as keywords searching this forum would probably give clues too.

Sorry, I am viewing the data in habpanel.

The widget is set up lie this:

<style>
  
	.condition {
	    font-size: 16px;
	    text-transform: capitalize;
	    margin-top: -15px;
	}  
	.title {
	    font-size: 14px;
	    padding-top: 7px;
	}

	.indoor {
	    border-bottom: 5px solid #333;
	    width: 96%;
	    margin-left: auto;
	    margin-right: auto;
	    background: url(http://192.168.0.129:3000/render/d-solo/z2QzMbKWk/indoor-temp?orgId=1&refresh=5s&now-36h&to=now&panelId=2&width=420&height=140&tz=America%2FEdmonton);
	    background-position: left;
	    background-size: 110%;
	    background-position-x: center;
	    background-repeat: no-repeat;
	    background-position-y: bottom;
	    background-origin: border-box;
	}
	  
	.indoortemp {
	    padding-bottom:10px;
	  	font-size: 38px;
	}

	.weather {
	    border-bottom: 5px solid #333;
	    padding-top: 10px;
	      width: 96%;
	    margin-left: auto;
	    margin-right: auto;
	  background: url(http://192.168.0.129:3000/render/d-solo/8K5R4bKWk/outside-temp?tab=visualization&orgId=1&refresh=5s&from=now-16w&to=now&panelId=2&width=420&height=140&tz=America%2FEdmonton);
	    background-position: left;
	    background-size: 110%;
	    background-position-x: center;
	    background-repeat: no-repeat;
	    background-position-y: bottom;
	    background-origin: border-box;
	}
	  
	.forecast {
	    padding-top: 10px;
	    width: 95%;
	    margin-left: auto;
	    margin-right: auto;
	}
	.result {
	    font-size: 38px;
	  margin-bottom: -3px;
	}
	  
	img.icon {
	    padding: 0px !important;
	    margin-top: -10px;
	}
	  
	  #warm {
	  
	  color:#ff504f !important ;
	  
	  }
	  
	    #cold {
	  
	  color:blue #4fbeff !important ;
	  
	  }
	</style>

	<div class="row">
	  
	 
	 
	  
	    <div class="indoor">
	   <div  class="title">INSIDE TEMPERATURE</div>
	    <div class="indoortemp">{{itemValue('HueTemperatureSensor1_Temperature')}}</div> 
	  </div> 
	  
	      
	    <div class="weather">
	    <div class="title">OUTSIDE TEMPERATURE</div>
	    <div class="result">{{itemValue('LocalWeatherAndForecast_Current_OutdoorTemperature')}}</div>
	    <div class="condition">{{itemValue('LocalWeatherAndForecastCurrentCondition')}}</div>
	  <img class="icon" height="100%" ng-src="{{itemValue('LocalWeatherAndForecastCurrentIcon')}}" src="{{itemValue('LocalWeatherAndForecastCurrentIcon')}}"></img>
	  </div>
	    <div class="forecast">
	      <div class="title">FORECAST FOR {{itemValue('LocalWeatherAndForecastForecastHours06TimeStamp') | date:'h:mma'}}</div>
	    <div class="result">{{itemValue('LocalWeatherAndForecastForecastHours06Temperature')}}</div>
	    <div class="condition">{{itemValue('LocalWeatherAndForecastForecastHours06Condition')}}</div>
	  <img class="icon" height="100%" ng-src="{{itemValue('LocalWeatherAndForecastForecastHours06Icon')}}" src="{{itemValue('LocalWeatherAndForecastForecastHours06Icon')}}"></img>
	  </div>
	  
	  </div>

38%20PM

HabPanel should be able to pick up the item format or you can define a format in the Dummy widgets.
What openHAB version are you running?

2.4 Stable - included habpanel widget above in edit

No, it’s a number, just a special type of number.
Search working with uom
You should find examples of conversions in rules

Do the formating in the widget code, then.

I can’t remember if HabPanel 2.4 was fixed for uom and Dummy widgets.
You’ll have to code the formatting in the widget

Got it! Found this in another post [SOLVED] Dummy Widget Format Value

		<div class="indoor">
		   <div  class="title">INSIDE TEMPERATURE</div>
		      <div class="indoortemp">{{'%.0f' | sprintf:itemValue('HueTemperatureSensor1_Temperature').split(' ')[0]}}  °C</div> 
		</div> 

56%20PM

1 Like

I think the “proper” fix is far too recent for 2.4, maybe made 2.5M2