Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close popup after time x #279

Closed
simaovienna opened this issue Dec 20, 2021 · 8 comments
Closed

close popup after time x #279

simaovienna opened this issue Dec 20, 2021 · 8 comments

Comments

@simaovienna
Copy link

hello, is it possible to call the browser_mod.close_popup service with a delay when opening a popup to auto close it when its not closed by the user?

thanks
simon

@chezpaul
Copy link

That would be very cool indeed

@KTibow
Copy link
Contributor

KTibow commented Dec 20, 2021

Outline for how this could work (from someone who doesn't know how browser-mod works at all):
When the popup is called, setTimeout is called. It has a reference to the popup object. If the user closes the popup, or another popup opens, clearTimeout is called, using the timeout's id.

@Dino-Tech
Copy link

Dino-Tech commented Dec 22, 2021

Since the auto close feature was added way back when... I have been using the browser_mod.close_popup service at the end of my popup scripts with a delay of 'x' minutes and also browser_mod.close_popup at the beginning of each popup script so they don't have any conflicts when the new one is called. E.g. a motion sensor triggers, fires script for camera popup with auto close, then delay kicks in for preset minutes, then closes if no one has manually closed it. Simple, but effective.

browser_popup_2:
  sequence:
    - condition: state
      entity_id: input_boolean.disable_inside_popups
      state: "off"
    - service: browser_mod.close_popup
    - service: browser_mod.more_info
      data:
        entity_id: camera.entry_hall
        large: true
    - service: tts.google_say
      data:
        entity_id:
          - media_player.pixel_fully
      data_template:
        message: "Entry hall motion detected!"
    - service: input_select.select_option
      data:
        entity_id: input_select.alert_type
        option: alert
    - delay: "00:00:20"
    - service: input_select.select_option
      data:
        entity_id: input_select.alert_type
        option: stop
    - delay: "00:02:00"
    - service: browser_mod.close_popup

@simaovienna
Copy link
Author

simaovienna commented Dec 23, 2021

thanks for your replies - is there a way to call a script here?

action: fire-dom-event
browser_mod:
command: popup
title: >
[[[ return entity.attributes.friendly_name; ]]]

or do i have to put the whole code in a script? i am a little bit lost here...

@Dino-Tech
Copy link

I have always used scripts for my popups. The only time I have used fire-dom-event is when there is a need to open a popup from a popup that is already opened. Anyone feel free to correct me on this...I'm a bit rusty here. There are plenty of structured examples of almost every possible type of popup located within my repo. I think I was around 100+ various types and styles of popups listed and still used in my HA setup at home.

@simaovienna
Copy link
Author

Thanks @Dino-Tech I will give it a try...

@simaovienna
Copy link
Author

update, for me this additional code does the trick:

tap_action:
  services: >
    [[[
      hass.callService('script', 'turn_on', {
        entity_id: 'script.close_popup'
      });
    ]]]     

@thomasloven
Copy link
Owner

Closed because of Browser Mod 2.0 release.
Please see #354.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants