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.1.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.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: comwatt_client_legacy-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2d4dbd4ff8f1b986daebc43066bc7283a3bbf7d7e67ec26bd0e44daf7c990757
MD5 ae20734c53b038334df311e0490644a1
BLAKE2b-256 69505f7b64a3b27cd2823b3aa460fa1b3287661b883dca222f23b3879b73dbf4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for comwatt_client_legacy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7307e9651668c8f222b9b5fa63b5ccea1e1e7f4961db3284ac1231fdbfc7d10
MD5 2c9979b4f36b479c361ae451648bebe3
BLAKE2b-256 9186b7aa32d71b1da827ce4bf0a19cf27b6d9a484dbb44b417d0aaa25d240a63

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