Widget: using string within itemValue

Hi Guys,
i try to use a string as part of my itemValue extract.

See:
Type: Item
ID: timerending
Default value: Kueche_Timer_Ending

Type: String
ID: room
Default value: Kueche

Code:
{{itemValue(config.timerending)}} -> 2018-01-03 11:06:19
{{itemValue(‘Kueche_Timer_Ending’)}} -> 2018-01-03 11:06:19
itemValue(’{{config.room}}_Timer_Ending’) -> itemValue(‘Kueche_Timer_Ending’)
{{itemValue(’{{config.room}}_Timer_Ending’)}} -> will cause all values to fail and simply print out e.g. {{itemValue(’{{config.room}}_Timer_Ending’)}}

How can i make the string part of my itemValue to get the correct output?`

Thanks
Andreas

Just one other idea,
would it be possible somehow to create a string setting with ID: room
and then create an Item with ID: timerending and the default value would be then: {{room}}_Timer_Ending or so?

Thanks
Andreas

What’s inside {{ }} is an expression so you can’t interpolate strings, rather should use the standard Javascript syntax:

{{itemState(config.room + '_Timer_Ending')}}

https://www.w3schools.com/angular/angular_expressions.asp

Hello Yannick,
i guess i said it once a while ago, i will say it again: YOU ARE THE MAN!
Thank you very much. Seeing this now makes absolute sense and i am a bit grumpy about not finding this out myself.
It makes all my widgets now much easier for me.

Thanks
Andi

1 Like