Skip to main content

Provider-based Dreo SDK with cloud support and local extension points.

Project description

pydreo-client

pydreo-client is now a provider-based Dreo SDK. The package still supports the original cloud-only usage, but the internal architecture has been rebuilt so we can add a real local module without duplicating client, device, and routing logic.

What Changed in v2

  • Added a formal pydreo/ package with clear core, cloud, and local boundaries.
  • Introduced a unified DreoClient facade that can orchestrate multiple providers.
  • Migrated cloud access into a CloudProvider with separate auth and HTTP transport layers.
  • Added a usable LocalProvider shell with config, discovery, protocol, and transport extension points.
  • Preserved the cloud compatibility import path: from pydreo.cloud.client import DreoClient.

Package Layout

pydreo/
  client.py            # Unified facade
  core/                # Shared models, strategy, registry, exceptions
  cloud/               # Cloud provider implementation
  local/               # Local provider shell and extension points

Installation

pip install pydreo-client

Usage

Cloud Only, Backward Compatible

from pydreo.cloud.client import DreoClient

client = DreoClient("USERNAME", "PASSWORD")
client.login()

devices = client.get_devices()
status = client.get_status("DEVICE_SN")
client.update_status("DEVICE_SN", power="on")

Unified Facade with Future Local Support

from pydreo import CloudConfig, ConnectionStrategy, DreoClient, LocalConfig

client = DreoClient(
    cloud_config=CloudConfig(username="USERNAME", password="PASSWORD"),
    local_config=LocalConfig(),
    strategy=ConnectionStrategy.LOCAL_PREFERRED,
)

devices = client.discover_devices()
state = client.get_device_state("DEVICE_SN")
result = client.set_device_state("DEVICE_SN", power="on")

Injecting a Local Transport During Development

from pydreo import DreoLocalClient, LocalConfig, LocalHostConfig
from pydreo.local.transport import InMemoryLocalTransport

client = DreoLocalClient(
    config=LocalConfig(
        known_hosts=(
            LocalHostConfig(host="192.168.1.20", serial_number="LOCAL-001", name="Desk Fan"),
        ),
    ),
    transport=InMemoryLocalTransport({"LOCAL-001": {"power": "on", "speed": 2}}),
)

devices = client.discover_devices()
state = client.get_device_state("LOCAL-001")

Extending the Local Module

The new local stack is deliberately composable:

  • LocalDiscoveryBackend is where LAN discovery or manual device seeding should live.
  • LocalTransport is where socket or protocol I/O should live.
  • LocalProtocolAdapter is where payload translation should live.
  • LocalProvider wires those pieces together and exposes the same contract as cloud.

That means the next local implementation can focus on protocol specifics without changing the public client surface again.

Development

Run the built-in unit tests with:

python3 -m unittest discover -s tests -v

License

Distributed under the MIT License. See LICENSE for more information.

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

pydreo_client-2.0.0.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

pydreo_client-2.0.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file pydreo_client-2.0.0.tar.gz.

File metadata

  • Download URL: pydreo_client-2.0.0.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pydreo_client-2.0.0.tar.gz
Algorithm Hash digest
SHA256 613ca6932b7c417f0dc11faf40bfa0ed79b5928d6dc21d9e0f27283dff888944
MD5 335b60dbde1326bdc6e550171c58c127
BLAKE2b-256 0da487aea1672935084a4ef18e86cd7edf8b7c7045d1c0a5907c9062327eca3f

See more details on using hashes here.

File details

Details for the file pydreo_client-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydreo_client-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for pydreo_client-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61b1ce3a07ac4fd36b96b77731bb888cde1239d941b05b40f306fb2f974940c8
MD5 ea95a51d76c44390b5c466e89bbf7406
BLAKE2b-256 c69acbc273518a9b0eea207241d2f040aea502dd2a07e41fc3181646e9b4884f

See more details on using hashes here.

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