Skip to main content

Kerblwelt API Client

Python API client for Kerbl Welt IoT platform, which powers the AKO Smart Satellite electric fence monitoring system.

Features

  • Async/await support for efficient I/O operations
  • Full type hints for better IDE support and type checking
  • Automatic token management with refresh capability
  • Comprehensive error handling with custom exceptions
  • Data models using Python dataclasses
  • Well-tested with pytest

Installation

pip install kerblwelt-api

Or for development:

git clone https://github.com/stgarrity/kerblwelt-api
cd kerblwelt-api
pip install -e ".[dev]"

Quick Start

import asyncio
from kerblwelt_api import KerblweltClient

async def main():
    async with KerblweltClient() as client:
        # Authenticate
        await client.authenticate("your-email@example.com", "your-password")

        # Get all devices
        devices = await client.get_devices()

        for device in devices:
            print(f"Device: {device.description}")
            print(f"  Fence Voltage: {device.fence_voltage}V")
            print(f"  Battery: {device.battery_state}%")
            print(f"  Signal: {device.signal_quality}%")
            print(f"  Online: {device.is_online}")
            print(f"  Status: {'OK' if device.is_fence_voltage_ok else 'LOW VOLTAGE!'}")

if __name__ == "__main__":
    asyncio.run(main())

Usage

Authentication

async with KerblweltClient() as client:
    # Method 1: Authenticate with credentials
    await client.authenticate("email@example.com", "password")

    # Method 2: Restore previous session with tokens
    client.set_tokens(
        access_token="eyJhbGci...",
        refresh_token="eyJhbGci..."
    )

Get User Information

user = await client.get_user()
print(f"User: {user.email}")
print(f"Timezone: {user.timezone}")
print(f"Language: {user.language}")

Get Devices

# Get all Smart Satellite devices
devices = await client.get_devices()

# Get a specific device by ID
device = await client.get_device("device-uuid-here")

# Get device with event count
device_data = await client.get_all_device_data()
for device_id, (device, events) in device_data.items():
    print(f"{device.description}: {events.new} new events")

Access Device Properties

device = devices[0]

# Basic info
print(device.description)      # User-defined name
print(device.id)                # Device UUID
print(device.identifier)        # Serial number

# Status
print(device.is_online)         # Online/offline
print(device.is_fence_voltage_ok)  # Voltage above threshold
print(device.is_battery_low)    # Battery below 20%

# Measurements
print(device.fence_voltage)     # Current voltage (V)
print(device.battery_voltage)   # Battery voltage (V)
print(device.battery_state)     # Battery percentage (0-100)
print(device.signal_quality)    # Signal strength (0-100)

# Thresholds
print(device.fence_voltage_alarm_threshold)  # Alert threshold (V)

# Timestamps
print(device.registered_at)     # Registration date
print(device.first_online_at)   # First connection
print(device.offline_since)     # Last offline time

Token Refresh

The client automatically handles token expiration. You can also manually refresh:

try:
    devices = await client.get_devices()
except TokenExpiredError:
    await client.refresh_token()
    devices = await client.get_devices()

Error Handling

from kerblwelt_api import (
    InvalidCredentialsError,
    DeviceNotFoundError,
    APIError,
    ConnectionError,
)

try:
    await client.authenticate("email@example.com", "wrong-password")
except InvalidCredentialsError:
    print("Invalid email or password")
except ConnectionError:
    print("Cannot connect to Kerbl Welt API")
except APIError as e:
    print(f"API error: {e}")

API Reference

KerblweltClient

Main client class for interacting with Kerbl Welt API.

Methods:

  • authenticate(email: str, password: str) -> None - Authenticate with credentials
  • set_tokens(access_token: str, refresh_token: str) -> None - Set tokens manually
  • refresh_token() -> None - Refresh the access token
  • get_user() -> User - Get current user information
  • get_devices() -> list[SmartSatelliteDevice] - Get all Smart Satellite devices
  • get_device(device_id: str) -> SmartSatelliteDevice - Get specific device
  • get_device_event_count(device_id: str) -> DeviceEventCount - Get event count
  • get_all_device_data() -> dict - Get all devices with event counts
  • close() -> None - Close the client session

Properties:

  • is_authenticated: bool - Check if client is authenticated

SmartSatelliteDevice

Represents an AKO Smart Satellite electric fence monitor.

Key Attributes:

  • id: str - Device UUID
  • description: str - User-defined device name
  • fence_voltage: int - Current fence voltage in volts
  • battery_voltage: float - Battery voltage in volts
  • battery_state: int - Battery percentage (0-100)
  • signal_quality: int - Signal strength (0-100)
  • is_online: bool - Device online status
  • fence_voltage_alarm_threshold: int - Alert threshold in volts

Helper Properties:

  • is_fence_voltage_ok: bool - Voltage above threshold
  • is_battery_low: bool - Battery below 20%

Exceptions

All exceptions inherit from KerblweltError:

  • AuthenticationError - Base authentication error
    • InvalidCredentialsError - Wrong email/password
    • TokenExpiredError - Token has expired
    • TokenRefreshError - Token refresh failed
  • APIError - API request failed
  • ConnectionError - Network connection failed
  • DeviceNotFoundError - Device ID not found
  • RateLimitError - API rate limit exceeded
  • ValidationError - Input validation failed

Development

Setup

# Clone repository
git clone https://github.com/stgarrity/kerblwelt-api
cd kerblwelt-api

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install with dev dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=kerblwelt_api

# Run specific test file
pytest tests/test_client.py

Code Quality

# Format code
black kerblwelt_api tests

# Lint code
ruff check kerblwelt_api tests

# Type checking
mypy kerblwelt_api

Requirements

  • Python 3.11 or higher
  • aiohttp 3.9.0 or higher

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Acknowledgments

  • Built for the Kerbl Welt IoT platform
  • Powers AKO Smart Satellite electric fence monitors
  • Designed for integration with Home Assistant

Support

For issues and questions:

Metadata

Release files for kerblwelt-api 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kerblwelt-api 0.1.3
File Size Uploaded Provenance
kerblwelt_api-0.1.3.tar.gz 16.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for kerblwelt-api 0.1.3
File Interpreter ABI Platform
kerblwelt_api-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 30.7 kB

Release files / kerblwelt_api-0.1.3.tar.gz

Download URL kerblwelt_api-0.1.3.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2bc5acf05aa53a546dddcab42fc39c86104fc7c821fc9ae70b8c616a47554844
BLAKE2b-256 checksum
How to use checksums
efbd38997bff6ce54b8539744873af1783ae05522b7a64908d745194a03c8b72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / kerblwelt_api-0.1.3-py3-none-any.whl

Download URL kerblwelt_api-0.1.3-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01f85c05eebc7bf887f77acfaa2d05b2dfaa5a09b3f83d96bf4d5cdf4892eb8b
BLAKE2b-256 checksum
How to use checksums
ef792fa98a1fb1a0b11f1412975e815dd14f81ea816237bc9734a4d3686b66d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for kerblwelt-api 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page