entities_assign_entity_to_area
Assign a Home Assistant entity to a specific area to organize devices by location within your smart home.
Instructions
Assign an entity to an area.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity_id | Yes | ||
| area_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/entities.py:85-88 (handler)The MCP tool handler for 'assign_entity_to_area'. It takes an entity_id and area_id, and delegates to ha.update_entity_registry with area_id=area_id.
@mcp.tool() def assign_entity_to_area(entity_id: str, area_id: str) -> dict: """Assign an entity to an area.""" return ha.update_entity_registry(entity_id, area_id=area_id) - tools/entities.py:86-88 (schema)The function signature defines the input parameters (entity_id: str, area_id: str) and return type (dict). No explicit Pydantic schema; FastMCP infers from type hints.
def assign_entity_to_area(entity_id: str, area_id: str) -> dict: """Assign an entity to an area.""" return ha.update_entity_registry(entity_id, area_id=area_id) - tools/entities.py:85-85 (registration)The @mcp.tool() decorator registers the function as an MCP tool named 'assign_entity_to_area' (derived from the function name).
@mcp.tool() - ha_client.py:181-182 (helper)The helper function update_entity_registry that sends a WebSocket call to 'config/entity_registry/update' with the entity_id and kwargs (including area_id).
def update_entity_registry(entity_id: str, **kwargs) -> dict: return _ws_call("config/entity_registry/update", entity_id=entity_id, **kwargs) - ha_client.py:59-66 (helper)The _ws_call helper that bridges async WebSocket calls to synchronous context, used by update_entity_registry.
def _ws_call(msg_type: str, **kwargs) -> Any: try: asyncio.get_running_loop() except RuntimeError: return asyncio.run(_ws_call_async(msg_type, **kwargs)) import concurrent.futures with concurrent.futures.ThreadPoolExecutor() as pool: return pool.submit(asyncio.run, _ws_call_async(msg_type, **kwargs)).result()