Skip to content

Commit 3ba168c

Browse files
committed
✨ Add site timeseries
1 parent bac1382 commit 3ba168c

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The client currently supports the following methods:
99
- `authenticate(self, username, password)`: Authenticates a user with the provided username and password.
1010
- `get_authenticated_user(self)`: Retrieves information about the authenticated user.
1111
- `get_sites(self)`: Retrieves a list of sites associated with the authenticated user.
12+
- `get_site_networks_ts_time_ago(self, site_id, measure_kind = "VIRTUAL_QUANTITY", aggregation_level = "HOUR", aggregation_type = "SUM", time_ago_unit = "DAY", time_ago_value = 1)`: Retrieves the time series data for the networks of a specific site, based on the provided parameters.
1213
- `get_devices(self, site_id)`: Retrieves a list of devices for the specified site.
1314
- `get_device_ts_time_ago(self, device_id, measure_kind = "FLOW", aggregation_level = "HOUR", aggregation_type = "MAX", time_ago_unit = "DAY", time_ago_value = "1")`: Retrieves the time series data for a specific device, based on the provided parameters.
1415

@@ -42,6 +43,10 @@ print(user_info)
4243
sites = client.get_sites()
4344
print(sites)
4445

46+
# Get time series data for the networks of a specific site
47+
networks_time_series_data = client.get_site_networks_ts_time_ago(sites[0]['id'])
48+
print(networks_time_series_data)
49+
4550
# Get a list of devices for a specific site
4651
devices = client.get_devices(sites[0]['id'])
4752
print(devices)

comwatt/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,12 @@ def get_device_ts_time_ago(self, device_id, measure_kind = "FLOW", aggregation_l
5252
return response.json()
5353
else:
5454
raise Exception(f'Error retrieving aggregations: {response.status_code}')
55+
56+
def get_site_networks_ts_time_ago(self, site_id, measure_kind = "VIRTUAL_QUANTITY", aggregation_level = "HOUR", aggregation_type = "SUM", time_ago_unit = "DAY", time_ago_value = 1):
57+
url = f'{self.base_url}/aggregations/site-networks-ts-time-ago?siteId={site_id}&measureKind={measure_kind}&aggregationLevel={aggregation_level}&aggregationType={aggregation_type}&timeAgoUnit={time_ago_unit}&timeAgoValue={time_ago_value}'
58+
59+
response = self.session.get(url)
60+
if response.status_code == 200:
61+
return response.json()
62+
else:
63+
raise Exception(f'Error retrieving aggregations: {response.status_code}')

0 commit comments

Comments
 (0)