An SDK to interact with the AladdinConnect (or OHD) partner API
Project description
AladdinConnect SDK
Authentication
OAuth Client
This SDK requires you to already have an OAuth client setup with us. The initial OAuth2.0 flow must be implemented by the users of this library as we provide no default implementation. More information on how to set this up will be provided when the OAuth client is set up.
Auth Class Implementation
The SDK provides an Auth
class. It requires the following constructor parameters:
websession
: anaiohttp.ClientSession
that will be used for requestshost
: the partner-specific base URL for the APIaccess_token
: an initial access token to use (either cached or retrieved via the login flow)api_key
: a partner-specific API key provided during initial onboarding
This class also provides an abstract method async_get_access_token
.
This method is meant to be overridden with logic to handle checking the
current token's validity and refreshing if needed. The refresh token will
need to be managed outside of this class. Once this is implemented, the
request
method will automatically check the access token and set the
appropriate authentication headers.
Model
Each garage door is modeled using the GarageDoor
class that has the following
properties:
device_id
: a unique ID for the device (that could have multiple doors)door_number
: the index of the door, can be 1, 2 or 3unique_id
: a unique ID for the door of the format{DEVICE_ID}-{DOOR_NUMBER}
name
: a user defined name for the doorstatus
: the current state of the door, one of:open
: door is openclosed
: door is closedopening
: door is in the process of being openedclosing
: door is in the process of being closedunknown
: device has been recently setup or reset, requires a user to locally cycle the door open / closed to get the correct state
link_status
: whether or not the door sensor is properly paired. Can be one of:not_config
: not yet configured, must use the app to pairpaired
: configured, but not yet connectedconnected
: fully functional
battery_level
: the current battery percentage (0 - 100) of the door sensor
Client
The AladdinConnectClient
class provides the actual functionality of the API. It
requires an Auth
session to be configured (described above in the Authentication section).
This class provides the following methods:
get_doors
: Sync all the user's devices. This returns a list ofGarageDoor
instances as well as updating its own internal stateupdate_door
: Sync a specific door and update the internal stateopen_door
: Issue an open commandopen_door
: Issue a close commandget_door_status
: Return the current state of a door (this uses the internal state, it does not make a call to the API. To sync the state of a door, useupdate_door
and then call this to get its status).get_battery_status
: Get the battery status of a door (this uses the internal state, it does not make a call to the API. To sync the state of a door, useupdate_door
and then call this to get the battery status)
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
Built Distribution
File details
Details for the file genie_partner_sdk-1.0.4.tar.gz
.
File metadata
- Download URL: genie_partner_sdk-1.0.4.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f06c87b5a6ad58280037851961602549f71b6f7f1be8a8b2e30d24227142aec |
|
MD5 | 9e8b1282991f8ac383b2267f8bd9fbc7 |
|
BLAKE2b-256 | 259222c1ce4b4d18aabc1a661cdb2cafc77e8781bb140be69d48cc1499a652fc |
File details
Details for the file genie_partner_sdk-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: genie_partner_sdk-1.0.4-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 246a415b297f05998f807dd34fec55211c15cc86abfcceb08e726209f773fcc6 |
|
MD5 | f8faa7574fb9052fc80e374fd610fa90 |
|
BLAKE2b-256 | 976e264bf0c38d2e091a72f49465a2e7311ec2d09c06c50c24d53fea7c7fc5bd |