# CustomWidget PopOver - Item from parameter does not use the configuration of the specific widget, but the last widget

**URL:** <https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980>\
**Category:** UIs\
**Tags:** widget, openhab3\
**Created:** [January 12, 2021, 8:22pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980 "2021-01-12T20:22:50Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [February 14, 2021, 5:40pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/21 "2021-02-14T17:40:03Z")

</div>

Thanks again,  
seems, that this works only while having the popover code directly within the “main”-widget _and_ having the popover action part of an (direct) f7-component.

Same as Jan did:

> [@muelli1967](#):
>
> i integrated the popover component into the „main widget“ and applied this in the popover component

So this works:

```
- component: f7-button
  config:
    action: popover
    popoverOpen: .detailList
  slots:
    default:
      - component: f7-popover
        config:
          class: detailList
          closeByBackdropClick: true
          closeByOutsideClick: true
          backdrop: false
          closeOnEscape: true
          style:
            --f7-popover-width: 400px
            --f7-popover-border-radius: 4px
        slots:
          default:
            - component: oh-list
              slots:
                default:
                  - component: oh-repeater
                    config:

```

Means, I can’t leverage the oh-card’s design and mimic that by f7-components - well: fair enaugh 😉

Thanks guys for your help!

---

<div class="post-metadata">

**Author:** ![muelli1967](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@muelli1967](https://community.openhab.org/u/muelli1967)\
**Post date:** [February 14, 2021, 5:44pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/22 "2021-02-14T17:44:15Z")

</div>

HI @RGroll, I have a follow up question. If i have 2 or more similar widgets in a site with the same popup and only by clicking again it shows the right one. this is a repeatable story. Is there a way to prevent this behaviour?

---

<div class="post-metadata">

**Author:** ![muelli1967](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@muelli1967](https://community.openhab.org/u/muelli1967)\
**Post date:** [February 14, 2021, 5:46pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/23 "2021-02-14T17:46:48Z")

</div>

> [@curlyel](#):
>
> Means, I can’t leverage the oh-card’s design and mimic that by f7-components - well: fair enaugh 😉

what do you mean by this?

---

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [February 14, 2021, 6:02pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/24 "2021-02-14T18:02:26Z")

</div>

I thought, I stick with the predefined layout of the basic oh-cells/oh-cards, e.g.:

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/d/d/dd53e471668309628489cc38c979ceaa0ee05dab.png)

… and just bother with some “details-widgets” as popover or popup to get a simple but similar look of the “top-level” UI elements.

Therefore I had a oh-label-card component in the above example with popover action.

If I can’t do this _(because the missing styling options for the popover)_ I can still build the same look using the _native_ f7-grid components.  
Not a big deal - but some more work 😉

---

<div class="post-metadata">

**Author:** ![muelli1967](https://community.openhab.org/letter_avatar_proxy/v4/letter/m/0ea827/32.png) [@muelli1967](https://community.openhab.org/u/muelli1967)\
**Post date:** [February 14, 2021, 6:07pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/25 "2021-02-14T18:07:03Z")

</div>

got it, true. I ended up in just using custom widgets :-), but i any way wanted more control over backgrounds, content and highlight colors… as well as usable for iphones

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/2/3/2304821171dcc3ca1e70d870fdd85e97f96ce416.png)

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/f/d/fd7eb904d5ec8a145201625dc87a46c15a41923b.png)

---

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [February 14, 2021, 6:37pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/26 "2021-02-14T18:37:55Z")

</div>

> [@muelli1967](#):
>
> wanted more control over

I think, I’ll follow this too though…

Some hidden limits with the oh-\* components may cost more time than it saves - finally … 😉

Even though I’ve managed the above task meanwhile:

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/f/af3b94f97e8365c9c557620a2a60ba52e4b1d15b.png)

I’ve put a f7-button over the oh-label-card:

```
component: f7-card
config:
  outline: false
  noBorder: false
  padding: true
  noShadow: false
  style:
    --f7-card-margin-horizontal: 5px
    --f7-card-content-padding-vertical: 0px
    --f7-card-content-padding-horizontal: 16px
    --f7-card-border-radius: 15px
    --f7-card-box-shadow: 0px 5px 10px rgba(0,0,0,0.15)
    --f7-card-header-font-size: 14px
    --f7-card-header-font-weight: 600
slots:
  default:
    - component: oh-label-card
      config:
        title: =(props.titel) || (props.mainItem) || "Set properties.. "
        icon: =(props.icon || "f7:battery_25")
        label: = (items[props.mainItem].state + " " + props.delimiter + " " + items[props.secItem].state)
        footer: =props.footerText
        noBorder: true
        noShadow: true        
    - component: f7-button
      config:
        action: popover
        popoverOpen: .detailList
        style:
          position: absolute
          top: 0px
          width: 100%
          height: 100%
      slots:
        default:
          - component: f7-popover
            config:
              class: detailList
              closeByBackdropClick: true
              closeByOutsideClick: true
              backdrop: false
              closeOnEscape: true
              style:
                --f7-popover-width: 320px
                --f7-popover-border-radius: 4px
            slots:
              default:
                - component: oh-list
                  slots:
                    default:
                      - component: oh-repeater
                        config:
                          for: i
                          sourceType: itemsWithTags
                          itemTags: LowBattery
                          fetchMetadata: semantics,widgetOrder,uiSemantics
                          filter: loop.i.state != "OFF"
                        slots:
                          default:
                            - component: oh-label-item
                              config:
                                icon: f7:battery_25
                                iconColor: red
                                footer: =loop.i.label
                                title: =loop.i.metadata.uiSemantics.config.equipment + loop.i.metadata.uiSemantics.config.preposition + loop.i.metadata.uiSemantics.config.location
                                item: =loop.i.name

```

---

<div class="post-metadata">

**Author:** ![Stephan\_K](https://community.openhab.org/user_avatar/community.openhab.org/stephan_k/32/71457_2.png) [@Stephan\_K](https://community.openhab.org/u/Stephan_K)\
**Post date:** [March 22, 2021, 10:12pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/27 "2021-03-22T22:12:52Z")

</div>

Can you please explain me how did you count the item state ( 0 von 17) ? 🙂

---

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [March 23, 2021, 11:44am UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/28 "2021-03-23T11:44:39Z")

</div>

> [@Stephan\_K](#):
>
> explain me how did you count

Sure 😉

That’s a good question, since the solution is not that obvious in openHAB3 😉

When checking the documentation for aggregation functions you may have noticed the `COUNT()` aggregation:

> **[Items](https://www.openhab.org/docs/configuration/items.html#derive-group-state-from-member-items)**
>
> a vendor and technology agnostic open source automation software for your home

Unfortunately, **the COUNT() aggregator is not selectable in the MainUI** of openHAB3.

BUT: You can work around that limitation by importing group items with COUNT() aggregators from textual configuration:

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/d/0/d0f4bf0284355e48fb7900a12b7db860e5ba1d2f.png)

This essentially adds two groups where one counts for empty and another count for good batteries.

A third group simply sums up the both which provides me the total number of batteries:

`NumOfEmptyBatts + NumOfGoodBatts = TotalNumOfBatts`

All BatteryLow-items belong to both count-groups - that’s it 😉

---

<div class="post-metadata">

**Author:** ![Stephan\_K](https://community.openhab.org/user_avatar/community.openhab.org/stephan_k/32/71457_2.png) [@Stephan\_K](https://community.openhab.org/u/Stephan_K)\
**Post date:** [March 23, 2021, 2:02pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/29 "2021-03-23T14:02:49Z")

</div>

Thanks that works great with your popup widget 😉

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [April 21, 2021, 7:58pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/30 "2021-04-21T19:58:30Z")

</div>

> [@curlyel](#):
>
> All BatteryLow-items belong to both count-groups - that’s it 😉

Nice trick. But how do you dynamically put your items into either of these groups, based their battery level ?

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [April 21, 2021, 8:07pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/31 "2021-04-21T20:07:20Z")

</div>

This works out of the box only with devices that support a low battery channel.  
if they don‘t, you need to create a virtual lowBat switch item and set it to on or off according to your defined treshold.

Edit : As COUNT supports a regular expression, it is worth to try

```auto
COUNT(<20)

```

Edit2: Hmmm, not working, as the validator does not like the „\<„, but also does not like a string, even the docs list it as possible.

Edit3:  
It should work with a virtual Item with the hysterese profile, linked to the batterylevel channel. This usage is noted in the profiles docu section…

---

<div class="post-metadata">

**Author:** ![curlyel](https://community.openhab.org/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@curlyel](https://community.openhab.org/u/curlyel)\
**Post date:** [April 22, 2021, 4:21am UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/32 "2021-04-22T04:21:42Z")

</div>

> [@mstormi](#):
>
> Nice trick. But how do you dynamically put your items into either of these groups,

Thanks Markus.  
I’ve put the lowbat items in both groups by hand… no fancy dynamic here 😉

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [April 22, 2021, 12:10pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/33 "2021-04-22T12:10:36Z")

</div>

> [@hmerk](#):
>
> Edit3:  
> It should work with a virtual Item with the hysterese profile, linked to the batterylevel channel. This usage is noted in the profiles docu section…

Yes, even including UoM i.e. you can set “3.0 V” as a limit. But you must select it to have a switch type, and it’s not a virtual item, it’s still bound to the channel that has the physical measurement (of battery voltage).

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [April 22, 2021, 12:12pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/34 "2021-04-22T12:12:32Z")

</div>

> [@mstormi](#):
>
> Yes, even including UoM i.e. you can set “3.0 V” as a limit. But you must select it to have a switch type, and it’s not a virtual item, it’s still bound to the channel that has the physical measurement (of battery

Sorry, you are wright, it is not a virtual item.

---

<div class="post-metadata">

**Author:** ![mstormi](https://community.openhab.org/user_avatar/community.openhab.org/mstormi/32/55857_2.png) [@mstormi](https://community.openhab.org/u/mstormi)\
**Post date:** [April 22, 2021, 12:15pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/35 "2021-04-22T12:15:06Z")

</div>

> [@hmerk](#):
>
> Sorry, you are wright, it is not a virtual item.

> **[wright - LEO: Übersetzung im Englisch ⇔ Deutsch Wörterbuch](https://dict.leo.org/englisch-deutsch/wright)**
>
> Lernen Sie die Übersetzung für 'wright' in LEOs ­Englisch ⇔ Deutsch­ Wörterbuch. Mit Flexionstabellen der verschiedenen Fälle und Zeiten ✓ Aussprache und relevante Diskussionen ✓ Kostenloser Vokabeltrainer ✓

🙂

---

<div class="post-metadata">

**Author:** ![hmerk](https://community.openhab.org/user_avatar/community.openhab.org/hmerk/32/56432_2.png) [@hmerk](https://community.openhab.org/u/hmerk)\
**Post date:** [April 22, 2021, 12:17pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/36 "2021-04-22T12:17:15Z")

</div>

😉

---

<div class="post-metadata">

**Author:** ![DrRSatzteil](https://community.openhab.org/user_avatar/community.openhab.org/drrsatzteil/32/63872_2.png) [@DrRSatzteil](https://community.openhab.org/u/DrRSatzteil)\
**Post date:** [May 4, 2021, 3:14pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/37 "2021-05-04T15:14:29Z")

</div>

Let me come back to this post from you Rainer: What you are doing there is fine since you only have static text in the popover. As soon as you want to show some item related info or controls in the popup I can confirm now that this does not work reliably. I have the following scenario:

I have two instances of the same widget on the same page. Both widgets try to open a popover which in turn shows stepper controls for a number item (I’m talking about my light control widgets). Since the class of the popover is hard coded in the widget there is no way for the browser to determine which element in the DOM should be displayed when you click in the link that opens the popover. I just realised this today when I always saw the popover with the item that was configured in the other widget but not the one I was clicking on.

So the solution still has to be the separate widget then which should work in any case. However I don’t think that anyone has solved the positioning issue yet…

Oh and by the way I tried to work around that by using a dynamic classname by reusing your suggestion from here: [New Stylesheet property - #5 by RGroll](https://community.openhab.org/t/new-stylesheet-property/120643/5)

Correction - It seems to work like this:

I use the name of the timer item as css class like shown in the code below:

```auto
          - component: oh-link
            config:
              text: Timer
              visible: "=props.shutdowntimer ? true : false"
              action: popover
              popoverOpen: '="."+props.shutdowntimer'
              style:
                position: absolute
                bottom: 10px
            slots:
              default:
                - component: f7-popover
                  config:
                    class: '=props.shutdowntimer'
                  slots:
                    default:
                      - component: oh-stepper-card
                        config:
                          item: =props.shutdowntimer
                          title: Ausschalten in Minuten

```

This way the class name may not necessarily be unique as you may use the same configuration in different widgets. However you would always open the control for the right item. This feels pretty hacky though since there may be problems when your item name is not a valid css class name or when you are using multiple items in your popover. In this case however you can always add a text property to the widget and leave the setting of a unique class name to the user. This is also not an excellent solution but should do in most setups.

---

<div class="post-metadata">

**Author:** ![Nico\_R](https://community.openhab.org/user_avatar/community.openhab.org/nico_r/32/41035_2.png) [@Nico\_R](https://community.openhab.org/u/Nico_R)\
**Post date:** [May 5, 2021, 3:54pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/38 "2021-05-05T15:54:46Z")

</div>

Same workaround here:

> [@OH3 Homekit Thermostat Control - Issue with PopOver](https://community.openhab.org/t/oh3-homekit-thermostat-control-issue-with-popover/117652/7):
>
> Other way is to define a popover class with a identifier. Like item name or something. Look at my heating widget.

I use a identifier to solve the task.

---

<div class="post-metadata">

**Author:** ![11194](https://community.openhab.org/user_avatar/community.openhab.org/11194/32/59282_2.png) [@11194](https://community.openhab.org/u/11194)\
**Post date:** [August 23, 2021, 6:28pm UTC](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980/39 "2021-08-23T18:28:23Z")

</div>

And for oh-repeater:

```yaml
                                  - component: oh-link
                                    config:
                                      iconMaterial: opacity
                                      color: '=items[loop.item.name].state == "ON" ? "blue" : "gray"'
                                      iconSize: 25px
                                      action: popover
                                      popoverOpen: ='.m'+loop.item.name
                                    slots:
                                      default:
                                        - component: f7-popover
                                          config:
                                            class: ='m'+loop.item.name
                                          slots:
                                            default:
                                              - component: f7-block
                                                config:
                                                  style:
                                                    animate: true
                                                    align-self: center
                                                    justify-self: center
                                                    justify-content: center
                                                    text-align: center
                                                slots:
                                                  default:
                                                    - component: Label
                                                      config:
                                                        text: Запуск вручную
                                                    - component: oh-button
                                                      config:
                                                        text: =items[loop.item.name].state
                                                        color: green
                                                        action: toggle
                                                        actionCommand: ON
                                                        actionCommandAlt: OFF
                                                        actionItem: =loop.item.name

```

[Previous page](https://community.openhab.org/t/customwidget-popover-item-from-parameter-does-not-use-the-configuration-of-the-specific-widget-but-the-last-widget/113980.md?page=1)
