Question: Group visibility and template switches


I have a group of plant in the frontend but they use a lot of space. I’d like to have a switch to toggle the visibility of the plants group but can’t get it to work. I’ve seen examples where people use two sets of scripts to toggle visibility but a switch would be best for me.

This is the group of plants:

  name: Pflanzen
  - plant.avocado
  - plant.scotch_bonnet
  - plant.rote_chili
  - plant.spathiphyllum
  - plant.kastanie
  - plant.basilikum
  - plant.goldfruchtpalme
  - plant.chilianzucht

And this is the template switch I came up with but somehow there seems to be no way to adress the value template and read the current state of the group’s visibility. Can anyone help?

- platform: template
      friendly_name: Pflanzen anzeigen
      value_template: "WHAT DO I NEED HERE?"
      - service: group.set_visibility
        entity_id: group.plants
          visible: 'True'
      - service: group.set_visibility
        entity_id: group.plants
          visible: 'False'

Goood question. You could try:

“{{ ‘hidden’ in group.plants.attributes.keys() and group.plants.attributes.hidden }}”

I’m not sure if that property is updated when visible is set to true/false.

That was my idea but the mentioned plant group does not have that kind of attribute:


Yeah, its not settable, that doesn’t mean you can’t access it. Look at it in the states page. It may contain the attribute there. If it doesn’t, I’m not sure what you can use outside a custom component.

You could just set the value_template = True for the time being, then use the switch and look at the groups attributes. Thats the beauty of template switches, it doesn’t matter what it’s state is, it will still execute the on/off.

I check my groups and the hidden attribute is only available when true, if false, there is no attribute. I thought this might work but it didn’t

@RobDYI this if check verifies hidden exists and also checks the attribute if it does. In theory, if the hidden attribute is updated when visibility changes, this if statement should work.

Hi, I would be interested in the subject. In your opinion, with an input text, is it possible to hide a group of buttons with a password? Thanks

I think it could be possible but it would be a pain to build in home assistant. Partly because input_texts don’t clear their contents so you’d have to clear it. Then you’d need to somehow store that password and check against it.

What exactly are you trying to do?

Hi, I would simply like to put some buttons protected by a password. Make sure that when I type a passord, a specific button or a group of buttons is enabled