Help Needed Showing/Hiding Layers in Floorplan

@Rune_Pedersen

Yes but it takes a little planning because the button is just a toggle so whatever is currently “hidden” will be “visible” when clicked and vise versa. I currently do this on my floorplan but to get it to work correctly I also had to create “hidden buttons”, below is an example.

The 1st Hidden button I set to default of making those visible so when the floorplan starts up they will show. The 2nd Hidden button I set to default of making those hidden. These two buttons are hidden so not seen ever and can’t be clicked. The remaining buttons are what control what gets “toggled” when I click them. I found that I had to create these “hidden buttons” and set the correct default_class otherwise the toggle and the layers wouldn’t work correctly. I also didn’t include the default_class on the buttons I have showing. I have a few more buttons that are not shown below but the setup is similar. Hopefully this makes sense.

You may or may not need to create these “hidden buttons”, I think it will depend on how you plan to view your layers. With mine I had some showing some of the time and mixed with other layers but not showing other times so this was the only way I could make it work.

    - name: Hidden button
      elements:
        - hidden_button
      action:
        domain: class
        service: toggle
        data:
          elements:
            - home
            - main
            - mainlts
            - camera
          classes:
            - layer-visible
            - layer-hidden
          default_class: layer-visible

    - name: Hidden button2
      elements:
        - hidden_button2
      action:
        domain: class
        service: toggle
        data:
          elements:
            - ff1
            - ff3
            - ffxtra1
            - ufxtra2
          classes:
            - layer-visible
            - layer-hidden
          default_class: layer-hidden

    - name: Main button
      elements:
        - main_button
      action:
        domain: class
        service: toggle
        data:
          elements:
            - main
            - camera
            - ff1
            - ffxtra1
            - ufxtra1
          classes:
            - layer-visible
            - layer-hidden

Would recommend you merge the layers you want to show at the same time to one layer.
Then do as described here:

https://community.home-assistant.io/t/how-to-set-up-layers-for-different-floorplans/

1 Like

got the first method as mentioned by photo64 to work… seems less hard…