#Is there a way to look up the entity_id(s) given a domain and name?

1 messages Β· Page 1 of 1 (latest)

calm karma
#

So when I'm exposing scripts to gemini for example, I noticed that it doesn't really have access to the entity_id in context, and generally works off the Intent's handling of entity lookups by domain and name.

Is there a way, in HASS scripts, to be able to take a domain and name, and resolve it to one or more entity_id?
So far the only way I've found (that isn't directly reading the entity registry file) is to use the intent/handle REST API and abuse the HassGetState intent to perform the resolution.

Was wondering if there was some way where it doesn't have to reach out to something like node-red just to look up entity_ids inside home assistant, from home assistant.

lost oar
#

Something like this works

{{states.media_player | selectattr('name', 'contains', 'Living Room') |map(attribute='entity_id') | first | default}}
calm karma
#

doesn't seem to work to look up aliases tho

#

(which the LLM model, may use as a parameter)

lost oar
#

Hmm not sure how ha internally exposes those

#

Thought it was exposed in context, but i don't use aliases so not really sure on that one πŸ˜…

mossy lagoon
lost oar
#

Yeah i have area ones as well πŸ™‚

#

Usually use those most often, but have individual device if i want to trigger something in another room for some reason 😁

mossy lagoon
lost oar
#

Haha indeed!

#

I tend to float around seeing what people are up to 😁

#

Good inspiration for tinkering haha

calm karma
#

In my case, I was mostly tying to get it to tell me a specific person entity (I basically built a TTS paging system that sends TTS messages to people's phones)

#

and my existing logic tied everything to the id of a person entity

#

so I was trying to plug that, into the LLM really.

#

(that and that apparently the current hass implementation doesn't let it push buttons).
I gave it a script that let it push buttons.

#

.>

#

But yeah, in my use case, since it's matching people names, I needed name match to work soo

#

Guess I'll stick to misusing the intent handling API to get a list of entities.

lost oar
#

Hmm, i have a script that uses reverse geocode to tell me a person's exact location and i can use names just fine. πŸ˜…

#

Maybe it's the difference between using the llm itself with function calling versus custom sentences with intent script.

calm karma
lost oar
#

Yeah I have a sensor in HA that gives the geocoords, but then I wanted that to be fed into reverse geocode to give me the literal location

#

so it can report what street/building they are at, how many miles away, whether they are heading away or toward home, etc πŸ™‚