|
| 1 | +# Comwatt Python Client |
| 2 | + |
| 3 | +## Overview |
| 4 | +The Comwatt Python Client is a Python library that provides a convenient way to interact with the Comwatt API. It allows you to authenticate users, retrieve authenticated user information, and access site and device data. |
| 5 | + |
| 6 | +## Features |
| 7 | +The client currently supports the following methods: |
| 8 | + |
| 9 | +- `authenticate(self, username, password)`: Authenticates a user with the provided username and password. |
| 10 | +- `get_authenticated_user(self)`: Retrieves information about the authenticated user. |
| 11 | +- `get_sites(self)`: Retrieves a list of sites associated with the authenticated user. |
| 12 | +- `get_devices(self, site_id)`: Retrieves a list of devices for the specified site. |
| 13 | + |
| 14 | +## Installation |
| 15 | +You can install the Comwatt Python Client using pip. Run the following command: |
| 16 | + |
| 17 | +``` |
| 18 | +pip install comwatt-client |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | +Here's a simple example of how to use the Comwatt Python Client: |
| 23 | + |
| 24 | +```python |
| 25 | +from comwatt.client import ComwattClient |
| 26 | + |
| 27 | +# Create a Comwatt client instance |
| 28 | +client = ComwattClient() |
| 29 | + |
| 30 | +# Authenticate the user |
| 31 | +# Password should be encrypted password, |
| 32 | +# I don't know exactly what the encryption is for the moment, |
| 33 | +# so you will need to encrypt it from their webapp |
| 34 | +client.authenticate('username', 'password') |
| 35 | + |
| 36 | +# Get information about the authenticated user |
| 37 | +user_info = client.get_authenticated_user() |
| 38 | +print(user_info) |
| 39 | + |
| 40 | +# Get a list of sites associated with the authenticated user |
| 41 | +sites = client.get_sites() |
| 42 | +print(sites) |
| 43 | + |
| 44 | +# Get a list of devices for a specific site |
| 45 | +devices = client.get_devices(sites[0]['id']) |
| 46 | +print(devices) |
| 47 | +``` |
| 48 | + |
| 49 | +Make sure to replace `'username'`, `'password'` with the actual values for your Comwatt account. |
| 50 | + |
| 51 | +## Contributing |
| 52 | +Contributions to the Comwatt Python Client are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository. |
0 commit comments