duwi-open-sdk


Nameduwi-open-sdk JSON
Version 0.2.5 PyPI version JSON
download
home_pagehttps://github.com/duwi2024/homeassistant-sdk
Summarysdk for duwi third platform
upload_time2024-09-10 06:13:44
maintainerNone
docs_urlNone
authorledgerbiggg
requires_python>=3.7
licenseMIT
keywords python duwi sdk third platform
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
pip3 install duwi-open-sdk
```

### Example

#### Initialize the Manager

To initialize the manager, use the following code:

```python
from duwi_open_sdk.device_scene_models import CustomerDevice
from duwi_open_sdk import Manager

manager = Manager(
    _id="example_entry_id",
    customer_api=CustomerApi(
        address="http://example.com",
        ws_address="ws://example.com/ws",
        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:

```python
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:

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

## Release Note

| version | Description       |
|---------|-------------------|
| 0.2.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](./LICENSE) file for more info.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/duwi2024/homeassistant-sdk",
    "name": "duwi-open-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "python, duwi, sdk, third, platform",
    "author": "ledgerbiggg",
    "author_email": "duwitech@163.com",
    "download_url": "https://files.pythonhosted.org/packages/f4/e8/b05163fe0a47698e8c2c3450b4137039589fcdead60055e6374b5fb577a9/duwi_open_sdk-0.2.5.tar.gz",
    "platform": null,
    "description": "# Duwi Device Management SDK\r\n\r\nA 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.\r\n\r\n## Features\r\n\r\n### APIs\r\n\r\n- Manager.customerClient\r\n  - `login(phone: str, password: str) -> dict[str, Any] | None`\r\n  - `control(is_group: bool, body: Optional[ControlDevice]) -> dict[str, Any] | None`\r\n  - `discover() -> dict[str, Any]`\r\n  - `fetch_floor_info() -> dict[str, Any] | None`\r\n  - `fetch_house_info() -> dict[str, Any] | None`\r\n  - `discover_groups() -> dict[str, Any]`\r\n  - `refresh() -> dict[str, Any] | None`\r\n  - `fetch_room_info() -> dict[str, Any] | None`\r\n  - `control_scene(sceneNo: str) -> dict[str, Any] | None`\r\n  - `fetch_terminal_info() -> dict[str, Any] | None`\r\n  - `fetch_scene_info() -> dict[str, Any] | None`\r\n\r\n### Device Listeners\r\n\r\n- `SharingDeviceListener`: Interface for listening to device state changes.\r\n- `SharingTokenListener`: Interface for handling authentication token updates.\r\n\r\n## Possible Scenarios\r\n\r\n- Smart Home Integration\r\n- Automated Device Control\r\n- Real-time Device Monitoring\r\n\r\n## Usage\r\n\r\n### Installation\r\n\r\n```bash\r\npip3 install duwi-open-sdk\r\n```\r\n\r\n### Example\r\n\r\n#### Initialize the Manager\r\n\r\nTo initialize the manager, use the following code:\r\n\r\n```python\r\nfrom duwi_open_sdk.device_scene_models import CustomerDevice\r\nfrom duwi_open_sdk import Manager\r\n\r\nmanager = Manager(\r\n    _id=\"example_entry_id\",\r\n    customer_api=CustomerApi(\r\n        address=\"http://example.com\",\r\n        ws_address=\"ws://example.com/ws\",\r\n        app_key=\"your_app_key\",\r\n        app_secret=\"your_app_secret\",\r\n        house_no=\"your_house_no\",\r\n        house_name=\"Your House Name\",\r\n        access_token=\"your_access_token\",\r\n        refresh_token=\"your_refresh_token\",\r\n        client_version=\"1.0\",\r\n        client_model=\"Model XYZ\",\r\n        app_version=\"0.1.0\",\r\n    ),\r\n    house_key=\"your_house_key\",\r\n)\r\n\r\n# Execute login\r\nlogin_status = await manager.login(\"your_phone_number\", \"your_password\")\r\n```\r\n\r\n### Implementing Listeners\r\n\r\nTo listen to device status updates and handle token authentication, implement the listeners as follows:\r\n\r\n```python\r\nclass DeviceListener(SharingDeviceListener):\r\n    async def on_device_update(self, device_id: str, data: dict):\r\n        # Handle device update logic\r\n        pass\r\n\r\nclass TokenListener(SharingTokenListener):\r\n    async def on_token_refresh(self, new_token: str):\r\n        # Handle token refresh logic\r\n        pass\r\n    \r\n# Add the listeners to the manager\r\ndevice_listener = DeviceListener()\r\ntoken_listener = TokenListener()\r\n\r\nmanager.add_device_listener(device_listener)\r\n```\r\n\r\n### Accessing Device Information\r\n\r\nYou can access any device information through the manager:\r\n\r\n```python\r\ndevice_info = manager.device_map.get(\"your_device_id\")\r\n```\r\n\r\n## Release Note\r\n\r\n| version | Description       |\r\n|---------|-------------------|\r\n| 0.2.4   | Initial release    |\r\n\r\n## Issue Feedback\r\n\r\nYou can provide feedback on your issue via **Github Issue**.\r\n\r\n## License\r\n\r\n**duwi-device-management-sdk** is available under the MIT license. Please see the [LICENSE](./LICENSE) file for more info.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "sdk for duwi third platform",
    "version": "0.2.5",
    "project_urls": {
        "Homepage": "https://github.com/duwi2024/homeassistant-sdk"
    },
    "split_keywords": [
        "python",
        " duwi",
        " sdk",
        " third",
        " platform"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4e8b05163fe0a47698e8c2c3450b4137039589fcdead60055e6374b5fb577a9",
                "md5": "ffdbd99038782f509c5e2ce989567da6",
                "sha256": "d20ca8ce00a067a38520a6348e6e39cb4a945c6de3dcb41675012a82d98a0fb6"
            },
            "downloads": -1,
            "filename": "duwi_open_sdk-0.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "ffdbd99038782f509c5e2ce989567da6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 22295,
            "upload_time": "2024-09-10T06:13:44",
            "upload_time_iso_8601": "2024-09-10T06:13:44.324987Z",
            "url": "https://files.pythonhosted.org/packages/f4/e8/b05163fe0a47698e8c2c3450b4137039589fcdead60055e6374b5fb577a9/duwi_open_sdk-0.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-10 06:13:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "duwi2024",
    "github_project": "homeassistant-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "duwi-open-sdk"
}
        
Elapsed time: 0.36951s