bwt-api 0.2.1__tar.gz → 0.3.0__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 (30) hide show
  1. {bwt_api-0.2.1 → bwt_api-0.3.0}/PKG-INFO +1 -1
  2. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api/api.py +12 -4
  3. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api/data.py +5 -4
  4. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/PKG-INFO +2 -2
  5. {bwt_api-0.2.1 → bwt_api-0.3.0}/tests/test_api.py +10 -8
  6. {bwt_api-0.2.1 → bwt_api-0.3.0}/.coveragerc +0 -0
  7. {bwt_api-0.2.1 → bwt_api-0.3.0}/.github/workflows/python-package.yml +0 -0
  8. {bwt_api-0.2.1 → bwt_api-0.3.0}/.github/workflows/python-publish.yml +0 -0
  9. {bwt_api-0.2.1 → bwt_api-0.3.0}/.gitignore +0 -0
  10. {bwt_api-0.2.1 → bwt_api-0.3.0}/AUTHORS.rst +0 -0
  11. {bwt_api-0.2.1 → bwt_api-0.3.0}/CHANGELOG.rst +0 -0
  12. {bwt_api-0.2.1 → bwt_api-0.3.0}/CONTRIBUTING.rst +0 -0
  13. {bwt_api-0.2.1 → bwt_api-0.3.0}/LICENSE.txt +0 -0
  14. {bwt_api-0.2.1 → bwt_api-0.3.0}/README.rst +0 -0
  15. {bwt_api-0.2.1 → bwt_api-0.3.0}/pyproject.toml +0 -0
  16. {bwt_api-0.2.1 → bwt_api-0.3.0}/setup.cfg +0 -0
  17. {bwt_api-0.2.1 → bwt_api-0.3.0}/setup.py +0 -0
  18. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api/__init__.py +0 -0
  19. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api/error.py +0 -0
  20. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api/exception.py +0 -0
  21. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api/skeleton.py +0 -0
  22. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/SOURCES.txt +0 -0
  23. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/dependency_links.txt +0 -0
  24. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/entry_points.txt +0 -0
  25. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/not-zip-safe +0 -0
  26. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/requires.txt +0 -0
  27. {bwt_api-0.2.1 → bwt_api-0.3.0}/src/bwt_api.egg-info/top_level.txt +0 -0
  28. {bwt_api-0.2.1 → bwt_api-0.3.0}/tests/conftest.py +0 -0
  29. {bwt_api-0.2.1 → bwt_api-0.3.0}/tests/pytest.ini +0 -0
  30. {bwt_api-0.2.1 → bwt_api-0.3.0}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bwt_api
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: Python API to access the local BWT Perla API.
5
5
  Home-page: https://github.com/dkarv/bwt_api
6
6
  Author: dkarv
@@ -5,6 +5,8 @@ from tokenize import String
5
5
  import aiohttp
6
6
  import base64
7
7
  import logging
8
+ from datetime import datetime
9
+ from zoneinfo import ZoneInfo
8
10
 
9
11
  from bwt_api.error import BwtError
10
12
  from bwt_api.exception import ApiException, ConnectException, WrongCodeException
@@ -60,6 +62,12 @@ class BwtApi:
60
62
  except aiohttp.ClientConnectorError as e:
61
63
  raise ConnectException from e
62
64
 
65
+ def _convert_datetime(self, input: str) -> datetime:
66
+ # It looks like the device even shows everything in UTC
67
+ return datetime.strptime(
68
+ input, "%Y-%m-%d %H:%M:%S"
69
+ ).replace(tzinfo=ZoneInfo("UTC"))
70
+
63
71
  async def get_current_data(self) -> CurrentResponse:
64
72
  """Get the current state of the BWT."""
65
73
  _logger.debug(f"Fetching current data from {self._host}")
@@ -89,10 +97,10 @@ class BwtApi:
89
97
  in_hardness,
90
98
  out_hardness,
91
99
  raw["HolidayModeStartTime"],
92
- raw["LastRegenerationColumn1"],
93
- raw["LastRegenerationColumn2"],
94
- raw["LastServiceCustomer"],
95
- raw["LastServiceTechnican"],
100
+ self._convert_datetime(raw["LastRegenerationColumn1"]),
101
+ self._convert_datetime(raw["LastRegenerationColumn2"]),
102
+ self._convert_datetime(raw["LastServiceCustomer"]),
103
+ self._convert_datetime(raw["LastServiceTechnican"]),
96
104
  raw["OutOfService"],
97
105
  raw["RegenerationCounterColumn1"],
98
106
  raw["RegenerationCounterColumn2"],
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
  from dataclasses import dataclass
5
+ from datetime import datetime
5
6
  from bwt_api.error import BwtError
6
7
 
7
8
 
@@ -25,10 +26,10 @@ class CurrentResponse:
25
26
  in_hardness: Hardness
26
27
  out_hardness: Hardness
27
28
  holiday_mode: int # -1 or 0: inactive, 1: active, unix timestamp: start in future
28
- regeneration_last_1: str # date time
29
- regeneration_last_2: str # date time
30
- service_customer: str
31
- service_technician: str
29
+ regeneration_last_1: datetime
30
+ regeneration_last_2: datetime
31
+ service_customer: datetime
32
+ service_technician: datetime
32
33
  out_of_service: int
33
34
  regeneration_count_1: int
34
35
  regeneration_count_2: int
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: bwt-api
3
- Version: 0.2.1
2
+ Name: bwt_api
3
+ Version: 0.3.0
4
4
  Summary: Python API to access the local BWT Perla API.
5
5
  Home-page: https://github.com/dkarv/bwt_api
6
6
  Author: dkarv
@@ -1,3 +1,5 @@
1
+ from datetime import datetime
2
+ from zoneinfo import ZoneInfo
1
3
  import pytest
2
4
 
3
5
  from bwt_api.api import BwtApi
@@ -128,10 +130,10 @@ async def test_current_data():
128
130
  in_hardness=Hardness(caco3=374, dH=21, fH=37, mmol=4),
129
131
  out_hardness=Hardness(caco3=71, dH=4, fH=7, mmol=1),
130
132
  holiday_mode=0,
131
- regeneration_last_1="2023-11-16 04:42:15",
132
- regeneration_last_2="2023-11-15 04:41:48",
133
- service_customer="2023-05-18 10:51:07",
134
- service_technician="2021-01-25 13:14:06",
133
+ regeneration_last_1=datetime(2023, 11, 16, 4, 42,15,0,ZoneInfo("UTC")),
134
+ regeneration_last_2=datetime(2023, 11, 15, 4, 41,48,0,ZoneInfo("UTC")),
135
+ service_customer=datetime(2023, 5, 18, 10, 51,7,0,ZoneInfo("UTC")),
136
+ service_technician=datetime(2021, 1, 25, 13, 14,6,0,ZoneInfo("UTC")),
135
137
  out_of_service=0,
136
138
  regeneration_count_1=754,
137
139
  regeneration_count_2=751,
@@ -162,10 +164,10 @@ async def test_empty_errors():
162
164
  in_hardness=Hardness(caco3=374, dH=21, fH=37, mmol=4),
163
165
  out_hardness=Hardness(caco3=71, dH=4, fH=7, mmol=1),
164
166
  holiday_mode=0,
165
- regeneration_last_1="2023-11-16 04:42:15",
166
- regeneration_last_2="2023-11-15 04:41:48",
167
- service_customer="2023-05-18 10:51:07",
168
- service_technician="2021-01-25 13:14:06",
167
+ regeneration_last_1=datetime(2023, 11, 16, 4, 42,15,0,ZoneInfo("UTC")),
168
+ regeneration_last_2=datetime(2023, 11, 15, 4, 41,48,0,ZoneInfo("UTC")),
169
+ service_customer=datetime(2023, 5, 18, 10, 51,7,0,ZoneInfo("UTC")),
170
+ service_technician=datetime(2021, 1, 25, 13, 14,6,0,ZoneInfo("UTC")),
169
171
  out_of_service=0,
170
172
  regeneration_count_1=754,
171
173
  regeneration_count_2=751,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes