Skip to main content

Duwi Device Management SDK

A Python SDK for Duwi Open API, which provides basic IoT capabilities like device management capabilities, helping you create IoT solutions. The Duwi IoT Development Platform opens basic IoT capabilities such as device management and data analytics services, helping you build robust IoT applications.

Features

APIs

  • Manager.customerClient
    • login(phone: str, password: str) -> dict[str, Any] | None
    • control(is_group: bool, body: Optional[ControlDevice]) -> dict[str, Any] | None
    • discover() -> dict[str, Any]
    • fetch_floor_info() -> dict[str, Any] | None
    • fetch_house_info() -> dict[str, Any] | None
    • discover_groups() -> dict[str, Any]
    • refresh() -> dict[str, Any] | None
    • fetch_room_info() -> dict[str, Any] | None
    • control_scene(sceneNo: str) -> dict[str, Any] | None
    • fetch_terminal_info() -> dict[str, Any] | None
    • fetch_scene_info() -> dict[str, Any] | None

Device Listeners

  • SharingDeviceListener: Interface for listening to device state changes.
  • SharingTokenListener: Interface for handling authentication token updates.

Possible Scenarios

  • Smart Home Integration
  • Automated Device Control
  • Real-time Device Monitoring

Usage

Installation

pip3 install duwi-open-sdk

Example

Initialize the Manager

To initialize the manager, use the following code:

from duwi_smarthome_sdk.device_scene_models import CustomerDevice
from duwi_smarthome_sdk import Manager

manager = Manager(
    _id="example_entry_id",
    customer_api=CustomerApi(
        address=HTTP_ADDRESS,
        ws_address=WEBSOCKET_ADDRESS,
        app_key="your_app_key",
        app_secret="your_app_secret",
        house_no="your_house_no",
        house_name="Your House Name",
        access_token="your_access_token",
        refresh_token="your_refresh_token",
        client_version="1.0",
        client_model="Model XYZ",
        app_version="0.1.0",
    ),
    house_key="your_house_key",
)

# Execute login
login_status = await manager.login("your_phone_number", "your_password")

Implementing Listeners

To listen to device status updates and handle token authentication, implement the listeners as follows:

class DeviceListener(SharingDeviceListener):
    async def on_device_update(self, device_id: str, data: dict):
        # Handle device update logic
        pass

class TokenListener(SharingTokenListener):
    async def on_token_refresh(self, new_token: str):
        # Handle token refresh logic
        pass
    
# Add the listeners to the manager
device_listener = DeviceListener()
token_listener = TokenListener()

manager.add_device_listener(device_listener)

Accessing Device Information

You can access any device information through the manager:

device_info = manager.device_map.get("your_device_id")

Release Note

version Description
0.7.4 Initial release

Issue Feedback

You can provide feedback on your issue via Github Issue.

License

duwi-device-management-sdk is available under the MIT license. Please see the LICENSE file for more info.

Download files

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

Source Distribution

duwi-smarthome-sdk-0.7.8.tar.gz (21.6 kB view details)

Uploaded Source

File details

Details for the file duwi-smarthome-sdk-0.7.8.tar.gz.

File metadata

  • Download URL: duwi-smarthome-sdk-0.7.8.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for duwi-smarthome-sdk-0.7.8.tar.gz
Algorithm Hash digest
SHA256 5af479c1661d2b155aba82b3b18f6d480b5d15b0650a75d2a8afbdcb63fbca83
MD5 a124a1f23cc135c0f5948a16dfd49009
BLAKE2b-256 a1789d5472da5c07f15ca413cf5b7d6c4ca01d39cb63dc2d6faa1473a80e327d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.8 This release

1 file

0.7.6

1 file

0.7.5

1 file

0.7.4

1 file

0.7.3

1 file

0.7.2

1 file

0.7.1

1 file

0.7.0

1 file

0.6.8

1 file

0.6.6

1 file

0.6.5

1 file

0.6.4

1 file

0.6.3

1 file

0.6.2

1 file

0.5.1

1 file

0.5.0

1 file

0.4.9

1 file

0.4.8

1 file

0.4.7

1 file

0.4.6

1 file

0.4.5

1 file

0.4.4

1 file

0.4.3

1 file

0.4.2

1 file

0.4.1

1 file

0.3.9

1 file

0.3.8

1 file

0.3.7

1 file

0.3.6

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3.0

1 file

0.2.9

1 file

0.2.8

1 file

0.2.7

1 file

0.2.6

1 file

0.2.5

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2.0

1 file

0.1.9

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

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