nickrout
(Nick Rout)
March 22, 2024, 7:41pm
41
The domain is per entity and is the leading part of the entity. Like light in light.bedroom.
The integration concerned provides entities (on my system) in the light, sensor, climate, binary_sensor and switch domains. But that doesn’t seem to be what @dbrunt was after.
The integration is the directory the source code is in. In this case smartthinq_sensors
. Because I know it is a custom component I can go ls /config/custom_components
to fairly easily find it. I can also go to the documentation link which in two clicks ends up here ha-smartthinq-sensors/custom_components at master · ollo69/ha-smartthinq-sensors · GitHub and there is the directory name.
For an invite integration I can do the same - click the documentation link, click the link to the source, read the name.
Or do as @Troon suggests.
petro
(Petro)
March 22, 2024, 8:07pm
42
I was referring to the code driven domain, or ‘platform’.
e.g.
https://github.com/home-assistant/core/blob/7d9fa64a66e676f3fcc6fb82cc150ca0ddd22950/homeassistant/components/compensation/const.py#L3
Which is what is used for config flow & config_entries (I.e. the exact information needed for selectors)
nickrout
(Nick Rout)
March 22, 2024, 8:12pm
43
As I understand (and I am probably about to be educated) platform and domain are different. But as I say my understanding may be limited.
dbrunt
(Daniel)
March 22, 2024, 8:47pm
44
Ideally, it would be nice if auto-entities were enhanced to provide a selector list of available integrations. Same for the other filter selections. I’ll propose it as a feature request…
1 Like
imagine having more than 1 config_entry under the same integration
example: 1 for each Hue bridge looking like:
we can template those in HA with
{{integration_entities('Philips Hue 1')}}
but cant use that in auto_entities unfortunately
we can only use the integration filter on the main integration, like
include:
- integration: hue
But, fortunately, there is the template filter option, which allows us to use the jinja template and return entities for the individual config_entries
type: entities
entities:
- type: custom:auto-entities
card:
type: entities
filter:
template: >
{{integration_entities('Philips Hue 1')}}
in its basic form
btw, there is also the option to do:
type: entities
entities:
- type: custom:auto-entities
card:
type: entities
filter:
include:
- device: Philips Hue 1
but that only lists the entities on the device itself (some bridge automations, scenes etc) and not the lights or sensors connected to the bridge.
2 Likes
dbrunt
(Daniel)
March 26, 2024, 6:48am
46
petro:
Here’s a template that will find you the identifiers for each integration that’s implemented in the UI.
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(integrations = []) %}
{%- for device in devices %}
{%- set ids = device_attr(device, 'identifiers') | list | first %}
{%- if ids and ids | length == 2 %}
{%- set integration, something_unique = ids %}
{%- if integration not in ns.integrations %}
{%- set ns.integrations = ns.integrations + [ integration ] %}
{%- endif %}
{%- endif %}
{%- endfor %}
{{ ns.integrations }}
Here’s my slightly improved version which removes the No first item, sequence was empty message in Dev Tools, and sorts the list…
{% set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(integrations = []) %}
{%- for device in devices %}
{%- set ids = device_attr(device, 'identifiers') | list | first | default %}
{%- if ids and ids | length == 2 %}
{%- set integration, something_unique = ids %}
{%- if integration not in ns.integrations %}
{%- set ns.integrations = ns.integrations + [ integration ] %}
{%- endif %}
{%- endif %}
{%- endfor %}
{{ ns.integrations | sort }}
1 Like
petro
(Petro)
March 26, 2024, 11:00am
47
This can all be shortened to a 1 liner now.
I posted this here yesterday.
{{ states | map(attribute='entity_id') | map('device_attr', 'identifiers') | reject('none') | map('list') | map('first') | map('first') | reject('undefined') | unique | list }}
sorted
{{ states | map(attribute='entity_id') | map('device_attr', 'identifiers') | reject('none') | map('list') | map('first') | map('first') | reject('undefined') | unique | sort }}
warningless
{{ states | map(attribute='entity_id') | map('device_attr', 'identifiers') | reject('none') | map('list') | reject('eq', []) | map('first') | map('first') | unique | list }}
warningless sorted
{{ states | map(attribute='entity_id') | map('device_attr', 'identifiers') | reject('none') | map('list') | reject('eq', []) | map('first') | map('first') | unique | sort }}
3 Likes