python-mytnb 0.5.0__tar.gz → 0.5.1__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.
Files changed (26) hide show
  1. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/PKG-INFO +1 -1
  2. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/pyproject.toml +1 -1
  3. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/models.py +7 -0
  4. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/tests/test_models.py +6 -0
  5. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/.github/workflows/ci.yml +0 -0
  6. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/.github/workflows/publish.yml +0 -0
  7. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/.gitignore +0 -0
  8. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/LICENSE +0 -0
  9. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/README.md +0 -0
  10. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/__init__.py +0 -0
  11. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/__main__.py +0 -0
  12. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/auth.py +0 -0
  13. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/cli.py +0 -0
  14. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/client/__init__.py +0 -0
  15. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/client/auth.py +0 -0
  16. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/client/client.py +0 -0
  17. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/client/config.py +0 -0
  18. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/client/legacy.py +0 -0
  19. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/client/rest.py +0 -0
  20. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/crypto.py +0 -0
  21. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/src/mytnb/exceptions.py +0 -0
  22. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/tests/test_auth.py +0 -0
  23. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/tests/test_cli.py +0 -0
  24. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/tests/test_client.py +0 -0
  25. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/tests/test_crypto.py +0 -0
  26. {python_mytnb-0.5.0 → python_mytnb-0.5.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-mytnb
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Python library to interface with the myTNB API (Tenaga Nasional Berhad)
5
5
  Project-URL: Repository, https://github.com/danieyal/python-mytnb
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-mytnb"
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  description = "Python library to interface with the myTNB API (Tenaga Nasional Berhad)"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -267,6 +267,13 @@ class AccountUsage(BaseModel):
267
267
  return m.numeric_value
268
268
  return None
269
269
 
270
+ @property
271
+ def average_usage_kwh(self) -> Optional[float]:
272
+ for m in self.usage_metrics:
273
+ if m.key == "AVGUSAGE":
274
+ return m.numeric_value
275
+ return None
276
+
270
277
  @property
271
278
  def current_cost_rm(self) -> Optional[float]:
272
279
  for m in self.cost_metrics:
@@ -244,6 +244,10 @@ class TestAccountUsage:
244
244
  usage = AccountUsage.from_api_response(FULL_API_RESPONSE)
245
245
  assert usage.current_usage_kwh == 234.5
246
246
 
247
+ def test_average_usage_kwh(self):
248
+ usage = AccountUsage.from_api_response(FULL_API_RESPONSE)
249
+ assert usage.average_usage_kwh == 15.6
250
+
247
251
  def test_current_cost_rm(self):
248
252
  usage = AccountUsage.from_api_response(FULL_API_RESPONSE)
249
253
  assert usage.current_cost_rm == 87.60
@@ -280,6 +284,7 @@ class TestAccountUsage:
280
284
  def test_empty_response(self):
281
285
  usage = AccountUsage.from_api_response({})
282
286
  assert usage.current_usage_kwh is None
287
+ assert usage.average_usage_kwh is None
283
288
  assert usage.current_cost_rm is None
284
289
  assert usage.projected_cost_rm is None
285
290
  assert usage.by_month is None
@@ -291,6 +296,7 @@ class TestAccountUsage:
291
296
  }
292
297
  usage = AccountUsage.from_api_response(data)
293
298
  assert usage.current_usage_kwh is None
299
+ assert usage.average_usage_kwh is None
294
300
  assert usage.current_cost_rm is None
295
301
 
296
302
 
File without changes
File without changes
File without changes
File without changes