- context: item
description: Item for Room
label: Room Item
name: selected
required: true
type: TEXT
but while my widgets are running without errors, I keep getting this warnings in my logs…
any ideas how to prevent this? for me it seems openhab is struggling to get the selected roomname or playername or similar referred by the props.selected name?!?
Don’t get me wrong, it’s not a big problem to me, but I would like to avoid that from happening
If any further info is needed I hope I can provide it
You are right. In fact it’s not a problem at all which is why it is given a WARN level and not an ERROR level. That said, I agree if it happens frequently it can make sifting through logs for actual information more difficult.
If you take a look at the warning, however, there’s a clue how to fix it:
[WARN ] ... an item which doesn't exist: Light-Color
Your naming scheme doesn’t include a - in it anywhere, so that part is what’s being added by your expression. That is consistent with the way the items object works in the widget expressions. items is not just a simple dictionary returning values when they exist and undefined when they don’t. Any time items would return an undefined or null (js not OH ‘NULL’ state) it returns - instead. So when you see Light-Color in the warning that means items[props.selected] is not returning a state that you expect.
So, you still want to test for a value before creating the item name string in your expression, but you are not testing whether props.selected exists, you want to test whether items[props.selected].state returns an actual value or -:
In the long run, however, since props.selected is a value that you control (i.e., have manually configured) you should also try to work out why this item, if it exists at all, is giving some invalid state response. The test solution above effectively masks the problem, but it would be even better for page loading speeds and long term stability to avoid the situation entirely, if possible.
I think I understood all of this - my problem is that props.selected is bound to a valid string-item with a valid text-string in it which represents the room. The widget is working so far… but I don’t really get why js can’t get the state of a valid item.
Your fix (and the previous from Oliver) are adressing the problem when the props item is empty - but that seems always the case although it is not… and I can’t understand why…
but I will try what changes if I try your fix for the “-”…
edit:
ok I tried your code, but the warnings still appear, after using your code it seems they are only shown once not everytime I enter the widgets page… but after closing and restarting the android app the warnings reappear!??
even if this don’t fixes the problem completely it reduces the amount of appearances in the logs a lot
This assumption: “a valid string-item with a valid text-string in it which represents the room” The existence of this item is less likely to be an issue unless you are doing something strange with dynamically created items, so the assumption that the item state always contains the name of a valid item should be looked into. How is this item set? Do you persist the value of this item? If you do persist it, is it restored on startup?
The exact same warning is produced no matter what widget encounters the warning. Are there any other widgets that might also check an items with the prefix + suffix pattern? If so, you need to change those widget expressions as well. Are you sure it is the same warning and not a warning about some other item that cannot be found? It can sometimes be pretty difficult to track down all the places where a such a non-existent item call can be made.
The fact the you see the pattern where the warning appears when you start the android app leads me to think the issue is more liekly to be #2.
If the Item wouldn’t be present all the time my widget would fail regularly which isn’t the case. But everything is working fine all the time except from the warnings… so for me it seems OH can handle the combined items but js is missing the middle part… I don’t really understand how this can be…
All my items are persisted on change with influxDB and on startup mapDB is used
Yes I have this in mind… the warning is always the same, the variable part is replaced with a “-”
and prefix and suffix varies…
edit:
thanks Oliver you answered while I was answering Justin’s post