Badge: state not updating?

Hi, so I made this list repeater for the alarms that have a RED/GREEN badge with state.
I switch on those alarms by rules but on the right made myself some debug switches for testing.
I noticed that the Badges are not updated in real time! I have to reload page to its status. Why?

The oh-toggle-item list to the right is updated fine if it changes from remote source.

Here is my code for the badge, quite simple, am I doing something wrong here?

component: oh-list-card
config:
  title: Alarms
  outline: true
slots:
  default:
    - component: oh-repeater
      config:
        for: i
        sourceType: itemsInGroup
        groupItem: gAlarms
        fetchMetadata: semantics,widgetOrder,uiSemantics
      slots:
        default:
          - component: oh-list-item
            config:
              title: =loop.i.label
              footer: =loop.i.name
              badge: =loop.i.state
              badgeColor: "=loop.i.state === 'OFF' ? 'green' : 'red'"

Yes. The repeater makes a call to OH API and collects the complete information about the relevant items, including the state of the item at the time the API call is made. The API, notably, returns the data as a JSON string which is static information. That string includes the state property, but that state property will never change unless the repeater runs again and re-collects the most recent up-to-data information.

Real time state updates must be handled by the items object. This is the only way for the widget expressions to get updates of item states in response to state changes.

So, loop.i.state will always just be the state when the repeater was rendered, but items[loop.i.name].state will be the reactive real time state.

3 Likes

or @@(loop.i.name) (if you need the actual raw state, equivalent to the above) or @(loop.i.name) (if you’re fine with the “display state” which may have formatting)

1 Like