leneda-client 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl

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.
leneda/client.py CHANGED
@@ -12,7 +12,7 @@ from typing import Any, Dict, List, Optional, Union
12
12
 
13
13
  import requests
14
14
 
15
- from .exceptions import ForbiddenException, InvalidMeteringPointException, UnauthorizedException
15
+ from .exceptions import ForbiddenException, UnauthorizedException
16
16
  from .models import (
17
17
  AggregatedMeteringData,
18
18
  MeteringData,
@@ -250,19 +250,24 @@ class LenedaClient:
250
250
 
251
251
  return response_data
252
252
 
253
- def test_metering_point(self, metering_point_code: str) -> bool:
253
+ def probe_metering_point_obis_code(self, metering_point_code: str, obis_code: ObisCode) -> bool:
254
254
  """
255
- Test if a metering point code is valid and accessible.
255
+ Probe if a metering point provides data for a specific OBIS code.
256
256
 
257
- This method checks if a metering point code is valid by making a request
258
- for aggregated metering data. If the unit property in the response is null,
259
- it indicates that the metering point is invalid or not accessible.
257
+ NOTE: This method is essentially a best guess since the Leneda API does not provide a way to check
258
+ if a metering point provides data for a specific OBIS code or whether a metering point code is valid
259
+
260
+ This method checks if a metering point provides data for the specified OBIS code by making a request
261
+ for aggregated metering data. If the unit property in the response is null, it indicates that either:
262
+ - The metering point is invalid, or
263
+ - The metering point does not provide data for the specified OBIS code
260
264
 
261
265
  Args:
262
- metering_point_code: The metering point code to test
266
+ metering_point_code: The metering point code to probe
267
+ obis_code: The OBIS code to check for data availability
263
268
 
264
269
  Returns:
265
- bool: True if the metering point is valid and accessible, False otherwise
270
+ bool: True if the metering point provides data for the specified OBIS code, False otherwise
266
271
 
267
272
  Raises:
268
273
  UnauthorizedException: If the API returns a 401 status code
@@ -273,20 +278,43 @@ class LenedaClient:
273
278
  end_date = datetime.now()
274
279
  start_date = end_date - timedelta(weeks=4)
275
280
 
276
- # Try to get aggregated data for electricity consumption
281
+ # Try to get aggregated data for the specified OBIS code
277
282
  result = self.get_aggregated_metering_data(
278
283
  metering_point_code=metering_point_code,
279
- obis_code=ObisCode.ELEC_CONSUMPTION_ACTIVE,
284
+ obis_code=obis_code,
280
285
  start_date=start_date,
281
286
  end_date=end_date,
282
287
  aggregation_level="Month",
283
288
  transformation_mode="Accumulation",
284
289
  )
285
290
 
286
- # If we get here and the unit is None, the metering point is invalid
287
- if result.unit is None:
288
- raise InvalidMeteringPointException(
289
- f"Metering point {metering_point_code} is invalid or not accessible"
290
- )
291
+ # Return True if we got data (unit is not None), False otherwise
292
+ return result.unit is not None
293
+
294
+ def get_supported_obis_codes(self, metering_point_code: str) -> List[ObisCode]:
295
+ """
296
+ Get all OBIS codes that are supported by a given metering point.
297
+
298
+ NOTE: Please see the documentation of the probe_metering_point_obis_code method about best guess
299
+ behaviour. If this method returns an empty list, chances are high that the metering point code
300
+ is invalid or that the Energy ID has no access to it.
301
+
302
+ This method probes each OBIS code defined in the ObisCode enum to determine
303
+ which ones are supported by the specified metering point.
304
+
305
+ Args:
306
+ metering_point_code: The metering point code to check
291
307
 
292
- return True
308
+ Returns:
309
+ List[ObisCode]: A list of OBIS codes that are supported by the metering point
310
+
311
+ Raises:
312
+ UnauthorizedException: If the API returns a 401 status code
313
+ ForbiddenException: If the API returns a 403 status code
314
+ requests.exceptions.RequestException: For other request errors
315
+ """
316
+ return [
317
+ obis_code
318
+ for obis_code in ObisCode
319
+ if self.probe_metering_point_obis_code(metering_point_code, obis_code)
320
+ ]
leneda/exceptions.py CHANGED
@@ -19,9 +19,3 @@ class ForbiddenException(LenedaException):
19
19
  """Raised when access is forbidden (403 Forbidden), typically due to geoblocking or other access restrictions."""
20
20
 
21
21
  pass
22
-
23
-
24
- class InvalidMeteringPointException(LenedaException):
25
- """Raised when a metering point code is invalid or not accessible."""
26
-
27
- pass
leneda/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Version information."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.4.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: leneda-client
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Python client for the Leneda energy data platform
5
5
  Home-page: https://github.com/fedus/leneda-client
6
6
  Author: fedus
@@ -0,0 +1,11 @@
1
+ leneda/__init__.py,sha256=-BHIXBfTTbX6EKDHr2Bq7rPzsPNYrrkgs9AJqWJR_1Q,732
2
+ leneda/client.py,sha256=RcANz6UweQ13fJHKwWP1V5dWnqSwcG4Ot9ws1grhZqQ,12250
3
+ leneda/exceptions.py,sha256=q00gjI5VwXAMF2I1gXfQidZMzbCF6UOSo4i1Wnb-inU,460
4
+ leneda/models.py,sha256=jdU2cIZZDExUSiSfz9zaYjJepr0m3v_x5b1fyOaEI8Q,7930
5
+ leneda/obis_codes.py,sha256=VfsJQN1U80eZ5g1bIteDCLkkmBQ0AIkkm_zNAeM1Dog,7507
6
+ leneda/version.py,sha256=e6aGg4sxTYiyshAbW98gDoekO-J6qYKpZNzhVZhaYUk,50
7
+ leneda_client-0.4.0.dist-info/licenses/LICENSE,sha256=nAhDs625lK6v8oLqjWCABKBKlwxVoRDFXQvoZPfOtKQ,1062
8
+ leneda_client-0.4.0.dist-info/METADATA,sha256=TGPWdTziOm6yt9HLE8GKtbDxUaU-N9GHcNH9vsAbdzw,3344
9
+ leneda_client-0.4.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
10
+ leneda_client-0.4.0.dist-info/top_level.txt,sha256=PANScm25ep7WLjKiph0fhJPb8s_sa_uLHemnBpQBaJ8,7
11
+ leneda_client-0.4.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.1.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- leneda/__init__.py,sha256=-BHIXBfTTbX6EKDHr2Bq7rPzsPNYrrkgs9AJqWJR_1Q,732
2
- leneda/client.py,sha256=X2seOTrUYLKuLxDJT6ryGdKfNelsOhVq7lenJjI3kmM,10825
3
- leneda/exceptions.py,sha256=a84T3uSDQsMiKyFUZTbJTAp3hELfI1GQDriqv6aMDb8,600
4
- leneda/models.py,sha256=jdU2cIZZDExUSiSfz9zaYjJepr0m3v_x5b1fyOaEI8Q,7930
5
- leneda/obis_codes.py,sha256=VfsJQN1U80eZ5g1bIteDCLkkmBQ0AIkkm_zNAeM1Dog,7507
6
- leneda/version.py,sha256=wtPxgfjm82dK-e3EK0shDP4_7DlFk8hkRkOIPd6mV58,50
7
- leneda_client-0.3.0.dist-info/licenses/LICENSE,sha256=nAhDs625lK6v8oLqjWCABKBKlwxVoRDFXQvoZPfOtKQ,1062
8
- leneda_client-0.3.0.dist-info/METADATA,sha256=RHArkKFQqY--FL7-RCwTUQTaJvMWLvdswIYbM-8Yr1U,3344
9
- leneda_client-0.3.0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
10
- leneda_client-0.3.0.dist-info/top_level.txt,sha256=PANScm25ep7WLjKiph0fhJPb8s_sa_uLHemnBpQBaJ8,7
11
- leneda_client-0.3.0.dist-info/RECORD,,