get_consumption_data
Retrieve hourly consumption data for the past 30 days, including time period, total cost, base energy cost, and kWh usage. Ideal for monitoring and analyzing energy consumption.
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 handler function decorated with @mcp.tool(), which registers and implements the get_consumption_data tool. It connects to Tibber API, fetches homes, retrieves hourly consumption data for the last 30 days, and returns it as string.@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)}"