Good afternoon.
I am working on a widget that will display the state of items that will be in a group (a Notifier widget)
The widget will be an oh-list and use a repeater to parse the states of items in a group.
Here is the setup:
- the item group is called
notify_group
- an example item:
notify_Roborock_Dock_State
- the state for the
notify_Roborock_Dock_State
which I would use as a false:No error
What I am attempting to do is create a custom metadata that contains an icon name and the state of the item that is considerted to be ‘false’, meaning there are no issues.
The example item is also an item i created that uses the ‘Dock Status’ string channel for the Xaomi binding. If there is a ‘true’ evaluation i will display the state, for example 'Error fresh water tank’.
The custom metadata I have added the the above item is called ‘notifier’ and is as follows:
value: " "
config:
icon: robot
falseState: No error
Here is a snippet of the code that I am attempting to use to evaluate, but I definately need some guidance. I have been reading as many posts as I can find, but am not having any luck as I am trying to piece together a bit of information from several posts so my evaluation statement may be completely incorrect. The snip is also based on widget yaml from another post which I am trying to update for my goal.
The line for the badgeColor is where I am attempting to use some expression parsing for the metdata. I realise the iconColor and badge lines will not work properly as they are written.
- component: oh-repeater
config:
for: item
sourceType: itemsInGroup
groupItem: =props.item
fetchMetadata: notifier
slots:
default:
- component: oh-list-item
config:
title: =loop.item.label + " " + loop.item.state
icon: f7:ant
iconColor: '=loop.item.state == "ON" ? "green" : "red"'
badgeColor: '=loop.item.state == loop.item.metadata.notifier.value.config.falseState ? "green" : "red"'
badge: '=loop.item.state == "false" ? "OK" : "ERROR"'
A thought as well, can the evaluation be stored in a variable which could be used on the iconColor, badgeColor and badge statements instead of evaluating the metadata multiple times for the same information?
Hope this information has enough details for what I am trying to achieve!
Thanks for your help
Craig