Skip to content

Commit bd9136b

Browse files
committed
🚨 Fix lint
1 parent 3ba168c commit bd9136b

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

comwatt/client.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ def __init__(self):
66
self.base_url = 'https://energy.comwatt.com/api'
77
self.session = requests.Session()
88

9-
# Password should be encrypted password, I don't know exactly what the encryption is for the moment,
10-
# so you will need to encrypt it from their webapp
9+
# Password should be encrypted password, I don't know exactly what the encryption is for the
10+
# moment, so you will need to encrypt it from their webapp
1111
def authenticate(self, username, password):
1212
url = f'{self.base_url}/v1/authent'
1313
data = {'username': username, 'password': password}
1414

1515
response = self.session.post(url, json=data)
1616

1717
if response.status_code != 200:
18-
raise Exception(f'Authentication failed: {response.status_code}')
18+
raise Exception(f'Authentication failed: {response.status_code}')
1919

2020
def get_authenticated_user(self):
2121
url = f'{self.base_url}/users/authenticated'
@@ -44,17 +44,35 @@ def get_devices(self, site_id):
4444
else:
4545
raise Exception(f'Error retrieving sites: {response.sttaus_code}')
4646

47-
def 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"):
48-
url = f'{self.base_url}/aggregations/device-ts-time-ago?deviceId={device_id}&measureKind={measure_kind}&aggregationLevel={aggregation_level}&aggregationType={aggregation_type}&timeAgoUnit={time_ago_unit}&timeAgoValue={time_ago_value}'
47+
def get_device_ts_time_ago(self, device_id, measure_kind = "FLOW", aggregation_level = "HOUR",
48+
aggregation_type = "MAX", time_ago_unit = "DAY", time_ago_value = "1"):
49+
url = (f'{self.base_url}/aggregations/device-ts-time-ago?'
50+
f'deviceId={device_id}&'
51+
f'measureKind={measure_kind}&'
52+
f'aggregationLevel={aggregation_level}&'
53+
f'aggregationType={aggregation_type}&'
54+
f'timeAgoUnit={time_ago_unit}&'
55+
f'timeAgoValue={time_ago_value}')
4956

5057
response = self.session.get(url)
5158
if response.status_code == 200:
5259
return response.json()
5360
else:
5461
raise Exception(f'Error retrieving aggregations: {response.status_code}')
5562

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}'
63+
def get_site_networks_ts_time_ago(self, site_id,
64+
measure_kind = "VIRTUAL_QUANTITY",
65+
aggregation_level = "HOUR",
66+
aggregation_type = "SUM",
67+
time_ago_unit = "DAY",
68+
time_ago_value = 1):
69+
url = (f'{self.base_url}/aggregations/site-networks-ts-time-ago?'
70+
f'siteId={site_id}&'
71+
f'measureKind={measure_kind}&'
72+
f'aggregationLevel={aggregation_level}&'
73+
f'aggregationType={aggregation_type}&'
74+
f'timeAgoUnit={time_ago_unit}&'
75+
f'timeAgoValue={time_ago_value}')
5876

5977
response = self.session.get(url)
6078
if response.status_code == 200:

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
setup(
44
name='comwatt-client',
5-
version='0.0.1'
6-
author='Matéo Greil'
7-
author_email='contact@greil.fr'
8-
description='Python Client for Comwatt API'
5+
version='0.0.1',
6+
author='Matéo Greil',
7+
author_email='contact@greil.fr',
8+
description='Python Client for Comwatt API',
99
packages=find_packages(),
1010
install_requires=[
1111
'requests',

0 commit comments

Comments
 (0)