AalianKhan / mushroom-strategy

A strategy to automatically generate a dashboard using mushroom cards
MIT License
370 stars 37 forks source link

Room/Areas views: option to group by devices #45

Open floco opened 1 year ago

floco commented 1 year ago

Is your feature request related to a problem? Please describe. I have many devices that are composed of multiple types/classes of entities. Example a cat feeder, locks, plugs with power measurement that are composed of binary sensors, sensors, switches, lights. So the grouping by entity class/domain does not work really well in my case. My rooms/areas are way too cluttered. So when looking for an info I end up going searching for the device where entities are neatly grouped under it.

Describe the solution you'd like It would be great to have an option for the generation of the views under each areas/rooms to group by device then by class/domain. I feel this would be a good compromise for the automatic dashboard of each rooms.

Describe alternatives you've considered An alternative would be to create an area for each devices I use the most, but that will clutter the front page. Or go back to creating my own dashboard.

Additional context Example of native home assistant device view showing multiple entities based devices image

AalianKhan commented 12 months ago

Generating the views in a different format will need a lot of work in the backend. I am thinking of adding an option to create a "device card" for certain devices you choose. The device card will just show all the linked entities in a popup. What do you think?

floco commented 11 months ago

Thanks @AalianKhan for considering this feature. 😀 yes I was thinking having an additional parameter at areas level, where we could specify different "sub-strategies" type to generate the areas view. Like in this case "by_device" instead of default "by_entity"

strategy:
  type: custom:mushroom-strategy
  options:
    areas:
      family_room_id:
        name: Family Room
        type: by_device

But I understand this means adding a complete new way to generate views...

Having an option for a device card might also work: like being able to display the main entity of the device in the view and displaying all other entities of the device in a popup. But in that case, the view would still have to know somehow that the entities of this device are already handled and not display them in the view. Or hide them all using the hide filter feature that is being developed here: https://github.com/AalianKhan/mushroom-strategy/issues/48 and then use templates to retrieve them in the "device popup view" like so:

type: custom:auto-entities
card:
  type: grid
  columns: 2
  square: false
card_param: cards
filter:
  template: |-
    {% for x in device_entities("da693b86a8bb0765172816a57a05a6f0") -%}
      {{
        {
          'type': 'custom:mushroom-entity-card',
          'entity': x,
          'name': state_attr(x, 'friendly_name')|replace('FRESHELEMENT3 ', '')

        }
      }},
    {%- endfor %}

image

bzzzggz commented 11 months ago

I agree that grouping sensors by device will make the dashboard much easier to read. Recently configured dryer and washer. This is my Laundry room view. It's very confusing and hard to follow what's going on. image

AalianKhan commented 11 months ago

Would you guys prefer a card? that when clicked gives you a popup (will require another custom integration, browser-mod) Or just creating a title with all entities associated with that device are displayed under it?

floco commented 11 months ago

Thanks again for considering this :-) Both options make sense and would allow a much better auto organisation of multi-entities devices.

The first option (device card with detail popup) would allow to really declutter the dashboard. But on the other hand the "device" card should ideally still show the main information or action, or you would have to click to see it. And then the dashboard creator would have to define/customise which main info/action to display in the "device" card (unless there is a way to guess it) and then means it's no longer auto-generated and/or everything is two clicks away.

So I think the second option (device name as the title and then list the device's entities under it, sorted by domain/class) would work great for me.

What do you think @bzzzggz ?

bzzzggz commented 11 months ago

I think the first option will looks amazing. A simple device card with basic running information. And then the pop up will include all entities.

Not sure how hard it is to define what is basic information since there are so many different type of smart devices.

Something similar like if the device has a switch use switch; If it does not contain any switches list all sensors?

bzzzggz commented 11 months ago

Screenshot_20230927_075258_SmartThings Something similar like this?

floco commented 11 months ago

I agree, first option would look the best, I can see the appeal of that.

But technically I have no idea how the strategy can guess the main "entities" to make available directly on the card...

Like you said there are so many different devices. Imagine a powerstrip with multiple plugs or a cat feeder when you want to distribute food manually but also see how much food was distributed today. Depends on each use case ... In the example below, what matters to me is to action the plug and to see the current and all rest can be in popup card.

Screenshot 2023-09-27 at 06 49 18

Could it attempt to guess somehow but still leave the choice to the user to change it if needed ?

For the popup view, we could use what HA does in the device view, where it classifies entities in 4 categories: controls, sensors, configuration, diagnostic, and put the main things on top (like in above screenshot). Usually that classification makes the most sense. But I don't know if that info is accessible through templates ?

floco commented 11 months ago

more on entity_category: https://developers.home-assistant.io/blog/2021/10/26/config-entity?_highlight=entity&_highlight=categories#entity-categories but looks like not available in templates: https://community.home-assistant.io/t/accessing-testing-entity-category-property-in-templates/378523 https://community.home-assistant.io/t/add-the-entity-category-to-the-available-state-object-properties/378724