[Solution] Open popup/popover by rule or item state

this is the code I am currently using. It is just the popup which I placed somewhere on the page (does not matter where)

uid: popup-cam
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Mar 4, 2023, 5:41:41 PM
component: f7-popup
config:
  closeByBackdropClick: true
  opened: =(items.vPopupCam.state == 'ON') ? true:false
  tabletFullscreen: true
slots:
  default:
    - component: oh-image
      config:
        lazy: false
        refreshInterval: 100
        style:
          max-width: 100%
          width: 100%
        url: ='http://192.168.178.69/record/current.jpg'
    - component: oh-button
      config:
        action: command
        actionCommand: close
        actionItem: vPopupCam
        style:
          --f7-button-bg-color: transparent
          --f7-button-hover-bg-color: transparent
          --f7-button-pressed-bg-color: transparent
          height: 100%
          left: 0px
          position: absolute
          top: 0px
          width: 100%
          z-index: 15
      slots:
        default:
          - component: f7-icon
            config:
              f7: xmark_rectangle_fill
              style:
                font-size: 50px
                position: absolute
                right: 15px
                top: 15px
                vertical-align: middle
              textColor: white

The f7 icon (x) is unnecessary/redundant. It is just for WAF as my wife complained there is no button to close the popup

Hi,

Thanks for the quick reply, no the page doesnā€™t grey or show any signs of a hidden pop up.

Iā€™m triggering it by change of item state, when the doorbell rings a rule sets the state to ON.

For your code, rather than displaying a URL can it use an item image? I have an item in OH that holds the latest snapshotā€¦

EDITā€¦itā€™s sort of workingā€¦I think I had a typo somewhere, Iā€™ve C&P it all back in and I now get the popup, but itā€™s blank as the URL I have goes no whereā€¦

So the only question is whether / how I can use the item as the image to display.

yes sure. simply remove the url and add the following:

item: itemWhichHoldsTheImage

But remember. If you used the url which points to the current image of the camera, you will see a video

item: itemWhichHoldsTheImage

Thanks, tried that but still an empty pop up. Iā€™ve added an image widget which is the item snapshot in question to the main page to check itā€™s correctā€¦but you can see the blank pop upā€¦

Sure itā€™s something simpleā€¦thanks for your help so far, Iā€™ll take another look with fresh eyes in the morning.

add a label to check if the popup is showing some content, like this:

slots:
  default:
    - component: Label
      config:
        text: Test
    - component: oh-image

could you copy the complete yaml code?

Hi,

Added a label and yes that appears:

Full YAML (It is pretty much verbatum from your example as a test)

The trigger is vDoorBellPress switch item and the image Iā€™m trying to show is called FrontDoor_Snapshot, and is the same item shown bottom right of the page shown above so I know it is working.

uid: doorbell_frontdoorpopup
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Mar 7, 2023, 10:26:13 PM
component: f7-popup
config:
  closeByBackdropClick: true
  opened: =(items.vDoorBellPress.state == 'ON') ? true:false
slots:
  default:
    - component: Label
      config:
        text: Test
    - component: oh-image
      config:
        lazy: false
        refreshInterval: 100
        style:
          max-width: 50%
          width: 50%
        item: FrontDoor_Snapshot
    - component: oh-button
      config:
        action: command
        actionCommand: close
        actionItem: vDoorBellPress
        style:
          --f7-button-bg-color: transparent
          --f7-button-hover-bg-color: transparent
          --f7-button-pressed-bg-color: transparent
          height: 50%
          left: 0px
          position: absolute
          top: 0px
          width: 50%
          z-index: 15
      slots:
        default:
          - component: f7-icon
            config:
              f7: xmark_rectangle_fill
              style:
                font-size: 50px
                position: absolute
                right: 15px
                top: 15px
                vertical-align: middle
              textColor: white

I might look to set up the live view rather than a snapshot but Iā€™d rather work out what is wrong here for the learning experience, (or find out where Iā€™ve been stupid)ā€¦then I can develop it.

Could you delete these attributes?
The popup in general works as can be seen at the image placeholder

Not related to this problem, but:
Is vDoorBellPress a string item or on/off item (switch)? If switch you need to replace close by off
And the height of the button needs to be 100%, otherwise its size is 50% of 50%

Hi,

Thatā€™s got it workingā€¦deleted the lazy: false etc and now the image showsā€¦amazingā€¦

Final question, it now loads the image but only the top corner of itā€¦is there a way to get it to auto resize to the size of the popup?

In general (and I think you already did that) you need to set the desired size of the popup and have the size of oh-image component set to 100%.
If you see just a part of your image in the popup (and I assume there is no wasted space arund your oh-image) your resolution is larger than your device.
Either reduce the resolution of the image source or you can start trying around with

style:
  -webkit-transform: scale(0.7)

to shrink the image.

@JustinG is a very helpful expert for css related questions. Do you have any other advice?

Thanks, Iā€™ve had a different thoughtā€¦

Could this widget open up a different page in the popup rather than an item? That way, the page is already formatted and you get a little more freedom in the contentsā€¦

Iā€™ve fiddled with the YAML, essentially Iā€™ve tried to add in a modal to a ā€˜cameraā€™ page Iā€™ve createdā€¦the pop up comes up as expected but Iā€™m back to a blank page, is there a setting Iā€™m missing or is it not possible to link to a page in this way?

uid: doorbell_frontdoorpopup
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Mar 8, 2023, 3:27:21 PM
component: f7-popup
config:
  closeByBackdropClick: true
  opened: =(items.aDoorBellPress.state == 'ON') ? true:false
slots:
  default:
    - component: oh-image
      config:
        actionModal: page:camera
    - component: oh-button
      config:
        action: command
        actionCommand: off
        actionItem: aDoorBellPress
        style:
          --f7-button-bg-color: transparent
          --f7-button-hover-bg-color: transparent
          --f7-button-pressed-bg-color: transparent
          height: 50%
          left: 0px
          position: absolute
          top: 0px
          width: 50%
          z-index: 15

If you donā€™t specify a width (height works too, for that matter) then the oh-image will always stretch to fit the image you give it. You can use a % width in this case, because the image is a child of the popup which has a defined width value of its own.

Not really no. Although pages are constructed in a similar format to widgets, the two are not really interchangeable. ā€œWidgetsā€ are just UI elements. ā€œPagesā€ in MainUI app are destinations that you can navigate to within the framework of the app that just happen to have widgets on them.

If you wan this item-based control the the popup then you are constrained to building the widget you want to have as the popup.

This will never trigger automatically. Widgets actions can only be initiated by interaction with the component. Thatā€™s why you cannot use the oh actions here to navigate to a page and must use the f7-popup method which you can control without direct interaction with the component.

Ah, that does make senseā€¦shameā€¦but it does make sense!

Just be aware: if you enable this you can close the popup but the popup triggering item is still ā€žONā€œ. This might lead to unexpected behaviour.

Yes, thanks, the trigger item is on from a rule which counts for 10 seconds and then turns it off again so thatā€™s when the pop up closes.

Iā€™m probably going to get rid of the manual X to close as it wonā€™t be needed.

Thanks for all your help, Iā€™m off to do some more YAML learning.

EDIT

Iā€™m trying to get the popup to open a page rather than an image, Iā€™ve been going around the houses with the config, what is wrong here please?

Concept - when vPagesPopUp item is set to HOME, it should open pop up a page called camera.

When the vPagesPopUp is then set to OFF it closes the popupā€¦

uid: home_popup
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Mar 13, 2023, 3:20:53 PM
component: f7-popup
config:
  closeByBackdropClick: true
  opened: =(items.vPagesPopUp.state == 'HOME') ? true:false
slots:
  default:
    - component: oh-link
      config:
        action: popup
        actionModal: page:camera
        style:
          width: 75%
    - component: oh-button
      config:
        action: command
        actionCommand: OFF
        actionItem: vPagesPopUp
        style:
          --f7-button-bg-color: transparent
          --f7-button-hover-bg-color: transparent
          --f7-button-pressed-bg-color: transparent
          height: 50%
          left: 0px
          position: absolute
          top: 0px
          width: 50%
          z-index: 15