Python Library¶
The official Python library aio-wattwaechter provides async access to the WattWächter REST API. It covers all API endpoints and is suitable for custom scripts as well as a foundation for smart home integrations.
Installation¶
pip install aio-wattwaechter
Quick Start¶
import asyncio
from aio_wattwaechter import Wattwaechter
async def main():
# No token needed if authentication is disabled (factory default)
async with Wattwaechter("192.168.1.100") as client:
# Get current meter readings
data = await client.meter_data()
if data:
print(f"Power: {data.power} W")
print(f"Total consumption: {data.total_consumption} kWh")
# System diagnostics
info = await client.system_info()
print(f"WiFi RSSI: {info.get_value('wifi', 'RSSI')} dBm")
# 15-minute resolution history
history = await client.history_high_res("2024-03-08")
for entry in history.items:
print(f" {entry.date}: {entry.power_w} W")
asyncio.run(main())
Authentication¶
By default, authentication is disabled — you can connect without a token:
client = Wattwaechter("192.168.1.100")
When authentication is enabled, two token levels are supported:
# Read-only (history, status, view settings)
client = Wattwaechter("192.168.1.100", token="your-read-token")
# Full access (change settings, OTA, reboot)
client = Wattwaechter("192.168.1.100", token="your-write-token")
Automatic Retry¶
The client automatically retries requests on 429 (rate limit) or 503 (device busy), respecting the Retry-After header:
# Default: 3 attempts
client = Wattwaechter("192.168.1.100")
# Custom configuration
client = Wattwaechter("192.168.1.100", max_retries=5)
# Disable retries
client = Wattwaechter("192.168.1.100", max_retries=1)
API Coverage¶
| Category | Methods |
|---|---|
| System | alive, system_info, led, selftest, wifi_scan, timezones, reboot |
| Meter Data | meter_data, history_high_res, history_low_res |
| Logs | logs_rawdump, logs_persistent, logs_ram |
| OTA | ota_check, ota_start |
| Settings | settings, update_settings |
| Auth | generate_tokens, confirm_tokens, setup_token |
| MQTT | mqtt_ca_status, mqtt_ca_upload, mqtt_ca_delete |
| Cloud | cloud_pair, cloud_unpair |
Reusing an Existing Session¶
An existing aiohttp.ClientSession can be passed in — useful for Home Assistant integrations:
client = Wattwaechter(
"192.168.1.100",
token="your-token",
session=existing_session,
)
Home Assistant
This library is the foundation for the WattWächter Home Assistant integration.
Source Code & License¶
- PyPI: pypi.org/project/aio-wattwaechter
- GitHub: github.com/SmartCircuits-GmbH/WattWaechter-PyPI
- License: Apache License 2.0