[SOLVED] Split Item Result in Temp

I have an item.
For example, a temperature item.

It’s stored in my custom widget.

{{'% .1f' | sprintf: itemValue ('KChe_Temperatur'). split ('') [0]}}

As a result, I get 24.5

I would like to split this up.

{{'% .0f' | sprintf: itemValue ('KChe_Temperatur'). split ('') [0]}}

gives 24.
Now I would like to have the number after the comma individually to make it different in my widget.

Is that possible?

{{'%f' | sprintf:itemValue('KChe_Temperatur').split('.')[1].substring(0,1)}}

@hr3

I am using the new UoM items and the dummy widgets don’t update straight away in HABpanel.
I don’t know html and I was wondering how to create a equivalent dummy widget that would display the UoM values.
Could you help, thanks

Thanks so much

and is it posible with a full nummber?
Like a 554

I want to show the 55 in a big div and the 4 in a smal

Change the substring-parms.

{{'%s' | sprintf:itemValue('KChe_CO2Gehalt').split(' ')[0].substring(2)}}

i have solve it. Thanks

If it’s a integer you don’t need the split-function.
For this solution you ever muß have the same number of digits.

Number:Temperature Temp1 "Temp 1[%.1f %unit%]"
sitemap tmp label="TMP" {Default item=Temp1}

hc_312

<h2>{{itemValue('Temp1')}}</h2>
<h2>{{'%s' | sprintf:itemValue('Temp1').substring(1,4)}}</h2>
<h2>{{'%.0f' | sprintf:itemValue('Temp1').split('.')[0]}},{{'%s' | sprintf:itemValue('Temp1').split('.')[1]}}</h2>
<h2>{{'%.1f' | sprintf:itemValue('Temp1').split(' ')[0]}}{{itemValue('Temp1').split(' ')[1]}}</h2>

hc_317

2 Likes

Now i have a misstake in the Temp.

 <div class="main">{{'%.0f' | sprintf:itemValue('KChe_Temperatur').split(' ')[0]}}<div class="sub">,{{'%f' | sprintf:itemValue('KChe_Temperatur').split('.')[1].substring(0,1)}}</div></div>

Its 25.8 C here but the Result in the widget shows 26,8

The first Item round up the 25,8 to 26 and the Sec Items is ,8.

Is it Posible to fix the round up?

Thanks

<div class="main">{{itemValue('KChe_Temperatur').split('.')[0]}}<div class="sub">,{{itemValue('KChe_Temperatur').split('.')[1].substring(0,1)}}</div></div>
1 Like

You can also use %d as a pattern i.e. {{'%d' | sprintf:itemValue('KChe_Temperatur').split(' ')[0]}} to get the integer part of the number without rounding.

@hr3
Thanks that works in a template widget.
Now, I am sorry but I am ok at coding but not HTML stuff, never touched as I have never really been interested.

How can I make that template widget look like the dummy widget?

Current with the <h2> html tag:

image

Wanted:

image
But with the temperature icon?

Thanks

<widget-icon iconset="'eclipse-smarthome-classic'" icon="'temperature'" state="item.state"/>

Thanks,
That’s what I have now:

<div class="text-center" style="font-size: 10pt">
  <span>Open Temp</span>
</div>
<div class="text-center" style="font-size: 36pt; color:#FF7B00">
  <span>{{'%.1f' | sprintf:itemValue('openWeather_Current_Temperature').split(' ')[0]}}{{itemValue('openWeather_Current_Temperature').split(' ')[1]}}</span>
</div>
<widget-icon iconset="'eclipse-smarthome-classic'" icon="'temperature'" state="item.state"/>

I have replicated the text styles of the dummy widget, but your suggestion for the icon display a thermometer under the text. How do I specifify the icon to be in the background?
Also, can I use the builtin: Smart Home Set of icons?
I know, sounds very noobs, but I have never really touched this kind of stuff before…
Thanks

Use the dummy-widget

hc_326

That’s what I am getting away from because at the moment it’s broken with the Units

I think that would be fixed in the future.
I would use the dummy-widget und prepare a (string) dummy-item in a rule for the moment.

This works with items with and without UoM similarly.
hc_328

Coolio, I’ll give it a go