Swipe for sidebar?

Nice one! Thanks for the tip!

You need to remove “browser_id: THIS” and than it works across all devices/browser/apps.

2 Likes

Yes, thanks! Works. Forgot it was deprecated with a specific version of browser mod. Typical copy & paste mistake.
Now I mapped it on a hold_action of a button. :wink:

1 Like

confirmed working by remving indeed browser: THIS

finally a workaround for menubar again :slight_smile:

Hey there, just passing by and wanted to thank you for the solution ! Woekinf for le on android! Hoping it just temporary !

I was missing some of the basics on how to reproduce this solution, so after figuring out the missing steps posting this for other newbies like me here is a script for reference; once script is created just add it to dashboard.

  1. Install “browser_mod 2” from HACS
  2. Create below script
  3. Add script to your dashboard (HA Show Sidebar), position it to the top ideally.
alias: HA Show Sidebar
sequence:
  - service: browser_mod.javascript
    data:
      code: >-
        document.querySelector('body >
        home-assistant').shadowRoot.querySelector('home-assistant-main').dispatchEvent(new
        CustomEvent('hass-toggle-menu', {detail: {open: true}}));
mode: single
icon: phu:playback-button
1 Like

Have you any idea if we can use the same approach to open the voice-dialog?

Hi @StickyClient I have had a quick look and this should work for your voice assist. It just emulates a force click on the voice assist menu item.

    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.javascript
        data:
          code: "document.querySelector('body > home-assistant').shadowRoot.querySelector('home-assistant-main').shadowRoot.querySelector('ha-drawer > partial-panel-resolver > ha-panel-lovelace').shadowRoot.querySelector('hui-root').shadowRoot.querySelector('div > div.header > div > div > ha-button-menu > mwc-list-item:nth-child(3)').click();"

Let me know if it works. It seems to work on my system

1 Like

Yea sorry. I have a wall mounted tablet and it would pop up the sidebar for the tablet whenever i used the command anywhere else.
If you set up your device in browser_mod as an entity then it should work on that particular device with browser_id: THIS and not all of your devices at the same time

Thanks! It works but opens the unused entities page instead of the assist popup. :slight_smile:

Edit: Seems to work on mobile but not on desktop, the path changes at dimensions (871x482). So in the meanwhile i figured out that this works for desktop/tablet.

  tap_action:
    action: "fire-dom-event"
    browser_mod:
      service: "browser_mod.javascript"
      data:
        code: "document.querySelector('body > home-assistant').shadowRoot.querySelector('home-assistant-main').shadowRoot.querySelector('ha-drawer > partial-panel-resolver > ha-panel-lovelace').shadowRoot.querySelector('hui-root').shadowRoot.querySelector('div > div.header > div > div > ha-icon-button:nth-child(2)').shadowRoot.querySelector('mwc-icon-button').shadowRoot.querySelector('button').click();"

Hey everyone, I started playing around a bit with listening to edge swipes (similar to Swipe Navigation - GitHub - zanna-37/hass-swipe-navigation: ↔️ Swipe through Home Assistant Dashboard views on mobile.) and triggering the sidebar open via the command noted in prior comments. The code is definitely not ready for prime-time but it seems to at least work well enough in my early testing.

1 Like

Oops I dont have the top bar showing so didnt realise it changes to buttons or menu items according to the screen size. Try this code. It finds the menu item more directly and should work.
Let me know how you go.

    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.javascript
        data:
          code: >-
              let assist = document.querySelector('body > home-assistant').shadowRoot.querySelector('home-assistant-main').shadowRoot.querySelector('ha-drawer > partial-panel-resolver > ha-panel-lovelace').shadowRoot.querySelector('hui-root').shadowRoot.querySelector('div > div.header > div').querySelector('[data-selector="ASSIST"]');
              if (assist == null) {
                  assist = document.querySelector('body > home-assistant').shadowRoot.querySelector('home-assistant-main').shadowRoot.querySelector('ha-drawer > partial-panel-resolver > ha-panel-lovelace').shadowRoot.querySelector('hui-root').shadowRoot.querySelector('div > div.header > div > div > ha-button-menu').querySelector('[data-selector="ASSIST"]');
              }
              assist.click();

Thanks for the input but it seems not working, tested on different screen dimensions but it’s not working on any.

If anyone is interested, I just pushed up what I’ve been using locally to restore edge swiping. I’d like to eventually add some customization options for swipe distance thresholds, disabling the back swipe gesture to close, etc., but I haven’t had time to really expand it beyond the base functionality. I also make no guarantees as to functionality and compatibility with any particular configuration, custom cards, etc. I do use the swipe navigation library and from my (and my family’s) testing, it doesn’t seem to interfere.

I know the library could have been even smaller, but I like reactive patterns, especially for ui events.

1 Like

@breakthestatic: Could you explain how to use it, please?

Sorry, was planning on adding documentation once I got it a bit further along (e.g. with some customization options, etc.). To use it, you just need to add hass-sidebar-swipe.js to your dashboard resources. I believe Registering Resources | Home Assistant Developer Docs has the general instructions on how to do so. You would just follow those and use the hass-sidebar-swipe.js file located at Releases ¡ breakthestatic/hass-sidebar-swipe ¡ GitHub. Hopefully that helps.

1 Like

Thank you for the explanation, unfortunately it doesn’t work for me. But I’m looking forward to further development.

Pushed up a new alpha release that adds some basic user-customization support. You should now be able to configure start/end thresholds and disable some of the extra processing that is currently performed to make the experience better on my own devices/hass setup.

@Ralfi1982, if you want to debug this further, shoot me a direct message and maybe we can go through the setup/config to see what might be causing your failures. So far you’re the only person outside my family that has tried using this, so any troubleshooting/feedback would definitely be welcome!

5 Likes

Work perfect, Android and App companion :wink:

Works :slight_smile: Thank you
(On Android , Poco X3 Pro)

/local/hass-sidebar-swipe/hass-sidebar-swipe.js