comwatt-client 0.2__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,160 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.1
2
+ Name: comwatt-client
3
+ Version: 0.2.2
4
+ Summary: Python Client for Comwatt API
5
+ Home-page: https://github.com/MateoGreil/python-comwatt-client
6
+ Author: Matéo Greil
7
+ Author-email: contact@greil.fr
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.6
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: requests
17
+
18
+ # Comwatt Python Client
19
+
20
+ ## Overview
21
+ 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.
22
+
23
+ Please note that the Comwatt client is exclusively for gen4 devices: it use `energy.comwatt.com/api`. **Versions below gen4 will not be compatible**. If you're looking for the `go.comwatt.com/api` go to [python-comwatt-client-legacy](https://github.com/MateoGreil/python-comwatt-client-legacy).
24
+
25
+ ## Features
26
+ The client currently supports the following methods:
27
+
28
+ - `authenticate(self, username, password)`: Authenticates a user with the provided username and password.
29
+ - `get_authenticated_user(self)`: Retrieves information about the authenticated user.
30
+ - `get_sites(self)`: Retrieves a list of sites associated with the authenticated user.
31
+ - `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.
32
+ - `get_site_consumption_breakdown_time_ago(self, site_id, aggregation_level = "HOUR", time_ago_unit = "DAY", time_ago_value = 1)` Retrieves the consumption breakdown data for a specific site, based on the provided parameters.
33
+ - `get_devices(self, site_id)`: Retrieves a list of devices for the specified site.
34
+ - `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.
35
+ - `get_device(self, device_id)`: Retrieves information about a specific device.
36
+ - `put_device(self, device_id, payload)`: Updates a specific device with the provided payload.
37
+
38
+ ## Installation
39
+ You can install the Comwatt Python Client using pip. Run the following command:
40
+
41
+ ```
42
+ pip install comwatt-client
43
+ ```
44
+
45
+ ## Usage
46
+ Here's a simple example of how to use the Comwatt Python Client:
47
+
48
+ ```python
49
+ from comwatt.client import ComwattClient
50
+
51
+ # Create a Comwatt client instance
52
+ client = ComwattClient()
53
+
54
+ # Authenticate the user
55
+ client.authenticate('username', 'password')
56
+
57
+ # Get information about the authenticated user
58
+ user_info = client.get_authenticated_user()
59
+ print(user_info)
60
+
61
+ # Get a list of sites associated with the authenticated user
62
+ sites = client.get_sites()
63
+ print(sites)
64
+
65
+ # Get time series data for the networks of a specific site
66
+ networks_time_series_data = client.get_site_networks_ts_time_ago(sites[0]['id'])
67
+ print(networks_time_series_data)
68
+
69
+ # Get the consumption breakdown data for a specific site, based on the provided parameters.
70
+ consumption_breakdown_data = client.get_site_consumption_breakdown_time_ago(sites[0]['id'])
71
+ print(consumption_breakdown_data)
72
+
73
+ # Get a list of devices for a specific site
74
+ devices = client.get_devices(sites[0]['id'])
75
+ print(devices)
76
+
77
+ # Get time series data for a specific device
78
+ time_series_data = client.get_device_ts_time_ago(devices[0]['id'])
79
+ print(time_series_data)
80
+
81
+ # Set the control mode of a specific device to MANUL
82
+ device = client.get_device(devices[0]['id'])
83
+ device['configuration']['controlMode'] = 'MANUAL'
84
+ client.put_device(device['id'], device)
85
+
86
+ # Switch the POWER_SWITCH capacity
87
+ for feature in device['features']:
88
+ for capacity in feature['capacities']:
89
+ if capacity.get('capacity', {}).get('nature') == "POWER_SWITCH":
90
+ capacity_id = capacity['capacity']['id']
91
+ client.switch_capacity(capacity_id, False)
92
+ client.switch_capacity(capacity_id, True)
93
+
94
+ ```
95
+
96
+ Make sure to replace `'username'`, `'password'` with the actual values for your Comwatt account.
97
+
98
+ ## Contributing
99
+ 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.
@@ -2,7 +2,8 @@
2
2
 
3
3
  ## Overview
4
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
- Please note that the Comwatt client is exclusively for gen4 devices. Versions below gen4 will not be compatible.
5
+
6
+ Please note that the Comwatt client is exclusively for gen4 devices: it use `energy.comwatt.com/api`. **Versions below gen4 will not be compatible**. If you're looking for the `go.comwatt.com/api` go to [python-comwatt-client-legacy](https://github.com/MateoGreil/python-comwatt-client-legacy).
6
7
 
7
8
  ## Features
8
9
  The client currently supports the following methods:
@@ -64,6 +65,15 @@ print(time_series_data)
64
65
  device = client.get_device(devices[0]['id'])
65
66
  device['configuration']['controlMode'] = 'MANUAL'
66
67
  client.put_device(device['id'], device)
68
+
69
+ # Switch the POWER_SWITCH capacity
70
+ for feature in device['features']:
71
+ for capacity in feature['capacities']:
72
+ if capacity.get('capacity', {}).get('nature') == "POWER_SWITCH":
73
+ capacity_id = capacity['capacity']['id']
74
+ client.switch_capacity(capacity_id, False)
75
+ client.switch_capacity(capacity_id, True)
76
+
67
77
  ```
68
78
 
69
79
  Make sure to replace `'username'`, `'password'` with the actual values for your Comwatt account.
@@ -2,6 +2,8 @@ import requests
2
2
  import json
3
3
  import hashlib
4
4
 
5
+ # from deprecated import deprecated
6
+
5
7
  class ComwattClient:
6
8
  """
7
9
  A client for interacting with the Comwatt API.
@@ -227,6 +229,7 @@ class ComwattClient:
227
229
  raise Exception(f'Error retrieving sites: {response.status_code}')
228
230
 
229
231
 
232
+ # @deprecated
230
233
  def get_device_ts_time_ago(self, device_id,
231
234
  measure_kind = "FLOW",
232
235
  aggregation_level = "HOUR",
@@ -265,3 +268,23 @@ class ComwattClient:
265
268
  return response.json()
266
269
  else:
267
270
  raise Exception(f'Error retrieving aggregations: {response.status_code}')
271
+
272
+ def switch_capacity(self, capacity_id, enable):
273
+ """
274
+ Switch a specific capcaity to the enable value.
275
+
276
+ Args:
277
+ capacity_id (str): The ID of the capacity.
278
+ enable (bool): The target state.
279
+
280
+ Returns:
281
+ dict: A dictionary containing the response from the API.
282
+
283
+ """
284
+ url = f'{self.base_url}/capacities/{capacity_id}/switch?enable={enable}'
285
+
286
+ response = self.session.put(url)
287
+ if response.status_code == 200:
288
+ return response.json()
289
+ else:
290
+ raise Exception(f'Error retrieving sites: {response.status_code}')
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.1
2
+ Name: comwatt-client
3
+ Version: 0.2.2
4
+ Summary: Python Client for Comwatt API
5
+ Home-page: https://github.com/MateoGreil/python-comwatt-client
6
+ Author: Matéo Greil
7
+ Author-email: contact@greil.fr
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.6
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: requests
17
+
18
+ # Comwatt Python Client
19
+
20
+ ## Overview
21
+ 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.
22
+
23
+ Please note that the Comwatt client is exclusively for gen4 devices: it use `energy.comwatt.com/api`. **Versions below gen4 will not be compatible**. If you're looking for the `go.comwatt.com/api` go to [python-comwatt-client-legacy](https://github.com/MateoGreil/python-comwatt-client-legacy).
24
+
25
+ ## Features
26
+ The client currently supports the following methods:
27
+
28
+ - `authenticate(self, username, password)`: Authenticates a user with the provided username and password.
29
+ - `get_authenticated_user(self)`: Retrieves information about the authenticated user.
30
+ - `get_sites(self)`: Retrieves a list of sites associated with the authenticated user.
31
+ - `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.
32
+ - `get_site_consumption_breakdown_time_ago(self, site_id, aggregation_level = "HOUR", time_ago_unit = "DAY", time_ago_value = 1)` Retrieves the consumption breakdown data for a specific site, based on the provided parameters.
33
+ - `get_devices(self, site_id)`: Retrieves a list of devices for the specified site.
34
+ - `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.
35
+ - `get_device(self, device_id)`: Retrieves information about a specific device.
36
+ - `put_device(self, device_id, payload)`: Updates a specific device with the provided payload.
37
+
38
+ ## Installation
39
+ You can install the Comwatt Python Client using pip. Run the following command:
40
+
41
+ ```
42
+ pip install comwatt-client
43
+ ```
44
+
45
+ ## Usage
46
+ Here's a simple example of how to use the Comwatt Python Client:
47
+
48
+ ```python
49
+ from comwatt.client import ComwattClient
50
+
51
+ # Create a Comwatt client instance
52
+ client = ComwattClient()
53
+
54
+ # Authenticate the user
55
+ client.authenticate('username', 'password')
56
+
57
+ # Get information about the authenticated user
58
+ user_info = client.get_authenticated_user()
59
+ print(user_info)
60
+
61
+ # Get a list of sites associated with the authenticated user
62
+ sites = client.get_sites()
63
+ print(sites)
64
+
65
+ # Get time series data for the networks of a specific site
66
+ networks_time_series_data = client.get_site_networks_ts_time_ago(sites[0]['id'])
67
+ print(networks_time_series_data)
68
+
69
+ # Get the consumption breakdown data for a specific site, based on the provided parameters.
70
+ consumption_breakdown_data = client.get_site_consumption_breakdown_time_ago(sites[0]['id'])
71
+ print(consumption_breakdown_data)
72
+
73
+ # Get a list of devices for a specific site
74
+ devices = client.get_devices(sites[0]['id'])
75
+ print(devices)
76
+
77
+ # Get time series data for a specific device
78
+ time_series_data = client.get_device_ts_time_ago(devices[0]['id'])
79
+ print(time_series_data)
80
+
81
+ # Set the control mode of a specific device to MANUL
82
+ device = client.get_device(devices[0]['id'])
83
+ device['configuration']['controlMode'] = 'MANUAL'
84
+ client.put_device(device['id'], device)
85
+
86
+ # Switch the POWER_SWITCH capacity
87
+ for feature in device['features']:
88
+ for capacity in feature['capacities']:
89
+ if capacity.get('capacity', {}).get('nature') == "POWER_SWITCH":
90
+ capacity_id = capacity['capacity']['id']
91
+ client.switch_capacity(capacity_id, False)
92
+ client.switch_capacity(capacity_id, True)
93
+
94
+ ```
95
+
96
+ Make sure to replace `'username'`, `'password'` with the actual values for your Comwatt account.
97
+
98
+ ## Contributing
99
+ 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.
@@ -1,4 +1,6 @@
1
+ .gitignore
1
2
  README.md
3
+ requirements.txt
2
4
  setup.py
3
5
  comwatt_client/__init__.py
4
6
  comwatt_client/client.py
@@ -0,0 +1,2 @@
1
+ requests==2.31.0
2
+ deprecated==1.2.15
@@ -1,11 +1,17 @@
1
1
  from setuptools import setup, find_packages
2
2
 
3
+ with open("README.md", 'r') as f:
4
+ long_description = f.read()
5
+
3
6
  setup(
4
7
  name='comwatt-client',
5
- version='0.2',
8
+ version='0.2.2',
6
9
  author='Matéo Greil',
7
10
  author_email='contact@greil.fr',
8
11
  description='Python Client for Comwatt API',
12
+ long_description=long_description,
13
+ long_description_content_type='text/markdown',
14
+ url="https://github.com/MateoGreil/python-comwatt-client",
9
15
  packages=find_packages(),
10
16
  install_requires=[
11
17
  'requests',
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: comwatt-client
3
- Version: 0.2
4
- Summary: Python Client for Comwatt API
5
- Author: Matéo Greil
6
- Author-email: contact@greil.fr
7
- Classifier: Development Status :: 3 - Alpha
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.6
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Requires-Dist: requests
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: comwatt-client
3
- Version: 0.2
4
- Summary: Python Client for Comwatt API
5
- Author: Matéo Greil
6
- Author-email: contact@greil.fr
7
- Classifier: Development Status :: 3 - Alpha
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.6
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Requires-Dist: requests
File without changes