Today I learned a way to hide and unhide a view in Home Assistant. It turns out it’s easier than I expected. All I had to do was use the group.set  service to change the attribute view.

Here is an example code:



group:
  default_view:
    name: "First"
    view: yes
    entities:
      - script.show_view
      - script.hide_view
  second_view:
    name: "Second"
    view: yes
    entities:
      - script.show_view
      - script.hide_view

script:
  show_view:
    alias: "Show Second View"
    sequence:
      - service: group.set
        data:
          object_id: second_view
          view: true
  hide_view:
    alias: "Hide Second View"
    sequence:
      - service: group.set
        data:
          object_id: second_view
          view: false


This generates two views (both visible). When I call the "Hide Second View" script, the "Second" view become hidden. And when I call the "Show Second View" script, the "Second" view become visible again.




The only drawback is that if you only have two views and hide one of them, the blue bar will be resized, but the placement of the content below it will not be updated automatically.