hi!
not sure why you’d post that, but if your ‘pulling the data’ from this Roldy's Home Assistant - 190+ sensors - 440+ entities - 70+ automations - Floorplan you now should have noticed that could be done much better…
consider that code:
count_automations:
entity_id: sensor.date
value_template: >
{%- set domains = ['automation'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
and compare it to
{{states.automation|count}}
Hey @uiguy come here and blow their minds…
Template editor tool:
{%- for d in states | groupby('domain') %}
{{ d[0] }} - {{ states[d[0]] | count }}
{%- endfor %}
my code on @Mariusthvdb link above came initially from @Mariusthvdb i seem to remember… oh and sorry I did not credit you before…
So, I threw this into the Template editor and it popped up a long list of domains as it should, but one in particular caught my eye -
sensor - 666
Thanks 2020!
What would be the best way to display this in Lovelace? I tried a Markdown Card but the formatting was ugly, not having each domain on a new line. Is there a way for format the use of new lines in the Markdown Card?
I tried to put it in a table but failed. This is the best I can do.
type: markdown
content: |-
{% for d in states|groupby('domain') %}
**{{ d[0]|replace('_', ' ')|title }}** {{ states[d[0]]|count }}
{%- endfor %}
title: Domain Counts
Much better than mine. Thanks
Crap:
Better:
how can one make the numbers to have at least 3 digits, ie 001 instead of 1
this way to have it nicely aligned
type: markdown
title: Domain Counts
content: |-
{% for d in states|groupby('domain') %}
{{ '{:03}'.format(states[d[0]]|count) }} **{{ d[0]|replace('_', ' ')|title }}**
{%- endfor %}
thank you works great now, multi column would be nice instead one big list.
Now Marius, where is the “Mark this post as : - Evil Bastard” on the response options ?
I did this:
- type: markdown
# title: Components
content: >
Domain | Count
:---|---:
{% for d in states | groupby('domain') %}
{{ d[0].replace('_', ' ') | title }} | {{ states[d[0]] | count }}
{% endfor %}
since we were counting before…
has anyone else noticed the state machine being flooded with so many new entities (probably because of the new design decisions to breakout attributes and use dedicated sensors?
Ive been weeding out my hand made template sensors, but can not fight this… ok, I wrote a few more scripts and automations, and added a few zones but the Hue integration alone adds about 200 scenes…
Hope this wont grow out of hand…or put differently, force some serious hardware step-ups
i’m not sure if this is really the best place to ask a question like this but…
is there a way you can use something similar to these but maybe more specific?
how about count just sensors?
and then only sensors that have a specific value in the friendly name? let’s say ‘birthday’
and then maybe on top of that? a numeric value less than 60?
there’s always a way check How to map state to correct type (|float) - #2 by Mariusthvdb and add a counter
|count
This is interesting… I never counted before, but now I can see I have a lot to adjust during my next vacations. 19k device trackers, 17 media players??? No way.
alarm_control_panel - 2
alert - 3
automation - 69
binary_sensor - 264
button - 83
camera - 4
climate - 7
cover - 3
device_tracker - 19322
humidifier - 2
input_boolean - 2
input_datetime - 1
input_number - 1
light - 42
lock - 2
media_player - 17
number - 6
person - 5
proximity - 2
remote - 1
script - 2
select - 18
sensor - 616
sun - 1
switch - 158
timer - 1
update - 14
vacuum - 1
weather - 1
zone - 17
Gotta Beacon Trackers … Not