Lazy Man's Entity Count - Something Screwy

I know I could do a quick fudge, like : -

{% set ns = namespace(num = 0) %}
{%- for state in states -%}
  {%- set ns.num = ns.num + 1 %}
{%- endfor -%}
{{ '\n'~'\n  ' ~ 'Total: ' ~ ns.num }}

Which gives me : 918
But that’s not the point

Well I get the exact same numbers for your for loop so I’d guess we’re counting not the list of [say] automations but a list of maybe attributes to the automation domain or something like this?
I don’t understand your for loop so I won’t even venture to tell you what you need to change, but hopefully the above comment steers you in the right direction. That’s a pretty cool formula (when it’ll work)

By the way I’m currently on 193 automations. No idea if it’s a good or bad thing though :rofl:

Yep I agree, they are generally meaningless numbers at the end of the day but I do like to track how my HA is growing as my OCD kicks into a different gear over time :rofl:
Thanks

BTW : -

{%- set unique_domains = states | map(attribute='domain') | list | unique | list -%}
{%- for dom in unique_domains -%}
  {{ dom ~ '\n' }}
{%- endfor -%}

Just gives you a list of the domains on your instance

I have only 714 :sob: :rofl:

now I get it and I believe the count you get is the count of chars in the string ‘states.[domain name]:wink:

1 Like

I’m pretty sure @Mariusthvdb has the most :rofl:

Yeah Marius collects sensors as a hobby. :rofl:

I’m pretty sure @lolouk44 is correct (well spotted :+1: )

But how should I pass the states.[domain] as a ‘group’ ? Rather than as a text string to have its length calculated ?

{%- for domain in states | map(attribute='domain') | unique %}
{{ domain }}: {{ states[domain] | count }}
{%- endfor %}

Edit: adding dashes

Edit 2: Also seems like you’re trying to add them all up… but you don’t need to do that, just

{{ states | count }}
3 Likes

@petro to the rescue :clap: :slight_smile:

1 Like

haha, Ive grown…

(note the scroll bug prevents the zones being visible)
(note2, the numbers don’t add up completely:

Thank You Petro :+1:

Just to pretty it up the modified original “would” have been : -

{% set ns = namespace(num = 0) %}
{%- for domain in states | map(attribute='domain') | unique %}
{%- set numb = states[domain] | count %}
{%- set ns.num = ns.num + numb %}
{{ domain ~ 's : ' ~ numb }}
{%- endfor %}
{{- '\n'~'\n  ' ~ 'Total: ' ~ ns.num }}

Except Petro simplified a lot more than that, so it all could be replaced by : -

{%- for domain in states | map(attribute='domain') | unique %}
{{ domain ~ 's : ' ~ states[domain] | count }}
{%- endfor %}

{{ '  Total: ' ~ states | count }}

Nigh on a direct copy of Petro’s code - Thanks Again ! :beer:

1 Like

But how many of yours are missing because they are in AppDaemon ?
Do you get a count of AD entities even ? :man_shrugging:

Anyway I’d be happy to have just 1 (or lower) of everything as long as I had everything working “just as I want it” (come back to me in 10 years
BTW Teras has been doing this at least 10 years and he still says he hasn’t finished 8-0 :scream_cat:

I only have 500 or so entities. But all my appdaemon apps make single entities with tons of attributes. I think I have 3 regular automations.

Okay, so I have to ask, why 3 ?
Why not just get rid of all of them and put them in AD ?
Or are they just tooooo simple to bother ?

(See @Burningstone you are not alone ! )

way to simple to bother, it’s a reminder at 10 am on wednesday. I just don’t feel like making an app for it.

I don’t have a single entity that lives only in AppDaemon and not in HA. And anyway I would prefer to also have less entities in HA, more entities → more entities that can malfunction → more time for maintenance → less time for AppDaemon :rofl:

Will we ever be done? What will we do with our lives when our home automation is done ?:scream:

I have an app for that :rofl:
But I use it for a lot of different reminders for household tasks with actionable notifications etc.

I’m just too lazy to generalize it. And at the end of the day, i’d end up with the same configuration as the automation. So I said eff it.

Hi all “lazy men” :slight_smile:

I’ve just about a year into my HA-journey, but have taken interrest in the topic of this post throughout my journey, and think it is about time to try to give something back.
My code might not be brilliant (but it works) - so all improvement suggestions are welcome :wink:

My take on it is to create a “solution” - which is a readme containing some guidance, screenshots and links to:

  • yaml.file with the actual sensors etc
  • yaml-dashboard

see the readme at: HomeAssistantConfig4/hastats.md at ce6dd64de1e826ea9f8d1c092214120146a42b6c · ArveVM/HomeAssistantConfig4 · GitHub

Screanshots:




I know this is way over the top on logging - but I’m a bit above average interested in seeing the long term development - and to quantify in numbers :wink:

and again - thanks for all the brilliant code, tips and guidance in this (and other) posts