I have been working on my CADDX Generic Alarm Widget to try and clean up some errors as follows:
11:18:53.847 [WARN ] [se.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: Partition5_Armed
11:18:53.847 [WARN ] [se.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: Partition6_Armed
11:18:53.847 [WARN ] [se.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: Partition7_Armed
11:18:53.847 [WARN ] [se.internal.SseItemStatesEventBuilder] - Attempting to send a state update of an item which doesn't exist: Partition8_Armed
The reason is that though the alarm caters for up to 8 Partitions, there may only be 1 or 2 (in my case 4) configured and in use.
I am trying to find a way to fix my expressions to not generate the errors when the missing Partitions are encountered. But I would still like the full 8 partitions to be displayed - with the extra ones just greyed out as disabled:
First off, these are just warnings and not errors. They do no harm, they are not indicative of any significant problem, and, you can very comfortably just ignore them and go on with your day.
These warnings derive from the way the widgets work. It would be incredibly inefficient for the UI to send the complete list of items to every widget and update that with every item change when most widgets only need the information about a small handful of items. So, as each widget runs, it keeps a list of all the items that are accessed using the items object and just registers those items with the event stream listener in order to be able to track changes to the minimum number of items. If an item is referenced that doesn’t exist, the UI spits out this warning, sets the item’s values to -, and carries on perfectly happily. I suspect the original intent of this warning was just as a check to the widget developer to let you know where to find a potential malfunction in case you are expecting all of the items referenced in the widget to exist.
The upshot here is that as long as you need to run a check about whether or not an item exists in a widget (i.e., there is a chance an item will not exist) you will get this warning.
It is possible to work around this? Sure, I could conceive of a couple of different ways of refactoring this widget to not have to reference non-existent items. The problem is that all of them would be way more complicated and/or require extra pieces (possibly an additional rule, or proxy items…or both). Because this is just a warning this extra effort really isn’t worth it. If it really bothers you to see these in your logs it’s almost certainly less effort to edit your logging to filter them out.
On an unrelated note: if you’d like to clean up the widget code just the tiniest bit, it’s not necessary to list out a number array like that in a repeater. Repeaters have a range option for sourceType which lets you specify a rangeStart and rangeStop property to get a numerical list like this.
Thanks Justin. Once again your explanation etc. makes perfect sense. I guess I must just suppress my OCD tendencies
You suggestion did however spark an idea that I tried.
I set up a property for the range
props:
parameters:
- default: 8
description: Numbers of Partitions in System
label: Numbers of Partitions in System
name: numberPartitions
required: false
type: TEXT
When using the default value - 8 the plan works perfectly. However if I enter a value via Props the rangeStop expression seems to give an incorrect value - this is always 10x the value entered.
EDIT: Also, if I do not enter a value for the props - the default appears to be 10. And entering 0 produces the expected 0.
EDIT 2: So it seems the following ALMOST works:
- default: 8
description: Numbers of Partitions in System
label: Numbers of Partitions in System
name: numberPartitions
required: true
type: INTEGER
The problem is now that when I save the widget, exit the widget editor and go back in the default: 8 has been changed to default: "8" which breaks the whole thing?
Any ideas?
EDIT 3: This seems to be specific to the Widget Editor. When the widget is called from a oh-cell etc the correct prop is used.