list_entities
Retrieve all entities in Home Assistant to monitor and control devices. Filter by domain like light or switch to find specific entities.
Instructions
List all available entities in Home Assistant
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | Optional domain filter (e.g., light, switch, automation) |
Implementation Reference
- src/index.ts:202-223 (handler)The handler function for the 'list_entities' tool. It fetches all entity states from the Home Assistant API, optionally filters by domain, maps to a simplified structure, and returns as formatted JSON text.private async listEntities(args: any) { const response = await this.haClient.get('/api/states'); let entities = response.data; if (args.domain) { entities = entities.filter((entity: any) => entity.entity_id.startsWith(args.domain + '.')); } return { content: [ { type: 'text', text: JSON.stringify(entities.map((entity: any) => ({ entity_id: entity.entity_id, state: entity.state, attributes: entity.attributes, })), null, 2), }, ], }; }
- src/index.ts:103-115 (registration)Registration of the 'list_entities' tool in the ListToolsRequestHandler response. Includes name, description, and input schema definition.{ name: 'list_entities', description: 'List all available entities in Home Assistant', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'Optional domain filter (e.g., light, switch, automation)', }, }, }, },
- src/index.ts:128-129 (registration)Dispatch case in the CallToolRequestHandler switch statement that invokes the listEntities handler.case 'list_entities': return await this.listEntities(request.params.arguments);