#Switch Dashboard tab after timeout

1 messages · Page 1 of 1 (latest)

tight thorn
#

Hey, I was wondering if it is possible to change to a specific tab after some time of inactivity. I have a Amazon Fire HD tablet mounted on my wall as a dashboard running HA Companion App with always on display.

I have my „default dashboard tab“ and some other tabs for controlling specific groups of devices (for example all my lamps or all my sensors). They all have their own tab. So if I want to change the brightness of my lamp I switch to the „lamp“ tab, change it and then sometimes forget to switch back to my „default dashboard tab“.

Is there a way to automate that? So that it switches back to the „default dashboard tab“ after some inactivity?

I would appreciate any suggestions on how I can fix this 😊
Thanks

harsh wedge
tight thorn
#

Actually I like the Companion App how it is. I was thinking about using „fully Kiosk“ but I don’t know how this would solve my problem

harsh wedge
#

or rework your dahboard UX so the light is showing for the dashboard on the tablet without having to change views.

tight thorn
harsh wedge
#

with FK you can reload to default page (or navigate to specific) along with a bunch of cool things.

tight thorn
tight thorn
harsh wedge
#

if you use webui on a browser instead of companion app you could maybe do this with browser_mod (although maybe that works in app too, i dont think so though)

tight thorn
#

Maybe it’s also possible to write some JS in the background to check for inactivity and then switch the tab

tight thorn
#

So in theory it should work

#

Maybe I could also add a sensor based on the last activity from the tablet

harsh wedge
tight thorn
#

I will look into browser_mod and see if someone already did something similar.

harsh wedge
#

granted its been a while since i set it up but it can do a bunch of stuff and integrates well

tight thorn
harsh wedge
#

i have the companion app running in the background on it too for some other sensors

harsh wedge
tight thorn
harsh wedge
#

my "temporary setup" which I keep meaning to improve but works... so its low priority. plus work being done in there soonish too so not worth doing until that plan is sorted out

#

"nothing more preeminent than a temporary setup" 😛

tight thorn
#

That’s my permanent setup 😅

harsh wedge
broken loom
#

Consider browser_mod. Similar to Fully Kiosk Browser, it will give you some entities to work with for the browser/app. There's a binary sensor that acts as a motion detector but it really shows the screen interaction. There's also a sensor that shows its current browser path.
With those, you could set up an automation when the "motion detector" changes from Detected to Cleared for 10 minutes, then browser_mod.navigate to the default dashboard.

#

(The screenshot above is for Firefox running in Kiosk Mode on a Windows 11 PC with a 24" touchscreen monitor. The dashboard also uses the Kiosk Mode dashboard-addon. The same concept would apply for the HA app.)

tight thorn
tight thorn
#

Like I said, I use the Companion App on an Amazon Fire HD

violet shale
tight thorn
#

I got it working now. Thanks for your help. Is there a way to close all pending popups from HomeAssistant itself before navigating to the home page? I tried the close popup action from browser mod but this does not work.

#

I thought about some javascript to close all current opened popups.

tight thorn
#

I got some vibe code wacky javascript code working. It looks horrible but it seems to work.

(() => {
  // Recursive DOM + shadow walker
  const seen = new WeakSet();
  function walk(root, fn) {
    if (!root || seen.has(root)) return;
    seen.add(root);

    try {
      fn(root);

      // normal children
      const children = root.children || [];
      for (const c of children) walk(c, fn);

      // shadow root
      if (root.shadowRoot) walk(root.shadowRoot, fn);

      // slot-assigned nodes
      if (root.querySelectorAll) {
        for (const slot of root.querySelectorAll('slot')) {
          const nodes = slot.assignedNodes ? slot.assignedNodes() : [];
          for (const n of nodes) walk(n, fn);
        }
      }
    } catch (e) {}
  }

  // Attempt to close a dialog-like element
  function tryClose(el) {
    try {
      // native <dialog>
      if (typeof el.close === 'function') {
        try { el.close(); } catch(e){}
      }

      // elements with .open property (mwc-dialog, paper-dialog etc.)
      if ('open' in el && el.open) {
        try { el.close?.(); } catch(e){}
        try { el.open = false; } catch(e){}
        try { el.removeAttribute('open'); } catch(e){}
      }

      // common alternative close methods
      const alt = ['closeDialog','hide','_close','cancel','dismiss','_dismiss','closeOverlay','toggleDialog'];
      for (const fn of alt) {
        if (typeof el[fn] === 'function') {
          try { el[fn](); } catch(e){}
        }
      }
    } catch (e) {}
  }

  // Walk entire document
  walk(document, root => {
    if (!(root instanceof Element)) return;

    // Generic: has open attribute
    if (root.hasAttribute && root.hasAttribute('open')) {
      tryClose(root);
    }

    // By class name pattern
    const cls = root.className || '';
    if (/overlay|modal|dialog|mwc-dialog/i.test(cls)) {
      tryClose(root);
    }
  });

  document.activeElement?.blur();
})();
broken loom