[SOLVED] Habpanel Contact question

All,

I am using successfully the following template for indicating the state of switches:

<button class="btn" style="width: 100%; height: 100%; padding: 0; background: inherit; outline: none">
<span>
<widget-icon iconset="'smarthome-set'" icon="'car_doorR'" size="32" state="itemValue('CarDrReLeft')" />
</span>
<span style="color: {{itemValue('CarDrReLeft')=='ON' ? 'white' : '#7B879C'}}">
HL
</span>
</button>

Because the items changed to Contacts (Door contacts of the new Volvo Binding), I struggle to get the icon to reflect the state.
For the widget’s text i just changed it to

<span style="color: {{itemValue('CarDrReLeft')=='OPEN' ? 'white' : '#7B879C'}}">
HL
</span>

and I tried to do the same on the icon, but did not succeed.

<button class="btn" style="width: 100%; height: 100%; padding: 0; background: inherit; outline: none">
<span>
<widget-icon iconset="'smarthome-set'" icon="'car_doorR'" size="32" state="itemValue('CarDrReLeft')=='OPEN' ? 'white' : '#7B879C'" />
</span>
<span style="color: {{itemValue('CarDrReLeft')=='OPEN' ? 'white' : '#7B879C'}}">
HL
</span>
</button>

any suggestion is greatly appreciated.

No one?
I can’t imagine, that no one uses contacts on habpanel

Hi

This is just a pure guess…

“Are contacts exposed to HabPanel”

Meaning, can you see the Contact item in a normal HabPanel widget?

Yes, I can select the contact item on e.g. the button widget.
And with the

the Text HL reflects the state open / closed correctly

I’ve never included the ==OPEN, I’ve always created three versions of the icon as that’s how the docs say to create variable icons…the garage example below is from a contact.

so in my case below…

Garage2.png
Garage2-open.png
Garage2-closed.png

<widget-icon iconset="'custom-icon'" icon="'Garage2'" size="120" state="itemState('LtGarageDrSensor2')" />

hmmm… that wouldn’t help me, because I just have one svg icon.
grafik

Thanks a lot for your help, though.

No one can help me to reflect the item state in th icon?
:cry:

<widget-icon iconset="'smarthome-set'" icon="'car_doorR'" size="32" state="itemState('CarDrReLeft')=='OPEN' ? 'ON' : 'OFF'" />

Thanks so much, Yannick.

So I assume, that the following syntax means: handle OPEN like the conditions for ON (of a switch) otherwise OFF.

I have tried before

state="itemState('CarDrReLeft')=='OPEN' ? 'OPEN' : 'CLOSED'" />

but this was obviously misinterpreted…
Thank you so much!!


:slight_smile:

:joy:
Fair enough.
You found one (of my numerous) gap in knowledge about programming.

The good Thing about openHAB is, that it enables people like me to look like a Programming pro (with the help of you guys @Kai, @ysc , @rlkoshak, @vzorglub) in comparison to my friends and family.
:joy: