Oliver2
(Oliver)
December 16, 2020, 2:27pm
1
How can I “force” itemValue() function to return “original” item state instead of mapped item’s state?
.item:
String Mondphase "Mondphase [MAP(astro.map):%s]" <mymoon> (gAstro) { channel = "astro:moon:local:phase#name" }
.map
WAXING_CRESCENT=zunehmender Halbmond
FIRST_QUARTER=erstes Viertel
HABPanelwidget
<span><widget-icon iconset="'custom-icon'" icon="'mymoon'" size="28" state="itemValue('Mondphase')" /></span>
HABPanel tries to open
mymoon-zunehmender Halbmond.svg
instead of
mymoon-waxing_crescent.svg
I double checked with REST API: WAXING_CRESCENT is the correct state.
However: sitemap (App or BasicUI) show correct icons
Oliver2
(Oliver)
December 25, 2020, 4:30pm
2
Could somebody please confirm, that this is not a bug in HABpanel?
Based on the above config HABpanel creates html code with a mapped item state:
<img ... ng-src="/icon/mymoon?format=svg&state=zunehmender Mond" src="/icon/mymoon?format=svg&state=zunehmender Mond" ... ;">
However, Basic UI creates html code with original unmapped state:
<img data-icon="mymoon" src="../icon/mymoon?state=WAXING_GIBBOUS&format=svg&anyFormat=true">
rossko57
(Rossko57)
December 25, 2020, 6:16pm
3
Yes, dynamic icons are selected based on raw, unmapped Item state.
It looks like your HABpanel widget is incorrect.
Oliver2
(Oliver)
December 25, 2020, 6:31pm
4
many thanks!
I am lost. I have been searching for my error a few days now.
Do you know where the error is when using this tag?
<widget-icon iconset="'custom-icon'" icon="'mymoon'" size="28" state="itemState('Mondphase')" />
rossko57
(Rossko57)
December 26, 2020, 1:27am
5
Oliver2
(Oliver)
December 26, 2020, 3:38pm
6
yes, I follow exactly the same path. The main difference is, that my item states are mapped and I do not know how to specify to use unmapped (raw) item states.
@ysc : Yannick, sorry for bothering you. Could you please give me a hint how to force HABpanel to return raw item states?
<widget-icon iconset="'custom-icon'" icon="'mymoon'" size="28" state="itemState('Mondphase')" />
is returning mapped states.
Many thanks in advance
ysc
(Yannick Schaus)
December 26, 2020, 6:25pm
7
No problem, it’s relatively obscure, see here:
This Wiki post aims to be a centralized resource to help new users (and experienced users alike!) with the advanced features in HABPanel. It will contain relevant examples and links to help you with common issues and getting the most out of these features!
Users with the “Member” badge (and levels above) can edit this post, don’t hesitate to do so if you deem it appropriate
Templates & Custom Widgets
What are templates?
If the standard widgets don’t fit your needs or your taste, HAB…
The second boolean “ignoreTransform” argument to itemState will ignore the transformations when set to true. It is false by default if omitted.
So state="itemState('Mondphase', true)"
2 Likes
Oliver2
(Oliver)
December 26, 2020, 7:32pm
8
I am ashamed. I really read that post but I have overseen this. Many thanks for that - now everything is working perfectly.