Custom Widget, dynamic list - filter on thing status

I have a widget that displays the result of a thing status monitoring mechanism, where all devices (things) are represented by a dummy item that is ON when the device is operating, and OFF when it is not. The dummy items are set in different rules depending on device functionality etc.

component: f7-card
  title: Unavailable Devices
    - component: f7-card-content
          - component: f7-list
              mediaList: true
                - component: oh-repeater
                    filter: loop.item.state == "OFF"
                    for: item
                    fragment: true
                    groupItem: vServiceAvailability
                    sourceType: itemsInGroup
                      - component: oh-list-item
                          icon: f7:exclamationmark_bubble
                          iconColor: red
                          title: =loop.item.label

What I would like to acheive is to filter the results so all Things that are “DISABLED” (uninitialized) are not included in the results. But I haven’t found a way to do this effectively.

I have a rule that can detect the thing status and discover if a Things is disabled:

var vThingStatus = getThingStatusInfo(vThingUID).getStatus()
			  	//logInfo("ThingStatus:", "vThingUID: "+vThingUID+ " Status: "+vThingStatus)
                if ((vThingStatus.toString())=="DISABLED") 
				  	< do something>

And maybe this can be used - I just haven’t found any good way to make use of this. Also if there is a way in the widgets to do “loop.thing.state” this would be much more effective, but I’ve tried this in all sorts of ways which didn’t work.

1 Like

No. There is no direct access to Things in the widgets. The only access is by setting up some system of proxy items, as you have done.

Probably the simplest solution is to update your thing status rules so that if the Thing is disabled you set the proxy item state to NULL. OFF state does not equal NULL state, so these Items will already be filtered out by the repeater code you have.

This works like a treat, and took 5 min to implement. Thanks man! :metal:

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.