[SOLVED] Split Item Result in Temp

{{'%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

Nope,
It only updates when the binding updates the value…

image

This updates immediately, but you can’t format the number of decimals.

Number:Temperature Temp1 "yyy[%.1f °C]" <temperature>

hc_331

Fix merged - https://github.com/openhab/org.openhab.ui.habpanel/pull/310
Should fix the formatting for the dummy widget, and the icon in item pickers.
It should also format the chart tooltips properly, although I haven’t tested it because I don’t have items with UoM and persistence available.

In #1318 HABPANEL is changed for UoM. So I did a test series.

Number:Temperature Temp1 "t1[%.1f %unit%]" <temperature>
Setpoint item=Temp1
Default  item=Temp1 label="t1 U[%.1f %unit%]"
Default  item=Temp1 label="t1 C[%.1f °C]"
Default  item=Temp1 label="t1 F[%.1f °F]"
Default  item=Temp1 label="t1 F[%.1f K]"

hc_364

.

Sitemap converts into another unit.

.

hc_351

.

The first 5 examples are ok, the second 5 are not

.

hc_352

hc_353

hc_354

hc_355

hc_356

hc_357

hc_358

hc_359

hc_360

hc_362

The %unit% placeholder is only supported in the format field, not the “unit” field.

See my remark here: https://github.com/openhab/org.openhab.ui.habpanel/pull/310#issuecomment-408122421 on why HABPanel can’t perform unit conversions.