Skip to main content

Unoffical async Python client for SEKO PoolDose devices

Project description

python-pooldose

Unofficial async Python client for SEKO Pooldosing systems. SEKO is a manufacturer of various monitoring and control devices for Pools and Spas. This client uses an undocumented local HTTP API. It provides live readings for pool sensors such as temperature, pH, ORP/Redox, as well as status information and control over the dosing logic.

Features

  • Async/await support for non-blocking operations
  • Dynamic sensor discovery based on device model and firmware
  • Dictionary-style access to instant values
  • Type-specific getters for sensors, switches, numbers, selects
  • Secure by default - WiFi passwords excluded unless explicitly requested
  • Comprehensive error handling with detailed logging

API Overview

Program Flow

1. Create PooldoseClient
   ├── Fetch Device Info
   │   ├── Debug Config
   │   ├── WiFi Station Info (optional)
   │   ├── Access Point Info (optional)
   │   └── Network Info
   ├── Load Mapping JSON (based on MODEL_ID + FW_CODE)
   └── Query Available Types
       ├── Sensors
       ├── Binary Sensors
       ├── Numbers
       ├── Switches
       └── Selects

2. Get Instant Values
   └── Access Values via Dictionary Interface
       ├── instant_values['temperature']
       ├── instant_values.get('ph', default)
       └── 'sensor_name' in instant_values

3. Set Values via Type Methods
   ├── set_number()
   ├── set_switch()
   └── set_select()

API Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│  PooldoseClient │────│ RequestHandler  │────│   HTTP Device   │
└─────────────────┘    └─────────────────┘    └─────────────────┘
         │                       │
         │                       ▼
         │              ┌─────────────────┐
         │              │ API Endpoints   │
         │              │ • get_debug     │
         │              │ • get_wifi      │
         │              │ • get_values    │
         │              │ • set_value     │
         │              └─────────────────┘
         │
         ▼
┌─────────────────┐    ┌─────────────────┐
│   MappingInfo   │────│  JSON Files     │
└─────────────────┘    └─────────────────┘
         │
         ▼
┌─────────────────┐
│ Type Discovery  │
│ • Sensors       │
│ • Switches      │
│ • Numbers       │
│ • Selects       │
└─────────────────┘
         │
         ▼
┌─────────────────┐    ┌─────────────────┐
│  InstantValues  │────│ Dictionary API  │
└─────────────────┘    └─────────────────┘
         │
         ▼
┌─────────────────┐
│ Type Methods    │
│ • set_number()  │
│ • set_switch()  │
│ • set_select()  │
└─────────────────┘

Prerequisites

  1. Install and set-up the PoolDose devices according to the user manual.
    1. In particular, connect the device to your WiFi network.
    2. Identify the IP address or hostname of the device.
  2. Browse to the IP address or hostname (default port: 80).
    1. Try to log in to the web interface with the default password (0000).
    2. Check availability of data in the web interface.
  3. Optionally: Block the device from internet access to ensure cloudless-only operation.

Installation

pip install python-pooldose

Example Usage

Basic Example

import asyncio
import json
from pooldose.client import PooldoseClient
from pooldose.request_handler import RequestStatus

HOST = "192.168.1.100"  # Change this to your device's host or IP address
TIMEOUT = 30

async def main() -> None:
    """Demonstrate PooldoseClient usage with new dictionary-based API."""
    
    # Create client instance (excludes WiFi passwords by default)
    client = PooldoseClient(host=HOST, timeout=TIMEOUT)
    
    # Optional: Include sensitive data like WiFi passwords
    # client = PooldoseClient(host=HOST, timeout=TIMEOUT, include_sensitive_data=True)
    
    # Connect to device
    status = await client.connect()
    if status != RequestStatus.SUCCESS:
        print(f"Error connecting to device: {status}")
        return
    
    print(f"Connected to {HOST}")
    print("Device Info:", json.dumps(client.device_info, indent=2))

    # --- Query available types dynamically ---
    print("\nAvailable types:")
    for typ, keys in client.available_types().items():
        print(f"  {typ}: {keys}")

    # --- Query available sensors ---
    print("\nAvailable sensors:")
    for name, sensor in client.available_sensors().items():
        print(f"  {name}: key={sensor.key}, type={sensor.type}")
        if sensor.conversion is not None:
            print(f"    conversion: {sensor.conversion}")

    # --- Get static values ---
    status, static_values = client.static_values()
    if status == RequestStatus.SUCCESS:
        print(f"Device Name: {static_values.sensor_name}")
        print(f"Serial Number: {static_values.sensor_serial_number}")
        print(f"Firmware Version: {static_values.sensor_fw_version}")

    # --- Get instant values ---
    status, instant_values = await client.instant_values()
    if status != RequestStatus.SUCCESS:
        print(f"Error getting instant values: {status}")
        return

    # --- Dictionary-style access ---
    
    # Get all sensors at once
    print("\nAll sensor values:")
    sensors = instant_values.get_sensors()
    for key, value in sensors.items():
        if isinstance(value, tuple) and len(value) >= 2:
            print(f"  {key}: {value[0]} {value[1]}")

    # Dictionary-style individual access
    if "temperature" in instant_values:
        temp = instant_values["temperature"]
        print(f"Temperature: {temp[0]} {temp[1]}")

    # Get with default
    ph_value = instant_values.get("ph", "Not available")
    print(f"pH: {ph_value}")

    # --- Setting values ---
    
    # Set number values
    if "ph_target" in instant_values.get_numbers():
        result = await instant_values.set_number("ph_target", 7.2)
        print(f"Set pH target to 7.2: {result}")

    # Set switch values
    if "stop_pool_dosing" in instant_values.get_switches():
        result = await instant_values.set_switch("stop_pool_dosing", True)
        print(f"Set stop pool dosing: {result}")

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

Advanced Usage

Connection Management

# Recommended: Separate initialization and connection
client = PooldoseClient("192.168.1.100", timeout=30)
status = await client.connect()

# Check connection status
if client.is_connected:
    print("Client is connected")
else:
    print("Client is not connected")

Error Handling

from pooldose.request_handler import RequestStatus

client = PooldoseClient("192.168.1.100")
status = await client.connect()

if status == RequestStatus.SUCCESS:
    print("Connected successfully")
elif status == RequestStatus.HOST_UNREACHABLE:
    print("Could not reach device")
elif status == RequestStatus.PARAMS_FETCH_FAILED:
    print("Failed to fetch device parameters")
elif status == RequestStatus.API_VERSION_UNSUPPORTED:
    print("Unsupported API version")
else:
    print(f"Other error: {status}")

API Reference

PooldoseClient

Constructor

PooldoseClient(host, timeout=10, include_sensitive_data=False)

Parameters:

  • host (str): The hostname or IP address of the device
  • timeout (int): Request timeout in seconds (default: 10)
  • include_sensitive_data (bool): Whether to include sensitive data like WiFi passwords (default: False)

Methods

  • connect() - Connect to device and initialize all components
  • static_values() - Get static device information
  • instant_values() - Get current sensor readings and device state
  • available_types() - Get all available entity types
  • available_sensors() - Get available sensor configurations
  • available_binary_sensors() - Get available binary sensor configurations
  • available_numbers() - Get available number configurations
  • available_switches() - Get available switch configurations
  • available_selects() - Get available select configurations

Properties

  • is_connected - Check if client is connected to device
  • device_info - Dictionary containing device information
  • host - Device hostname or IP address
  • timeout - Request timeout in seconds

InstantValues

Dictionary Interface

# Reading
value = instant_values["sensor_name"]
value = instant_values.get("sensor_name", default)
exists = "sensor_name" in instant_values

# Writing (async)
await instant_values.__setitem__("switch_name", True)

Type-specific Methods

# Getters
sensors = instant_values.get_sensors()
binary_sensors = instant_values.get_binary_sensors()
numbers = instant_values.get_numbers()
switches = instant_values.get_switches()
selects = instant_values.get_selects()

# Setters (async, with validation)
await instant_values.set_number("ph_target", 7.2)
await instant_values.set_switch("stop_dosing", True)
await instant_values.set_select("water_meter_unit", 1)

Supported Devices

This client has been tested with:

  • PoolDose Double/Dual WiFi (Model: PDPR1H1HAW100, FW: 539187)

Other SEKO PoolDose models may work but are untested. The client uses JSON mapping files to adapt to different device models and firmware versions (see e.g. src/pooldose/mappings/model_PDPR1H1HAW100_FW539187.json).

Note: The other JSON files in the docs/ directory define the default English names for the data keys of the PoolDose devices. These mappings are used for display and documentation purposes.

Security

By default, the client excludes sensitive information like WiFi passwords from device info. To include sensitive data:

client = PooldoseClient(
    host="192.168.1.100", 
    include_sensitive_data=True
)
status = await client.connect()

Changelog

[0.4.0] - 2025-07-11

  • BREAKING: Removed create() factory method
  • BREAKING: Changed client initialization pattern to separate __init__ and async connect() methods
  • Added is_connected property to check connection status
  • Improved flexibility for testing and connection management
  • Simplified RequestHandler by removing factory method pattern
  • Changed default timeout to 30s
  • Improved unit handling (No Unit is 'None')

[0.3.1] - 2025-07-04

  • First official release, published on PyPi
  • Install with pip install python-pooldose

[0.3.0] - 2025-07-02

  • BREAKING: Changed from dataclass properties to dictionary-based access for instant values
  • Added dynamic sensor discovery based on device mapping files
  • Added type-specific getter methods (get_sensors, get_switches, etc.)
  • Added type-specific setter methods with validation (set_number, set_switch, etc.)
  • Added dictionary-style access (getitem, setitem, get, contains)
  • Added configurable sensitive data handling (excludes WiFi passwords by default)
  • Improved async file loading to prevent event loop blocking
  • Enhanced error handling and logging
  • Added comprehensive type annotations

[0.2.0] - 2024-06-25

  • Added query feature to list all available sensors and actuators

[0.1.5] - 2024-06-24

  • First working prototype for PoolDose Double/Dual WiFi supported
  • All sensors and actuators for PoolDose Double/Dual WiFi supported

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_pooldose-0.4.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_pooldose-0.4.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file python_pooldose-0.4.0.tar.gz.

File metadata

  • Download URL: python_pooldose-0.4.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python_pooldose-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d4fd0c7b229701a5ab22fd04c2b66411536d81727b93e616f0b2b0bc1129affd
MD5 3a87531e99af3547476b14054ab3c317
BLAKE2b-256 1af1224622c4444a7f56a3e709e9efec8b491f8ea1b342575adedbfe01cd985e

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_pooldose-0.4.0.tar.gz:

Publisher: python-publish.yml on lmaertin/python-pooldose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_pooldose-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_pooldose-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68aede50fed5d59262569f9ca737abc5fcd84f6d2946b9895cfec8300329042d
MD5 10c9c4c9cd9724790cc9e34027dd809d
BLAKE2b-256 1bf2a32cc5cd8b8c9e8b601d7f206f8b6d2eae66c0bfab93d497f7a136b4d582

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_pooldose-0.4.0-py3-none-any.whl:

Publisher: python-publish.yml on lmaertin/python-pooldose

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page