Battery Level Status

i’ve used displayState in a repeater many times and never had a problem. I’m not sure why you are seeing anything differently.

Click on the black widget editing icon above the widget and select “Configure Widget”. Set the properties called for. One will be a Group with all the Battery Items as members.

Thanks Rich. Appreciated.

I am getting NULL for minimum battery level. Is there something I need to configure to fix this part?
Screen Shot 2021-11-20 at 1.12.01 pm

Did you define the Group with the MIN aggregation function? If so has any of its members been updated since adding the aggregation function? Are all members of the Group a Number type Item.

That that was it Rich. I didn’t even know you could, thanks for the pointer!

One other question, to round the number values to 1 decimal place. I have added a Metadata stateDescription and added %.1f to the Pattern field. But it does not seem to be working? Is there something simple I am missing?

value: " "
config:
  pattern: "%.1f"
  step: "1"
  min: "1"
  max: "100"

It might be related the behavior that @wars is seeing. I don’t have an explanation nor a suggestion yet.

Has this something to do with this? Formatting date/time of a label-item (within a list-card-widget in a page) with YAML - #32 by ysc

I knew we had a discussion before :grin:

It could be based on the binding the readings come from. All my battery levels I care about come from MQTT so I wouldn’t have noticed this issue here.

Mine are also coming from MQTT, all my items have a state description ("%s %%"), but none of them are showing in the widget… I actually have this issue with all my widgets where a repeater is included.

Then that thread doesn’t apply. The issue in that thread you linked to is when the binding supplies a state description which sometimes overrides the State Description metadata. The MQTT binding doesn’t do this.

In my case the values from the GPS binding are displaying rounded to a whole number where as the values coming from the iCloud binding are coming through with 15 decimal places, a little more accurate than needed for battery levels.

I might run the raw values through a rule every 10mins and display a proxy item.

Thanks for your help!

Nice Widget, just for fun i modified for dynamic icon. But now i do´nt have colored icon any more. I did´nt change the Code behind iconColor:

dynamic Icon´s in generall do´nt have colors? Or any chance to get them colored by iconColor:?

The icons were already dynamic. It shows a full green icon over 75%, orange partial icon between 25% and 75% and red empty under 25%.

These are not OH icons though. If you are using oh icons, the color is what ever the color is in the image file.

OK, in your widget you use F7 Icons. I have modified the F7:Iconfile to more segments/steps. But since i have to save them in openhab/icon folder and in code they have to be used like oh:icons :man_facepalming: they lost the ability to be colorized like F7.

OH will only colorize f7 icons - i have learned know, thanks

In the end i have also lerned, no need to make dynamic battery icons meself, OH allready have :wink:
just learning OH-UI

I found the solution, thanks to nikos7179

badge: "=(items[loop.item.name].displayState === undefined) ? loop.item.state : items[loop.item.name].displayState"

Now, my displaystates are showed!

@rlkoshak I have another (maybe more general) question about a function I would like to add.

Let’s say I setup the variables so that it only shows battery levels below 50% (props.max). I would to like to be able to click somewhere in the widget so it shows all values, so it actually ignores the filter. This click can be on the title, oh-repeater component or footer (I use a footer in all my list widgets). I know there is a accordion component, but don’t know how to integrate this. Or maybe there is another better solution to show ALL items on demand, without setting up a different widget.

I’m sure something like that might be possible but I’m not wizard at UI Widgets and wouldn’t know how to make it happen.

Accordion will be 100% manually defined based on my experience. You can’t use it with a repeater and you have to manually add each Item to the list.

But you could create a container card that contains both the repeater and the accordion elements.

I guess you could create a switch item for that purpose and add a link or button to toggle it on or off. Based on this items state you may then show or ignore items on the list.

Continuing the discussion from Battery Level Status:

I am not a code expert but enjoy learning and I’ve reached a stop wall. A hand would be more than welcome. I have an accordion list with battery status, but I am not being able to remove the “null” state next to the badge that shows the right battery remaining.

This is the code for each battery element:


```yaml
component: oh-list-card
config:
  accordionList: true
  simpleList: false
  outline: true
  footer: estado de baterĂ­as..
slots:
  default:
    - component: oh-list-item
      config:
        title: BATERIAS
        icon: =(items.gBatteries.state>20)?items.gBatteries.state>50?"f7:battery_100":"f7:battery_25":"f7:battery_0"
        iconColor: =(items.gBatteries.state>20)?items.gBatteries.state>50?"green":"orange":"red"
        iconUseState: true
        badge: =items.gBatteries.state+' %'
        badgeColor: =(items.gBatteries.state>20)?items.gBatteries.state>50?"green":"orange":"red"
        listButton: false
      slots:
        accordion:
          - component: oh-list-card
            config:
              accordionList: true
              noBorder: true
              noShadow: true
              outline: true
            slots:
              default:
                - component: oh-list-card
                  config:
                    accordionList: true
                    noBorder: true
                    noShadow: true
                    outline: true
                  slots:
                    default:
                      - component: oh-label-item
                        config:
                          title: Planta Alta
                          icon: =(items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state>20)?items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state>50?"f7:battery_100":"f7:battery_25":"f7:battery_0"
                          iconColor: =(items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state>20)?items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state>50?"green":"orange":"red"
                          style:
                            color: =(items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state >
                              20)?'white':'red'
                          badge: =items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state+' %'
                          badgeColor: =(items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state>20)?items.ZWaveNode009PAZW100Multisensor6_BatteryLevel.state>50?"green":"orange":"red"


![screenbatteries|210x500](upload://nlBOy7Ns2CpZm75P0DGb9X3gW70.png)

Set the state description pattern to a space and that will suppress showing the state.

Thanks a lot Rich,

In the end, changing the oh-label to oh-list in the header made the trick and stopped showing the state outside of the badge. Thanks!