consultar_habitaciones
Retrieve a complete list of rooms with their device counts by type to manage your smart home setup.
Instructions
Obtiene la lista completa de habitaciones con su información.
Returns: Lista de habitaciones con nombre y cantidad de dispositivos por tipo.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- servers/mcp_rooms.py:145-153 (handler)MCP tool handler decorated with @mcp.tool(). Executes by calling storage.list_rooms() to return the list of rooms with device counts.def consultar_habitaciones() -> list[dict]: """ Obtiene la lista completa de habitaciones con su información. Returns: Lista de habitaciones con nombre y cantidad de dispositivos por tipo. """ return storage.list_rooms()
- storage.py:128-147 (helper)Core helper method in DomoticaStorage that lists all rooms, counts devices by type for each room, and returns structured data.def list_rooms(self) -> list[dict]: """Lista todas las habitaciones con estadísticas.""" self.reload() # Sincronizar con archivo result = [] for room in self.rooms.values(): lights = sum(1 for d in room.devices if self.devices[d].type == "light") thermos = sum(1 for d in room.devices if self.devices[d].type == "thermostat") fans = sum(1 for d in room.devices if self.devices[d].type == "fan") ovens = sum(1 for d in room.devices if self.devices[d].type == "oven") result.append({ "name": room.name, "type": room.type, "light_count": lights, "thermostat_count": thermos, "fan_count": fans, "oven_count": ovens, "total_devices": len(room.devices) }) return result