Skip to main content

Python Client for Comwatt API (legacy: go.energy.comwatt)

Project description

Comwatt Python Client (Legacy)

Overview

The Comwatt Python Client (Legacy) is a Python library that provides a convenient way to interact with the legacy Comwatt API (go.comwatt.com/api). It allows you to authenticate users, retrieve authenticated user information, and access owner, box, product, device, and statistical data.

Please note that this client is intended for devices below gen4 and uses the deprecated go.comwatt.com. If you're looking for the client compatible with gen4 devices and the energy.comwatt.com, please refer to the python-comwatt-client.

Features

The client currently supports the following methods:

  • authenticate(self, username, password): Authenticates a user with the provided username and password.
  • get_authenticated_user(self): Retrieves information about the authenticated user.
  • get_owner_details(self, owner_id): Retrieves information about the owner's details.
  • get_box_details(self, macAddress): Retrieves information about the box's details.
  • get_products(self): Retrieves information about the products.
  • get_devices(self, indepbox_id): Retrieves a list of devices for the specified box.
  • get_networkstats(self, indepbox_id, level="HOUR", measure_kind="QUANTITY", start=datetime.now(), end=datetime.now()): Retrieves a list of network statistics for the specified box.
  • get_devices_stats(self, device_id, measure_kind="QUANTITY", measure_type_id="1", level="HOUR", start=datetime.now(), end=datetime.now()): Retrieves a list of device statistics for the specified device.

Installation

You can install the Comwatt Python Client (Legacy) using pip. Run the following command:

pip install comwatt-client-legacy

Usage

Here's a simple example of how to use the Comwatt Python Client (Legacy):

from comwatt.client import ComwattClient
from datetime import datetime, timedelta

# Create a Comwatt client instance
client = ComwattClient()

# Authenticate the user
client.authenticate('username', 'password')

# Get information about the authenticated user
user_info = client.get_authenticated_user()
print(user_info)

# Get owner details
owner_id = user_info['id']
owner_details = client.get_owner_details(owner_id)
print(owner_details)

# Get box details
macAddress = owner_details[0]['macAddress']
box_details = client.get_box_details(macAddress)
print(box_details)

# Get products
products = client.get_products()
print(products)

# Get devices for a specific box
indepbox_id = box_details['id']
devices = client.get_devices(indepbox_id)
print(devices)

# Get network statistics for a specific box
start_date = datetime.now() - timedelta(days=7)
end_date = datetime.now()
networkstats = client.get_networkstats(indepbox_id, start=start_date, end=end_date)
print(networkstats)

# Get device statistics for a specific device
device_id = devices[0]['id']
devices_stats = client.get_devices_stats(device_id, start=start_date, end=end_date)
print(devices_stats)

Make sure to replace 'username' and 'password' with the actual values for your Comwatt account.

Contributing

Contributions to the Comwatt Python Client (Legacy) 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.

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

comwatt_client_legacy-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comwatt_client_legacy-0.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file comwatt_client_legacy-0.1.2.tar.gz.

File metadata

  • Download URL: comwatt_client_legacy-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for comwatt_client_legacy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e32da41ca19d291e4a35d6764ea0354d0064a9d4182320b9af0417035ffe95c4
MD5 536bbc6175f95b8cdeba6146cf99c3f0
BLAKE2b-256 6fcc4a5a69c188c4190275ce863ba5981ff116a42e93176093ba4470680dd20d

See more details on using hashes here.

File details

Details for the file comwatt_client_legacy-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for comwatt_client_legacy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 176314aeda595814e72108eed5152b90fcf6cbab7e959c47ee4614a3dc36b36e
MD5 854bb231cd9b1405ab24ae723078b6fc
BLAKE2b-256 cd1127f510d1cb32f0247d5389db7c0dc28f11341f40d336efaa3fcba7781910

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page