Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select correct coordinator for execute_command service #797

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions custom_components/tahoma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,15 @@ async def handle_execute_command(call: ServiceCall):
entity_registry = await hass.helpers.entity_registry.async_get_registry()

for entity_id in call.data.get("entity_id"):
entity = entity_registry.entities.get(entity_id)
registry_entry = entity_registry.entities.get(entity_id)
entity = [
e
for e in hass.data["entity_components"][registry_entry.domain].entities
if e.unique_id == registry_entry.unique_id
][0]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could perhaps also use next() here, instead of [0].


try:
await coordinator.client.execute_command(
await entity.coordinator.client.execute_command(
entity.unique_id,
Command(call.data.get("command"), call.data.get("args")),
"Home Assistant Service",
Expand Down