I knew I saw loaded components somewhere and I have been looking everywhere to try and find it. I wanted to do exactly what you are trying to achieve. Cheers
Glad I came and checked this thread before I started working on a Python script!
@Mariusthvdb does this satisfy what you’re looking for? If you want to display it as a sorted, formatted list in Lovelace, you can use the new card-templater card and apply it to a Markdown card with the following template:
{% for component in states.sensor.my_config.attributes.components|sort -%}
{{ component + "\n"}}
{%- endfor %}
yes it does, and its working. on my ha 84.3 system I need the authorization using the bearer token, for my 92.1 system I can use below configuration …without authentication, from another instance that is, havent checked in on the system itself yet)
using that custom_ui_state_card, I can show the card in regular HA too!
Can we get the domains like this too? The state of the template sensor in my first post is way too long also, so if we could get that in to an attribute via the rest api that would be very nice indeed.
I’m a little out of my depth on this one, as I pretty much went straight to Lovelace UI when I started with Home Assistant, and I’m not really familiar with custom_ui_state_card.
never mind the state card, thats only to represent the outcome in a regular HA card and can’t show more than max 255 characters.
Im now trying to get the components in this python script… maybe you would be know how to help, I seem to have forgotten the correct syntax… been a while since I wrote my last python ;-(
same goes for the domains sensor. I can now only show the number of domains, nt the domains themselves.
well, finally made some progress, showing in regular HA:
now I want to ‘unlist’ this showing each component on its own line, and dont show the brackets and quotes. Also want to list them alphabetically, but thats of second concern.
Should be very easily be able to do that with the for loop, but didn’t get the correct syntax yet, please have a look?
after that I can simply substitute the format(components) with format(line)…
components = hass.states.get('sensor.hassio_main_config').attributes['components']
for c in components:
state = hass.states.get(c)
line = '{}\n'.format(state)
text = '*========== {} Loaded Components ========\n' \
'+{}' \
.format(len(components),
components)
hass.states.set('sensor.hassio_main_components', len(components), {
'custom_ui_state_card': 'state-card-value_only',
'text': text
})
Indeed, it just showed it to give an idea of what I was looking for. and yes, your code works, thank you!
could I order that alphabetically also?
Since this is a very long card now (… i know, i asked for it) maybe format it as a comma separated listing (still without the quotes and brackets?
there’s a bit of a caveat: Id need the header to have another color code (* in this case ) than the rest of the list. Right now the * works on the full text , since you add the header to that text and the following lines consecutively. Somehow Id love to be able to separate those.
that’s the way the custom-ui card works. Example of another card:
I couldn’t successfully use the <summary> tag to change the phrasing from “Details”, maybe someone more well-versed in Markdown can take this a step further. But it’s a starting point.
It does give the opportunity to use the extra color/style tag though.
Which in this case was what I was looking for.
Completely missed the tag at the end of the first line…can confirm this to work indeed.
I’ll note the variation though for future use!