Habpanel template access units of items

Hoi zäme,

I currently try to get the units from my items into a table in a template in HabPanel:

Wetter Daten
<table class="table table-condensed">
  <tr ng-repeat="item in itemsInGroup('gHPWU')">
   <td class ="text-left">{{item.label}}</td>
   <td class="text-left" ng-style="{color:'lightblue'}">{{itemState(item.name)}}</td>
   <td class="text-left" ng-style="{color:'lightblue'}">{{itemState(item.unit)}}</td>

with this item for instance:

Weather_RainTodayTotalforecast "Rain Today forecast [%.2f mm]"    (gWeatherUnderground, gHPWU)	{channel="weatherunderground:weather:local:forecastToday#precipitationDay"}

could anyone tell me how I can call up the unit in the table I try to produce above?

Thanks in advance, Cheers

See: Split Item Result in Temp

1 Like

Hey vzorglub, thanks for the hint, but I still cannot get to it. How would I need to split it to get to the unit? :confused:
Thanks so much for your help!!!

Can you help, here, please?

You can use for instance

<td class="text-left">{{item | json)}}</td>

to inspect the structure.

In your case the unit is probably going to be in stateDescription.pattern

so you would get to the unit (the part after the space) with something like:

<td class="text-left" ng-style="{color:'lightblue'}"
ng-if="item.stateDescription.pattern && item.stateDescription.pattern.split(' ').length == 2">
  {{item.stateDescription.pattern.split(' ')[1]}}
1 Like

hey @ysc it works!!! thanks so much! :wink: hopefully helping future requests with this :wink:

1 Like