Where can I find a list of domains?

Use grep?

On Linux variants:

hass-cli --no-header service list  | grep notify

On Windows

hass-cli --no-header service list   |findstr -i notify

Blockquote
hass-cli --no-header service list | grep notify

Yes thanks. On Linux this works without --no-headers with the end point

hass-cli service list | grep notify.
and it is the same as this one
hass-cli --no-headers service list 'notify.'

But the question is: how can I import this data into hass? in an input_text separated by a comma maybe? But how? Or else I don’t know …

notify

by the path /api/services

thanks anyway :+1:

what is it in you mean when you say you want to import this into hass with an input select ?

didnt see the solution to finding used domains in your setup yet, so here’s what shows all your domains in use:

  - platform: template
    sensors:
      domains_in_use:
        friendly_name: Domains in use
        value_template: >
          {%- for d in states | groupby('domain') %}
          {{ d[0] }}
          {%- endfor %}

or count them also:

           {%- for d in states | groupby('domain') %}
            {% if loop.first %}{{loop.length}} Domains:
            {% endif %}- {{ d[0] }}
          {%- endfor %}

this will show all components:

  - platform: rest
    name: Hassio Main config
    resource: !secret resource_hassio_main_config
    authentication: basic
    value_template: >
      {{ value_json.version }}
    json_attributes:
      - components
      - unit_system
      - config_dir
    headers:
      Content-Type: application/json
      Authorization: !secret api_bearer_token
      User-Agent: Home Assistant REST sensor

and you need to have/create an api_bearer_token for that

4 Likes

Thank you both!
@Mariusthvdb, I suggest your post here

It was what I wanted, but I didn’t know that config existed
resource: http://hassio:port/api/config

In the link there are many interesting things. Thank you so much for your super shares.

2 Likes

i installed HA in ubuntu venv. when i entered this command at the terminal, i get error of:
hass-cli: command not found

hass-cli --no-header service list  | grep notify

any idea what i did wrong?

You need to install hass-cli:

{%- for d in states | groupby('domain') %}
  {% if loop.first %}{{loop.length}} Domains:
  {% endif %}- {{ d[0] }}: {{d[0]|count}}
{%- endfor %}

12 Likes

this has to be corrected, even though it is a very old post…

you are counting the number of characters of that domain name…

this works a bit better:

      - unique_id: ha_main_domains
        name: Ha main domains
        icon: mdi:format-list-numbered
        state: >
          {{states|groupby('domain')|map(attribute='0')|list|count}}
        attributes:
          domains: >
            {% set x = ['unavailable','unknown'] %}
            {%- for d in states|groupby('domain') %}
              - {{ d[0]}}: ({{states[d[0]]
                            |rejectattr('state','in',x)
                                  |list|count}})
            {%- endfor -%}

1 Like

You already have state objects, no reason to access states again. That’s what groupby does.

{% set x = ['unknown', 'unavailable'] %}
{%- for d, es in states | groupby('domain') %}
- {{ d }}: ({{ es | rejectattr('state', 'in', x) | list | count }})
{%- endfor %}
1 Like

o thats nice!

however, there’s always a caveat, I had this

            {% for i in d[1] if i.state not in x -%}
            > {{i.name}}: *{{i.state}}*
            {% endfor %}

as additional in my markdown (which I simply left out for the post above):

          {% set x = ['unavailable','unknown'] %}
          {%- for d in states|groupby('domain') %}
          {% if loop.first %} ### Domains: *{{loop.length}}* - Entities: *{{states|count}}* {% endif %}
            **{{- d[0]}}:** *({{states[d[0]]
                                |rejectattr('state','in',x)
                                |list|count}})*
            {% for i in d[1] if i.state not in x -%}
            > {{i.name}}: *{{i.state}}*
            {% endfor %}
          {%- endfor -%}

and I cant simply jot that in in your shorter template

id love to get those back in there, and return:

2 Likes

uh, yes you can…/.

{% set x = ['unknown', 'unavailable'] %}
{%- for d, es in states | groupby('domain') %}
- {{ d }}: ({{ es | rejectattr('state', 'in', x) | list | count }})
  {% for i in es if i.state not in x -%}
    > {{i.name}}: *{{i.state}}*
  {% endfor %}
{%- endfor %}

huh, I did that:

{% set x = ['unknown', 'unavailable'] %}
{%- for d, es in states | groupby('domain') %}
- {{ d }}: ({{ es | rejectattr('state', 'in', x) | list | count }})
            {% for i in d[1] if i.state not in x -%}
            > {{i.name}}: *{{i.state}}*
            {% endfor %}
{%- endfor %}

and it threw: UndefinedError: 'str object' has no attribute 'state'

must have been a spacing in the dev editor.
cool, thx!

yeah, because you aren’t using the correct variable

1 Like

yes!

and now change rejectattr to selectattr and turn this in the ultimate unavailable checker :wink:

one thing I had wanted to do was add:

          {% set exclude_domains = ['alarm_control_panel','alert','automation','button',
                                    'counter','media_player','proximity','scene'] %}

and have the unavailable checker use that. Any chance you can spot where to do so, in the if statement?

btw, if at all possible, it would be awesome if we could exclude domains without unavailable entities:

          {% set x = ['unavailable','unknown'] %}
          {% set exclude_domains = ['alarm_control_panel','alert','automation','button',
                                    'counter','media_player','proximity','scene'] %}

          {% set x = ['unknown', 'unavailable'] %}
          {%- for d, es in states | groupby('domain') %}
            **{{ d }}:**  *({{es|selectattr('state','in',x)
                              |list|count}})*
            {% for i in es if i.state in x -%}
            > {{i.name}}: *{{i.state}}*
            {% endfor %}
          {%- endfor %}

and for that {{es|selectattr('state','in',x)|list|count}} == 0 would have to be excluded from the for loop…

yep, if statement using d

heck, I would have sworn I had done that, but now it works:

{%- for d, es in states | groupby('domain') if d not in exclude_domains %}

its remarkable btw, how much this weighs on the frontend. where the dev templates has this in the blink of an eye, frontend takes really long to show upon first reload

because the frontend has to send it to the backend

yes, I understand that.
its just that your format takes way longer than what I posted above. for the frontend that is, cant say for the dev tools, because those both are fast

btw, this fixes the other request:

          {%- for d, es in states | groupby('domain') if d not in exclude_domains 
          and es|selectattr('state','in',x)
                              |list|count != 0 %}