get_consumption_data
Retrieve hourly energy consumption data for the past 30 days, including time periods, total costs, base energy costs, and consumed kWh.
Instructions
Get the hourly consumption data for the last 30 days, such as time period, total cost, base energy cost, and consumpted kwh.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:49-72 (handler)The main handler function for the 'get_consumption_data' tool. It connects to the Tibber API, fetches homes, retrieves consumption data, and returns it as a string. Registered via @mcp.tool() decorator.@mcp.tool() async def get_consumption_data() -> str: """Get the hourly consumption data for the last 30 days, such as time period, total cost, base energy cost, and consumpted kwh. """ try: tibber_connection = tibber.Tibber(tibber_api_token, user_agent="tibber-mcp") await tibber_connection.update_info() homes = tibber_connection.get_homes() if not homes: logger.error("No homes found for this Tibber account") return "No homes found" home = homes[0] await home.fetch_consumption_data() await tibber_connection.close_connection() result = home.hourly_consumption_data return str(result) except Exception as e: logger.error(f"Error retrieving price info: {e}") return f"Error: {str(e)}"