This custom component integrates Octopus Germany services with Home Assistant, providing access to your energy account data, electricity prices, device control, and vehicle charging preferences.
This integration is in no way affiliated with Octopus Energy.
If you find this useful and are planning on moving to Octopus Energy Germany, why not use my referral link?
- Account information display with electricity and gas balances
- Current electricity and gas tariff prices
- Support for Octopus tariff types:
- Simple tariffs (fixed rate)
- Time of Use tariffs (different rates at different times)
- Dynamic tariffs (with real-time pricing using unit rate forecasts)
- Heat tariffs (for heat pumps)
- Gas infrastructure monitoring (MALO/MELO numbers, meters, readings)
- Latest Electricity meter reading
- Gas contract tracking with expiry countdown
- Device smart control (suspend/unsuspend charging)
- Electric vehicle charging preferences management
- Intelligent dispatching status tracking
- octopus-energy-rates-card compatibility for dynamic tariff visualization
- Add this repository as a custom repository in HACS
- Search for "Octopus Germany" in the HACS integrations
- Install the integration
- Restart Home Assistant
- Add the integration via the UI under Settings > Devices & Services > Add Integration
- Copy the
octopus_germany
directory to your Home Assistantcustom_components
directory - Restart Home Assistant
- Add the integration via the UI under Settings > Devices & Services > Add Integration
The integration is configured via the Home Assistant UI:
- Navigate to Settings > Devices & Services
- Click + ADD INTEGRATION and search for "Octopus Germany"
- Enter your Octopus Energy Germany email and password
- The integration will automatically fetch your account number and set up the entities
- Entity ID:
sensor.octopus_<account_number>_electricity_price
- Description: Shows the current electricity price in €/kWh
- Tariff support:
- Simple tariffs: Displays the fixed rate
- Time of Use tariffs: Automatically updates to show the currently active rate based on the time of day
- Dynamic tariffs: Uses real-time pricing data from unit rate forecasts for the most accurate current price
- Heat tariffs: Supports specific heat pump tariffs like Heat Light and shows the applicable rate
- Attributes:
code
: Product codename
: Product namedescription
: Product descriptiontype
: Product type (Simple or TimeOfUse)valid_from
: Start date of validityvalid_to
: End date of validitymeter_id
: ID of your metermeter_number
: Number of your metermeter_type
: Type of your meter (MME, iMSys, etc.)account_number
: Your Octopus Energy account numbermalo_number
: Your electricity meter point numbermelo_number
: Your electricity meter numberelectricity_balance
: Your current account balance in EURtimeslots
: (For TimeOfUse tariffs) List of all time slots with their rates and activation timesactive_timeslot
: (For TimeOfUse tariffs) Currently active time slot name (e.g., "GO", "STANDARD")rates
: (For Dynamic tariffs) Rate data formatted for octopus-energy-rates-card compatibilityrates_count
: (For Dynamic tariffs) Number of available ratesunit_rate_forecast
: (For Dynamic tariffs) Native German API unit rate forecast data
- Entity ID:
sensor.octopus_<account_number>_electricity_latest_reading
- Description: Latest electricity meter reading with timestamp and origin information
- Unit: kWh
- Attributes:
reading_value
: Reading value in kWhreading_units
: Reading units (kWh)reading_date
: Date of the reading (formatted)reading_origin
: Origin of the reading (CUSTOMER, ESTIMATED, etc.)reading_type
: Type of reading (ACTUAL, ESTIMATED, etc.)register_obis_code
: OBIS code for the registerregister_type
: Type of the registermeter_id
: ID of the electricity meterread_at
: Raw timestamp from APIaccount_number
: Your Octopus Energy account number
- Entity ID:
sensor.octopus_<account_number>_electricity_balance
- Description: Shows the current electricity account balance in EUR
- Unit: €
- Note: Only available for accounts with electricity service (MALO number present)
- Entity ID:
sensor.octopus_<account_number>_gas_tariff
- Description: Shows the current gas product code and tariff details
- Attributes:
code
: Product codename
: Product namedescription
: Product descriptiontype
: Product typevalid_from
: Start date of validityvalid_to
: End date of validityaccount_number
: Your Octopus Energy account number
- Entity ID:
sensor.octopus_<account_number>_gas_balance
- Description: Shows the current gas account balance in EUR
- Unit: €
- Note: Only available for accounts with gas service (gas MALO number present)
-
Entity ID:
sensor.octopus_<account_number>_gas_malo_number
-
Description: Market location identifier for gas supply
-
Entity ID:
sensor.octopus_<account_number>_gas_melo_number
-
Description: Meter location identifier for gas supply
-
Entity ID:
sensor.octopus_<account_number>_gas_meter
-
Description: Current gas meter information with ID, number, and type
-
Attributes:
meter_id
: ID of your gas metermeter_number
: Number of your gas metermeter_type
: Type of your gas meteraccount_number
: Your Octopus Energy account number
-
Entity ID:
sensor.octopus_<account_number>_gas_latest_reading
-
Description: Latest gas meter reading with timestamp and origin information
-
Unit: m³
-
Attributes:
reading_value
: Reading valuereading_units
: Reading units (m³)reading_date
: Date of the readingreading_origin
: Origin of the readingreading_type
: Type of readingregister_obis_code
: OBIS code for the registermeter_id
: ID of the meteraccount_number
: Your Octopus Energy account number
-
Entity ID:
sensor.octopus_<account_number>_gas_price
-
Description: Current gas tariff rate from valid contracts
-
Unit: €/kWh
-
Entity ID:
sensor.octopus_<account_number>_gas_smart_reading
-
Description: Smart meter capability status (Enabled/Disabled)
-
Entity ID:
sensor.octopus_<account_number>_gas_contract_start
-
Description: Contract validity start date
-
Entity ID:
sensor.octopus_<account_number>_gas_contract_end
-
Description: Contract validity end date
-
Entity ID:
sensor.octopus_<account_number>_gas_contract_days_until_expiry
-
Description: Contract expiration countdown in days
- Entity ID:
sensor.octopus_<account_number>_device_status
- Description: Current status of your smart charging device (e.g., "PLUGGED_IN", "CHARGING", "FINISHED", etc.)
- Attributes:
device_id
: Internal ID of the connected devicedevice_name
: Name of the devicedevice_model
: Vehicle model (if available)device_provider
: Device providerbattery_size
: Battery capacity (if available)is_suspended
: Whether smart charging is currently suspendedaccount_number
: Your Octopus Energy account numberlast_updated
: Timestamp of the last update
- Entity ID:
binary_sensor.octopus_<account_number>_intelligent_dispatching
- Description: Shows whether intelligent dispatching (smart charging) is currently active
- State:
on
when a dispatch is active,off
otherwise - Attributes:
planned_dispatches
: List of upcoming charging sessionscompleted_dispatches
: List of past charging sessionsdevices
: List of connected devicescurrent_state
: Current state of your smart charging devicelast_updated
: Timestamp of the last update
- Entity ID:
switch.octopus_<account_number>_device_smart_control
- Description: Controls whether smart charging is enabled for your vehicle
- Actions:
- Turn ON to enable smart charging (unsuspend)
- Turn OFF to disable smart charging (suspend)
- Attributes:
device_id
: Internal ID of the connected devicename
: Name of the devicemodel
: Vehicle model (if available)battery_size
: Battery capacity (if available)provider
: Device providerstatus
: Current status of the devicelast_updated
: Timestamp of the last update
- Service ID:
octopus_germany.set_vehicle_charge_preferences
- Description: Configure your vehicle's charging preferences
- Parameters:
account_number
(optional): Your Octopus Energy account number (uses account from configuration if not specified)weekday_target_soc
(required): Target state of charge (in %) for weekdaysweekend_target_soc
(required): Target state of charge (in %) for weekendsweekday_target_time
(required): Target time for weekday charging (HH:MM)weekend_target_time
(required): Target time for weekend charging (HH:MM)
Example:
# Example automation to set vehicle charging preferences to 80% by 7:30 AM on weekdays and 90% by 9:00 AM on weekends
service: octopus_germany.set_vehicle_charge_preferences
data:
weekday_target_soc: 80
weekend_target_soc: 90
weekday_target_time: "07:30"
weekend_target_time: "09:00"
Octopus Intelligent Go mit EVCC
If you encounter issues, you can enable debug logging by adding the following to your configuration.yaml
:
logger:
logs:
custom_components.octopus_germany: debug
If you need more information for API debug set in const:
/config/custom_components/octopus_germany/const.py
LOG_API_RESPONSES = True
After restarting HA the API-Responses and additional information will be in debug log.
For bug reports and feature requests, please open an issue on the GitHub repository. Before raising anything, please read through the discussion. If you have found a bug or have a feature request please raise it using the appropriate report template.
https://deepwiki.com/thecem/octopus_germany
If you are enjoying the integration, why not use my referral link
This project is licensed under the MIT License - see the LICENSE file for details.
This integration is not officially affiliated with Octopus Energy Germany. Use at your own risk.
A comprehensive Python client for interacting with the OEG Kraken Energy API, based on the official developer documentation at https://developer.oeg-kraken.energy/.
- Complete API Coverage: Supports all major endpoints including account management, consumption data, tariff rates, meter readings, and billing information
- REST & GraphQL Support: Both REST API and GraphQL interfaces for maximum flexibility
- Type Safety: Fully typed with modern Python type hints
- Flexible Authentication: Support for environment variables and configuration files
- Utility Functions: Built-in functions for common operations like cost calculations and data analysis
- Error Handling: Comprehensive error handling with proper logging
- Data Models: Structured data classes for clean data handling
- Advanced Analytics: Energy insights, weather correlation, and tariff optimization
- Clone this repository or copy the
kraken_api
folder to your project - Install required dependencies:
pip install requests
You can configure your API credentials in two ways:
export KRAKEN_API_KEY="your-api-key-here"
export KRAKEN_ACCOUNT_NUMBER="your-account-number"
export KRAKEN_BASE_URL="https://api.oeg-kraken.energy" # Optional, defaults to this
Create a file at ~/.config/octopus_germany/kraken_config.json
:
{
"api_key": "your-api-key-here",
"account_number": "your-account-number",
"base_url": "https://api.oeg-kraken.energy"
}
from kraken_api import KrakenApiClient
from kraken_api.config import load_credentials
from datetime import datetime, timedelta
# Load credentials
credentials = load_credentials()
# Create client
client = KrakenApiClient(credentials)
# Get account information
account_info = client.get_account_info()
print(f"Account: {account_info['number']}")
# Get consumption data
if properties:
prop = properties[0]
electricity_meters = prop.get('electricity_meter_points', [])
if electricity_meters:
mpan = electricity_meters[0]['mpan']
# Get last 30 days of consumption
end_date = datetime.now()
start_date = end_date - timedelta(days=30)
consumption = client.get_electricity_consumption(
mpan, start_date, end_date, 'day'
)
print(f"Consumption records: {len(consumption)}")
if consumption:
total = sum(record.consumption for record in consumption)
print(f"Total consumption: {total:.2f} kWh")
from kraken_api import KrakenGraphQLClient
from kraken_api.config import load_credentials
# Load credentials
credentials = load_credentials()
# Create GraphQL client
client = KrakenGraphQLClient(credentials)
# Get comprehensive account details with nested data
account_details = client.get_account_details()
account = account_details['account']
print(f"Account: {account['number']}")
print(f"Balance: €{account['balance']:.2f}")
# Get detailed consumption with statistics
consumption_data = client.get_consumption_data(
mpan, start_date, end_date, "electricity", "DAY"
)
consumption = consumption_data['electricityMeterPoint']['consumption']
print(f"Total consumption: {consumption['totalConsumption']:.2f} kWh")
print(f"Total cost: €{consumption['totalCost']:.2f}")
print(f"Peak usage: {consumption['statistics']['peakConsumption']:.2f} kWh")
get_account_info()
: Get account informationget_properties()
: Get all properties associated with the accountget_electricity_consumption()
: Get electricity consumption dataget_gas_consumption()
: Get gas consumption dataget_electricity_tariff_rates()
: Get electricity tariff ratesget_gas_tariff_rates()
: Get gas tariff ratessubmit_meter_reading()
: Submit meter readingget_payments()
: Get payment historyget_bills()
: Get billing informationget_products()
: Get available products
get_account_details()
: Get comprehensive account information with nested dataget_consumption_data()
: Get detailed consumption data with statisticsget_tariff_comparison()
: Compare costs across different tariffsget_smart_devices()
: Get smart devices and their statusset_device_preferences()
: Set preferences for smart devicesget_products_and_tariffs()
: Get available products and tariffsget_carbon_intensity()
: Get carbon intensity dataget_energy_insights()
: Get energy insights and recommendationsget_live_consumption()
: Get live consumption dataget_weather_data()
: Get weather data for energy analysisget_grid_supply_points()
: Get grid supply point information
get_comprehensive_account_overview()
: Complete account overviewanalyze_consumption_with_weather()
: Consumption analysis with weather correlationcompare_tariff_scenarios()
: Advanced tariff comparisonget_smart_charging_optimization()
: Smart charging optimizationget_energy_efficiency_report()
: Comprehensive efficiency reportget_grid_flexibility_opportunities()
: Grid flexibility analysis
@dataclass
class ApiCredentials:
api_key: str
account_number: str
base_url: str = "https://api.oeg-kraken.energy"
@dataclass
class EnergyConsumption:
interval_start: datetime
interval_end: datetime
consumption: float
unit: str
@dataclass
class TariffRate:
valid_from: datetime
valid_to: datetime | None
value_exc_vat: float
value_inc_vat: float
unit: str
GraphQL Advantages:
- Request exactly the data you need
- Single request for complex nested data
- Built-in statistics and analytics
- Advanced filtering and grouping
- Real-time data capabilities
Use GraphQL when:
- You need detailed, nested data in one request
- You want consumption statistics and analytics
- You're building dashboards or reports
- You need real-time or live data
- You want to minimize API calls
Use REST when:
- You need simple, straightforward data
- You're doing basic CRUD operations
- You want to minimize complexity
- You're building simple integrations
from kraken_api.graphql_utils import analyze_consumption_with_weather
# Analyze consumption patterns with weather data
weather_analysis = analyze_consumption_with_weather(
client, mpan, postcode, start_date, end_date
)
# Get high usage days with weather conditions
high_usage_days = weather_analysis["insights"]["high_usage_weather_conditions"]
for day in high_usage_days:
print(f"High usage: {day['consumption']:.2f} kWh on {day['date']}")
print(f"Temperature: {day['temperature']}°C")
print(f"Conditions: {day['conditions']}")
from kraken_api.graphql_utils import get_smart_charging_optimization
# Get smart charging optimization recommendations
optimization = get_smart_charging_optimization(client)
# Show current settings
for device_id, settings in optimization["current_settings"].items():
print(f"Device {device_id}:")
print(f" Charging enabled: {settings['charging_enabled']}")
print(f" Target SoC: {settings['target_soc']}%")
print(f" Target time: {settings['target_time']}")
# Show performance metrics
metrics = optimization["performance_metrics"]
print(f"Average charging cost: €{metrics['average_charging_cost']:.2f}")
print(f"Carbon intensity: {metrics['carbon_intensity_average']:.0f} gCO2/kWh")
from kraken_api.graphql_utils import compare_tariff_scenarios
# Compare different tariff scenarios
comparison = compare_tariff_scenarios(
client, mpan, ["AGILE-FLEX-22-11-25", "INTELLIGENT-GO-22-11-25"]
)
best_tariff = comparison["recommendations"]["best_overall"]
print(f"Best tariff: {best_tariff['tariff_name']}")
print(f"Potential savings: €{best_tariff['potential_savings']:.2f}")
from kraken_api.graphql_utils import get_energy_efficiency_report
# Generate comprehensive efficiency report
report = get_energy_efficiency_report(client, period_months=12)
print(f"Efficiency score: {report['efficiency_score']:.1f}/10")
print(f"Potential savings: €{report['cost_analysis']['potential_savings']:.2f}")
# Show recommendations
for rec in report["recommendations"]:
print(f"• {rec['title']}: €{rec['potential_savings']:.2f} savings")
Both clients include comprehensive error handling:
from kraken_api import GraphQLError
try:
# REST API
consumption = client.get_electricity_consumption(mpan, start_date, end_date)
# GraphQL API
account_details = graphql_client.get_account_details()
except GraphQLError as e:
print(f"GraphQL errors: {e.errors}")
except requests.exceptions.RequestException as e:
print(f"API request failed: {e}")
except ValueError as e:
print(f"Invalid parameters: {e}")
Both clients use Python's built-in logging module:
import logging
logging.basicConfig(level=logging.DEBUG)
example_usage.py
: Complete REST API exampleexample_graphql_usage.py
: Complete GraphQL API example
Both clients automatically handle rate limiting according to the API's guidelines.
- Follow the existing code style and type hints
- Add appropriate error handling and logging
- Include docstrings for all public methods
- Add tests for new functionality
This project is provided as-is for educational and development purposes. Please review the OEG Kraken Energy API terms of service before use.
For API-related questions, consult the official documentation:
- REST API: https://developer.oeg-kraken.energy/
- GraphQL API: https://developer.oeg-kraken.energy/graphql/
For client-specific issues, please check the code and error messages for troubleshooting guidance.