lovelace-auto-entities icon indicating copy to clipboard operation
lovelace-auto-entities copied to clipboard

Adding hidden_by field to filters to handle hidden entities

Open Eckii24 opened this issue 2 years ago • 12 comments

Hey @thomasloven,

I have implemented a basic support of the new feature from hass 2022.4 where entities can be hidden. My solution is more of a quick fix. To include or exclude hidden entities a new filter have to be added with the syntax:

include:
   hidden_by: user

A more user friendly solution would be, to add a toggle in the UI. If you prefer the toggle solution it would be great, if we can have a little chat, how to implement this toggle ;)

Eckii24 avatar Apr 12 '22 22:04 Eckii24

Addresses #270/#272

bjeanes avatar Apr 29 '22 22:04 bjeanes

Does not work for me with minimalist UI idk why

  • type: "custom:auto-entities" card: type: "grid" columns: 2 square: false card_param: "cards" filter: include: - domain: switch area: Гостиная options: type: "custom:button-card" template: card_power_outlet exclude: - hidden_by: user - entity_id: switch.mute_3 - entity_id: switch.restart - entity_id: switch.volume_down - entity_id: switch.volume_up_2

I tried "user", actual user id, user name, nothing helps :(

dankarization avatar May 04 '22 18:05 dankarization

What if you did hidden_by: // (empty regex)?

bjeanes avatar May 04 '22 23:05 bjeanes

Still same :(

dankarization avatar May 05 '22 08:05 dankarization

Hey @dankarization,

did you test it with the standard UI components? Does this work?

If not you can check the following:

  • Open the following file: config/.storage/core.entity_registry
  • Search for a entity which is selected to be hidden by the UI
  • What kind of value is present in hidden_by?

If this value matches your auto-entities-rules it should probably work. You should also clear you cache to apply the changes.

Please let me know if that helps you.

Eckii24 avatar May 09 '22 19:05 Eckii24

I'm sorry for such a long answer. I found that some of entities were hidden by "integration", and some are from actual username in config/.storage/core.entity_registry, but even when I added all of these options in exclude, none of them were actually excluded. And yes, I tested it on standard UI and I'm getting same results there :(

dankarization avatar Jul 02 '22 17:07 dankarization

I'm sorry for such a long answer. I found that some of entities were hidden by "integration", and some are from actual username in config/.storage/core.entity_registry, but even when I added all of these options in exclude, none of them were actually excluded. And yes, I tested it on standard UI and I'm getting same results there :(

I can not reproduce your behaviour. The following is working for me. Please have a look at this config and compare it with yours:

type: custom:auto-entities
card:
  type: entities
  title: Living room
  state_color: true
filter:
  include:
    - area: LivingRoom
  exclude:
    - hidden_by: '*'
show_empty: true

Also make sure that you updated the compiled files manually inside /root/config/www/community/lovelace-auto-entities, until this MR is merged.

Eckii24 avatar Jul 15 '22 21:07 Eckii24

Any timeline as to when this change might get merged?

strelniece avatar Aug 23 '22 18:08 strelniece

I'm sorry for such a long answer. I found that some of entities were hidden by "integration", and some are from actual username in config/.storage/core.entity_registry, but even when I added all of these options in exclude, none of them were actually excluded. And yes, I tested it on standard UI and I'm getting same results there :(

I can not reproduce your behaviour. The following is working for me. Please have a look at this config and compare it with yours:

type: custom:auto-entities
card:
  type: entities
  title: Living room
  state_color: true
filter:
  include:
    - area: LivingRoom
  exclude:
    - hidden_by: '*'
show_empty: true

Also make sure that you updated the compiled files manually inside /root/config/www/community/lovelace-auto-entities, until this MR is merged.

Which files do we copy to /root/config/www/community/lovelace-auto-entities?

mash2k3 avatar Oct 24 '22 00:10 mash2k3

I would love to see this merged. I wonder if the default should be changed to hide anything hidden unless specified to include it.

randellhodges avatar Oct 25 '22 04:10 randellhodges

Which files do we copy to /root/config/www/community/lovelace-auto-entities?

https://raw.githubusercontent.com/Eckii24/lovelace-auto-entities/master/auto-entities.js I replaced the auto-entities.js with the one linked and deleted the 2 .gz files (not sure if that was needed or not). Be sure to clear your cache/force a reload. Works for me.

randellhodges avatar Oct 25 '22 12:10 randellhodges

That worked thanks, deleting the gz files was the answer.

mash2k3 avatar Oct 26 '22 05:10 mash2k3

Any progress on this?

Spartan-II-117 avatar Nov 16 '22 04:11 Spartan-II-117

Any progress on this?

I too have found the excellence of Auto-Entities and hoping the "hidden_by: '*'" to hide those Switch as X entities to be added soon! 🤞🚀

githubsteveb avatar Dec 14 '22 11:12 githubsteveb

Any progress on this?

It works, but @thomasloven hasn't been working on this particular project in months. I'd recommend uninstalling and manually installing the updated version from @mash2k3 if you need the feature now.

brodkin avatar Dec 24 '22 21:12 brodkin

Thanks!

thomasloven avatar Dec 26 '22 22:12 thomasloven

Thanks @thomasloven! I really didn't expect it, but this is a great Christmas present!

brodkin avatar Dec 27 '22 01:12 brodkin

What is expected behaviour? I am probably missing something

Hidden entity:

      {
        "aliases": [],
        "area_id": null,
        "capabilities": {
          "supported_color_modes": [
            "onoff"
          ]
        },
        "config_entry_id": "fa17776c20aec9037dbad3f93116feeb",
        "device_class": null,
        "device_id": null,
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "light.vsechna_svetla",
        "hidden_by": "user",
        "icon": null,
        "id": "56cf997c8e4c0402d5e6b659604fa81b",
        "has_entity_name": false,
        "name": "All lights",
        "options": {},
        "original_device_class": null,
        "original_icon": "mdi:lightbulb-group",
        "original_name": "Všechna světla",
        "platform": "group",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "fa17776c20aec9037dbad3f93116feeb",
        "unit_of_measurement": null
      }

image

if I change exclude state to on (filter out state on) entity is not shown as expected image

but changing hidden_by to anything does nothing

Edit: excluding null value for hidden_by does include only hidden entities which are not in group of lights image

Edit 2 : ~~this PR ignores Groups of entities - it works only for devices itself~~

Edit 3: Browser needs a refresh when manipulating with entities (hidding/disabling) otherwise changes are cached

scetu avatar Jan 08 '23 18:01 scetu

What is expected behaviour? I am probably missing something

Hidden entity:

      {
        "aliases": [],
        "area_id": null,
        "capabilities": {
          "supported_color_modes": [
            "onoff"
          ]
        },
        "config_entry_id": "fa17776c20aec9037dbad3f93116feeb",
        "device_class": null,
        "device_id": null,
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "light.vsechna_svetla",
        "hidden_by": "user",
        "icon": null,
        "id": "56cf997c8e4c0402d5e6b659604fa81b",
        "has_entity_name": false,
        "name": "All lights",
        "options": {},
        "original_device_class": null,
        "original_icon": "mdi:lightbulb-group",
        "original_name": "Všechna světla",
        "platform": "group",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "fa17776c20aec9037dbad3f93116feeb",
        "unit_of_measurement": null
      }

image

if I change exclude state to on (filter out state on) entity is not shown as expected image

but changing hidden_by to anything does nothing

Edit: excluding null value for hidden_by does include only hidden entities which are not in group of lights image

Edit 2 : this PR ignores Groups of entities - it works only for devices itself

I found that I sometimes have to clear my browser cache and refresh the page before updates to hidden entities are accounted for (on the Android app, I have to force close and reopen the app). I don't know if that's the issue you are having here, but it may be worth giving that a go to see if it helps.

Excentyl avatar Jan 08 '23 18:01 Excentyl

I found that I sometimes have to clear my browser cache and refresh the page before updates to hidden entities are accounted for (on the Android app, I have to force close and reopen the app). I don't know if that's the issue you are having here, but it may be worth giving that a go to see if it helps.

Woah, now it works! Thanks for quick suggestion!

scetu avatar Jan 08 '23 18:01 scetu

Super appreciate this as a manual file setting. Any chance it can be added to the card UI? Or just replicate the prior behavior where "hidden" items are also hidden in lovelace? And maybe have the manual code tweak to override the default behavior to respect the hidden attribute?

Coder84619 avatar Mar 25 '23 03:03 Coder84619