Async_register_entity_service - calling entity method from service call


I’m developing an integration:
In this integration I have a service taking an entity_id param. So far so good.

Now, from this entity_id, I would like to get the Entity object, so not the State nor the EntityRegistry objects.
Actually, I would like to get another object from the entity object itself.

For now, I’m storing an array of entity objects inside my coordinator and my entities have a ref to my coordinator and using async_added_to_hass and async_will_remove_from_hass I’m populating this array. But it sounds quite ugly.

Is there any way to get the entity object from entity_id ? Or do you have any other suggestions ?

Thanks !



actually I found async_register_entity_service method inside EntityComponent.

But I’m wondering how I can get/create the EntityComponent ?

I’m doing like this:

PLATFORMS = ["binary_sensor", "sensor", "water_heater", "climate"]

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):

    for platform in PLATFORMS:
            hass.config_entries.async_forward_entry_setup(entry, platform)

    entity_component = EntityComponent(_LOGGER, DOMAIN, hass)
    entity_component.async_register_entity_service('set_quick_veto', schema, 'set_quick_veto')

And I’m getting the following error:

DEBUG:homeassistant.core:Bus:Handling <Event call_service[L]: domain=vaillant, service=set_quick_veto, service_data=entity_id=climate.vaillant_zone_1, duration=300, temperature=25>
WARNING:homeassistant.helpers.service:Unable to find referenced entities climate.vaillant_zone_1

So it seems to work, but it’s not able to find my entity (my entity really exists).
I believe I have to add the my entities to entity_component, but how can I do that ?

Hey did you get it working?

I am also working on an integration and trying to figure out how to access the entity object itself, run some logic and update a property.