Uhomepy is a simple Python API wrapper for the U home OpenAPI. This library provides an abstract base class UhomeOpenAPI to interact with the Uhome API. It includes methods to authenticate and make requests to the API, such as discovering, querying, locking, and unlocking devices.
To use the Uhome API, you will need a client_id, a client_secret, and a RedirectURI.
Tip
Install and set up the U home app before starting the following steps.
- Contact U-tec Customer Service to request a Developer Account. Once your Developer Account is set up, the Developer Console menu option will appear in your U home app.
- In the Developer Console, note the
client_idandclient_secret. - In the Developer Console, add a
RedirectUri. For thedump_devicesexample included in this project, use any non-public URI (e.g., https://localhost:8080).
To use the UhomeOpenAPI, you need to create a concrete implementation of the abstract class which implements the async_get_access_token method.
An example script dump_devices.py is provided in the examples directory. This script demonstrates how to use the Uhome API to authenticate a user, retrieve an access token, and dump the list of devices associated with the user.
To run the example script, use the following command:
python examples/dump_devices.pyWhen running the example script, you will need to authenticate and approve access. You will be redirected to the RedirectUri, which will not load. However, you only need to copy the URI from the address bar of your browser for the final step of the script.
The U home OpenAPI supports SmartLock, SmartPlug, SmartSwitch and Light devices. This library will discover all of these devices types but only supports interacting with SmartLocks.