thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.24k stars 113 forks source link

Adding hidden_by field to filters to handle hidden entities #277

Closed Eckii24 closed 1 year ago

Eckii24 commented 2 years ago

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 ;)

bjeanes commented 2 years ago

Addresses #270/#272

dankarization commented 2 years ago

Does not work for me with minimalist UI idk why

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

bjeanes commented 2 years ago

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

dankarization commented 2 years ago

Still same :(

Eckii24 commented 2 years ago

Hey @dankarization,

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

If not you can check the following:

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.

dankarization commented 2 years ago

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 :(

Eckii24 commented 2 years ago

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.

strelniece commented 2 years ago

Any timeline as to when this change might get merged?

mash2k3 commented 1 year ago

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?

randellhodges commented 1 year ago

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 commented 1 year ago

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.

mash2k3 commented 1 year ago

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

Spartan-II-117 commented 1 year ago

Any progress on this?

githubsteveb commented 1 year ago

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! 🤞🚀

brodkin commented 1 year ago

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.

thomasloven commented 1 year ago

Thanks!

brodkin commented 1 year ago

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

scetu commented 1 year ago

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

Excentyl commented 1 year ago

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.

scetu commented 1 year ago

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!

Coder84619 commented 1 year ago

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?