t0bst4r / matterbridge-home-assistant

Apache License 2.0
73 stars 8 forks source link

Feature Request: Support loading entities using "Voice assistants" and Aliases #46

Open tam481 opened 2 months ago

tam481 commented 2 months ago

Hi @t0bst4r Please consider loading entities by using the Voice assistants and associated aliases feature in HASS.

I'm sure you have your own plans for what you want to do but I thought I would get my requests in first :-)

t0bst4r commented 2 months ago

I have also thought about that, but Home assistant does not populate this information via their websocket API.

Instead I would need to query the REST API for each entity to get its metadata. And probably additional requests to get the Voice assistant config.

i wanted to make the communications between my app and HA as easy as possible and used a similar include/exclude mechanism as Alexa and Apple Home configurations (except for the improvement from the other issue šŸ˜ ).

Letā€™s keep that issue as a reminder for a future improvement. But Iā€™ll not do that in the next days.

Jibbonator commented 2 months ago

Sry confused the github site. Would be feasable for the homeassitant addon.

I have a potential idea. IĀ“m just gonna leave my thoughts here...

Does the Addon have access to config.storage.core\entity_registry?

I have created a Node-RED flow(with help of GPT), I read this file, filter for entries where {"should_expose": true}, and then generate a configuration file tailored to my needs. This flag indicates whether the entity is configured for Assistants.

You might consider creating a configuration file using a similar approach. I know your approach is a bit different with filters for entitys and groups, but since youĀ“re experimenting with a config file this Flag would be easy to set for the users.

An if this idea is a nogo for you someone could still make a node red flow when the addon allows for a config file.

hereĀ“s an example of my filter function: It creates a config file for the homeassistant alexa integration.

const data = msg.payload && msg.payload.data;
const entities = data && data.entities;

if (Array.isArray(entities)) {
    const filteredEntities = entities
        .filter(entity => entity.entity_id && entity.options && entity.options.conversation && entity.options.conversation.should_expose === true);

    const includeEntities = filteredEntities
        .map(entity => `      - ${entity.entity_id}`)
        .join('\n');

    let entityConfig = 'entity_config:';

    filteredEntities
        .filter(entity => entity.aliases)
        .forEach(entity => {
            entity.aliases.forEach(alias => {
                entityConfig += `\n    ${entity.entity_id}:\n      name: "${alias}"`;
            });
        });

    msg.filename = '/config/alexa_expose/generated_smart_home.yaml';
    msg.payload = `smart_home:\n  locale: de-DE\n  endpoint: https://api.eu.amazonalexa.com/v3/events\n  client_id: !secret alexa_client_id\n  client_secret: !secret alexa_client_secret\n  filter:\n    include_entities:\n${includeEntities}\n\n  ${entityConfig}`;
} else {
    msg.payload = '';
}

return msg;
t0bst4r commented 2 months ago

Yes, using the registry is exactly what I intended to do šŸ˜ I am already combining entity state with the registry state to detect the "hidden" state.

I donā€™t think I need another config file.

As a next step i wanted to use that "conversation.expose" property. So, having that in mind, but other stuff was higher priority yet šŸ˜…

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.