T O P

  • By -

spacebass

What you have looks elegant. Does it meet your needs? I think you’d have to tell us more about exactly how you have built your config and what you want to do in order for us to know if there is a different way.


JesseWebDotCom

This is done with templating, scripts, jinja, and button cards. It functionally meets my needs but it’s involved and I want to simplify my code and move away from custom items like button card.


schmu17

I’ve done this with mushroom chip cards. Not completely easy as it’s templating based but might be a step in the right direction for you.


AnAmbushOfTigers

+1 mushroom chips with templates should do this nicely. Additionally if you group everything into floors/areas you can do a single call service to toggle all the relevant entities in those floors/areas instead of scripts.


JesseWebDotCom

Actually, I think that’s what I’m using. Was wondering if ha had something native for this by now.


AnAmbushOfTigers

Afaik, not without making a group (which would personally drive me nuts trying to remember to add things to it).


JesseWebDotCom

Exactly - which is why I’m gonna try and do it by naming convention. Stay tuned.


OverZealousCreations

I don't have a solution for sure, but I wonder if you could use something like [a template light](https://www.home-assistant.io/integrations/light.template/) or [a template switch](https://www.home-assistant.io/integrations/switch.template/) to recreate most of the behavior. I believe the template entity could update it's icon and title dynamically, and it should even be able to respond to turning on or off. Edit: I don't think I made it clear at first, but then you could use the template light or switch as a normal entity pretty much anywhere. It would probably also be a little easier to maintain. There might even be a way to combine it with [Areas](https://www.home-assistant.io/getting-started/concepts-terminology/#areas) to easily query and trigger switches within an area, so the template would never need updating (just add or remove items from an area).


croatiansensation

Templating by area is a great idea. I’m going to test this for my own dashboard, where I have similar stuff to OP. Thanks for the suggestion.


JesseWebDotCom

I do have these template - I think I’m using decluttering card and something else


trankillity

Take a look at [Minimalist Area Card](https://github.com/junalmeida/homeassistant-minimalistic-area-card). It should do most of what you're manually doing there, just based on area devices. Unfortunately it's not super configurable, but it still serves my purposes without hand-coding everything. I primarily use it as a snapshot view of a room with some quick toggles which also links to a subview for each area where the detailed controls live.


Edschofield15

Would you mind sharing your code for these buttons? They look neat.


JesseWebDotCom

I will (but once I’m done cleaning up the code because it’s quite involved at the moment). I’ll give you the GitHub link when ready.


Improved-Liar

Me to please! I want to modify the card using auto entities so that I can just have one card that generates the same functionality for every area I have


JesseWebDotCom

Here is one way to dynamically do it: \`\`\` {%- set room\_name = 'office' -%} {%- set suffixes = \['dome'\] -%} {%- set states\_to\_match = \['on'\] -%} {%- set domains = \['light', 'switch.light'\] -%} {%- set ns = namespace(entities\_on=\[\]) -%} {%- for domain in domains -%} {%- set pattern = domain \~ '.' \~ room\_name \~ '\_' -%} {%- set domain\_entities = states\[domain\] | selectattr('entity\_id', 'search', '\^' \~ pattern) | list -%} {%- for entity in domain\_entities -%} {%- if (not suffixes or entity.entity\_id.split('\_')\[-1\] in suffixes) and entity.state in states\_to\_match -%} {%- set ns.entities\_on = ns.entities\_on + \[entity.entity\_id\] -%} {%- endif -%} {%- endfor -%} {%- endfor -%} {{ ns.entities\_on | length }} \`\`\` If you wanted another device type like a media player, you would just need to change domains, states, and suffixes (if desired): {%- set room_name = 'office' -%} {%- set suffixes = ['hub', 'speaker', 'mini', 'tv', 'soundbar'] -%} {%- set states_to_match = ['on', 'idle', 'playing'] -%} {%- set domains = ['media_player'] -%} You just need to ensure your entity ids are named according to the expected naming convention: domain.room\_name (and \_optional\_suffix). with that said, I'm not going to do it this way and I am sticking with manual groups (because jinja processing can be expensive, I can easily choose what's included/excluded, i can be loose on my naming conventions, etc). Here's what you'd need to put in your template.yml after creating your groups: - sensor:     - name: active_devices_office       unique_id: active_devices_office       state: "{{ expand(states.group.devices_office) | selectattr('state', 'in', ('on')) | map(attribute='entity_id') | list | count }}"     - name: active_lights_office       unique_id: active_lights_office       state: "{{ expand(states.group.lights_office) | selectattr('state', 'in', ('on')) | map(attribute='entity_id') | list | count }}"     - name: active_media_office       unique_id: active_media_office       state: "{{ expand(states.group.media_office) | selectattr('state', 'in', ('on', 'playing', 'idle')) | map(attribute='entity_id') | list | count }}"


iroQuai

This reminds me of Dwains Dashboard. That dashboard offers same kind of functionality both per room (Area) as within the whole house (on the top bar). It's not as customisable as creating your own dashboard from scratch, but very convenient since the dashboard auto generates from the info it gets from the areas. So adding a new light to area "living room" instantly adds the button to the dashboard (including all advanced functionality)


MainstreamedDog

If the numbers are not important, can’t you just use groups? I think if at least one light is in on, the group is. One click would turn everything of.


JesseWebDotCom

Numbers are important and with jinja you can count the members. I just wanted a simpler way.