When using the [ ] notation to access an object’s properties, the code inside the brackets must evaluate to a string. That means you either have to use a variable that is currently assigned a string value or put the actual text you want inside quotes. Right now the expression tester is trying to use ZWaveNDKantoor_Switch as a variable and since this variable doesn’t have a value you’re getting items[NULL].state which always evaluates to false. Try
Thanks, that did the trick, Perhaps a follow-up question. I’d like to the use props.item to avoid having to type in a lot of item names. Is that possible in the standard listWidget metadata? I cannot get it to work somehow. The expression always resolves to the else part.
If you include a parameter with the name of item in a widget and assign that widget as the default standalone or list widget for an item, you don’t even need to configure the item property in the metadata, the UI will automatically populate the item parameter with the name of that item.
Here’s an example:
The parameters for my custom list item for blinds look like this:
- description: Label to show
label: Item Label
- context: item
description: An item to control
In the metadata for one of my blinds items I have:
Thanks. But what I’m trying to do is to keep the default OH widget and avoid custom widgets. When I use the default OH widget the breadcrumb works fine in the equipment tab. With a custom widget the breadcrumb does not seem to work. I guess I have to stick with the specific reference to an item name if I want to keep the default OH behavior.
Nope. I could not get it to work with the standard out of the box widget. It requires a custom widget but then some other features are not available (breadcrumb) or at least I could not get it to work so I gave up for now.