get_alpha_ess_data
Retrieve statistical energy data for all registered Alpha ESS solar and battery systems to monitor performance and analyze consumption patterns.
Instructions
Get statistical energy data for all registered Alpha ESS systems.
Returns:
dict: Energy data with success status and system information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:359-403 (handler)The primary handler function for the 'get_alpha_ess_data' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Fetches statistical energy data from Alpha ESS API for all registered systems using the alphaess client.getdata() method. Includes error handling for authentication, API calls, and proper client cleanup.@mcp.tool() async def get_alpha_ess_data() -> dict[str, Any]: """ Get statistical energy data for all registered Alpha ESS systems. Returns: dict: Energy data with success status and system information """ client = None try: app_id, app_secret = get_alpha_credentials() client = alphaess(app_id, app_secret) # Get energy data data = await client.getdata() if data is not None: return { "success": True, "message": "Successfully retrieved Alpha ESS energy data", "data": data } else: return { "success": False, "message": "Failed to retrieve energy data - API returned None", "data": None } except ValueError as e: return { "success": False, "message": f"Configuration error: {str(e)}", "data": None } except Exception as e: return { "success": False, "message": f"Error retrieving energy data: {str(e)}", "data": None } finally: if client: await client.close()
- main.py:229-238 (helper)Supporting helper function used by get_alpha_ess_data to retrieve Alpha ESS API credentials from environment variables and validate their presence.def get_alpha_credentials(): """Get Alpha ESS credentials from environment variables""" app_id = os.getenv('ALPHA_ESS_APP_ID') app_secret = os.getenv('ALPHA_ESS_APP_SECRET') if not app_id or not app_secret: raise ValueError("ALPHA_ESS_APP_ID and ALPHA_ESS_APP_SECRET environment variables must be set") return app_id, app_secret