bwt-api 0.3.0__tar.gz → 0.4.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.
- {bwt_api-0.3.0/src/bwt_api.egg-info → bwt_api-0.4.1}/PKG-INFO +1 -1
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api/api.py +3 -9
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api/data.py +9 -2
- {bwt_api-0.3.0 → bwt_api-0.4.1/src/bwt_api.egg-info}/PKG-INFO +1 -1
- {bwt_api-0.3.0 → bwt_api-0.4.1}/tests/test_api.py +6 -5
- {bwt_api-0.3.0 → bwt_api-0.4.1}/.coveragerc +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/.github/workflows/python-package.yml +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/.github/workflows/python-publish.yml +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/.gitignore +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/AUTHORS.rst +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/CHANGELOG.rst +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/CONTRIBUTING.rst +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/LICENSE.txt +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/README.rst +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/pyproject.toml +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/setup.cfg +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/setup.py +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api/__init__.py +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api/error.py +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api/exception.py +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api/skeleton.py +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api.egg-info/SOURCES.txt +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api.egg-info/dependency_links.txt +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api.egg-info/entry_points.txt +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api.egg-info/not-zip-safe +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api.egg-info/requires.txt +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/src/bwt_api.egg-info/top_level.txt +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/tests/conftest.py +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/tests/pytest.ini +0 -0
- {bwt_api-0.3.0 → bwt_api-0.4.1}/tox.ini +0 -0
|
@@ -10,16 +10,10 @@ from zoneinfo import ZoneInfo
|
|
|
10
10
|
|
|
11
11
|
from bwt_api.error import BwtError
|
|
12
12
|
from bwt_api.exception import ApiException, ConnectException, WrongCodeException
|
|
13
|
-
|
|
14
|
-
from bwt_api.data import CurrentResponse, DailyResponse, MonthlyResponse, YearlyResponse
|
|
15
|
-
from bwt_api.data import Hardness
|
|
13
|
+
from bwt_api.data import CurrentResponse, DailyResponse, MonthlyResponse, YearlyResponse, Hardness, BwtStatus
|
|
16
14
|
|
|
17
15
|
_logger = logging.getLogger(__name__)
|
|
18
16
|
|
|
19
|
-
class RestApi:
|
|
20
|
-
"""Rest functionality encapsulated for testing."""
|
|
21
|
-
|
|
22
|
-
|
|
23
17
|
class BwtApi:
|
|
24
18
|
"""BWT Api."""
|
|
25
19
|
_session: aiohttp.ClientSession
|
|
@@ -63,7 +57,7 @@ class BwtApi:
|
|
|
63
57
|
raise ConnectException from e
|
|
64
58
|
|
|
65
59
|
def _convert_datetime(self, input: str) -> datetime:
|
|
66
|
-
# It looks like the device even shows everything in UTC
|
|
60
|
+
# It looks like the device sends and even shows everything in UTC
|
|
67
61
|
return datetime.strptime(
|
|
68
62
|
input, "%Y-%m-%d %H:%M:%S"
|
|
69
63
|
).replace(tzinfo=ZoneInfo("UTC"))
|
|
@@ -108,7 +102,7 @@ class BwtApi:
|
|
|
108
102
|
raw["RegenerativLevel"],
|
|
109
103
|
raw["RegenerativRemainingDays"],
|
|
110
104
|
raw["RegenerativSinceSetup_g"],
|
|
111
|
-
raw["ShowError"],
|
|
105
|
+
BwtStatus(int(raw["ShowError"])),
|
|
112
106
|
raw["WaterTreatedCurrentDay_l"],
|
|
113
107
|
raw["WaterTreatedCurrentMonth_l"],
|
|
114
108
|
raw["WaterTreatedCurrentYear_l"],
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"""Data objects received from the API."""
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
import enum
|
|
5
|
+
|
|
4
6
|
from dataclasses import dataclass
|
|
5
7
|
from datetime import datetime
|
|
6
8
|
from bwt_api.error import BwtError
|
|
7
9
|
|
|
8
10
|
|
|
11
|
+
class BwtStatus(enum.Enum):
|
|
12
|
+
OK = 0
|
|
13
|
+
WARNING = 1
|
|
14
|
+
ERROR = 2
|
|
15
|
+
|
|
9
16
|
@dataclass
|
|
10
17
|
class Hardness:
|
|
11
18
|
caco3: int # ppm CACO3
|
|
@@ -37,7 +44,7 @@ class CurrentResponse:
|
|
|
37
44
|
regenerativ_level: int # %
|
|
38
45
|
regenerativ_days: int # days left
|
|
39
46
|
regenerativ_total: int # g
|
|
40
|
-
|
|
47
|
+
state: BwtStatus
|
|
41
48
|
treated_day: int # treated water current day
|
|
42
49
|
treated_month: int # treated water current month
|
|
43
50
|
treated_year: int # treated water current year
|
|
@@ -58,4 +65,4 @@ class MonthlyResponse:
|
|
|
58
65
|
@dataclass
|
|
59
66
|
class YearlyResponse:
|
|
60
67
|
# treated water in 1 month intervals
|
|
61
|
-
values: list[int]
|
|
68
|
+
values: list[int]
|
|
@@ -4,7 +4,8 @@ import pytest
|
|
|
4
4
|
|
|
5
5
|
from bwt_api.api import BwtApi
|
|
6
6
|
from bwt_api.error import BwtError
|
|
7
|
-
from bwt_api.data import CurrentResponse, Hardness
|
|
7
|
+
from bwt_api.data import CurrentResponse, Hardness, BwtStatus
|
|
8
|
+
|
|
8
9
|
from aioresponses import aioresponses
|
|
9
10
|
|
|
10
11
|
from bwt_api.exception import ApiException, ConnectException, WrongCodeException
|
|
@@ -43,7 +44,7 @@ current_json = """
|
|
|
43
44
|
"RegenerativLevel" : 20,
|
|
44
45
|
"RegenerativRemainingDays" : 26,
|
|
45
46
|
"RegenerativSinceSetup_g" : 245846,
|
|
46
|
-
"ShowError" :
|
|
47
|
+
"ShowError" : 2,
|
|
47
48
|
"WaterSinceSetup_l" : 261633,
|
|
48
49
|
"WaterTreatedCurrentDay_l" : 181,
|
|
49
50
|
"WaterTreatedCurrentMonth_l" : 3137,
|
|
@@ -80,7 +81,7 @@ current_json_empty_errors = """
|
|
|
80
81
|
"RegenerativLevel" : 20,
|
|
81
82
|
"RegenerativRemainingDays" : 26,
|
|
82
83
|
"RegenerativSinceSetup_g" : 245846,
|
|
83
|
-
"ShowError" :
|
|
84
|
+
"ShowError" : 0,
|
|
84
85
|
"WaterSinceSetup_l" : 261633,
|
|
85
86
|
"WaterTreatedCurrentDay_l" : 181,
|
|
86
87
|
"WaterTreatedCurrentMonth_l" : 3137,
|
|
@@ -141,7 +142,7 @@ async def test_current_data():
|
|
|
141
142
|
regenerativ_level=20,
|
|
142
143
|
regenerativ_days=26,
|
|
143
144
|
regenerativ_total=245846,
|
|
144
|
-
|
|
145
|
+
state=BwtStatus.ERROR,
|
|
145
146
|
treated_day=181,
|
|
146
147
|
treated_month=3137,
|
|
147
148
|
treated_year=80700,
|
|
@@ -175,7 +176,7 @@ async def test_empty_errors():
|
|
|
175
176
|
regenerativ_level=20,
|
|
176
177
|
regenerativ_days=26,
|
|
177
178
|
regenerativ_total=245846,
|
|
178
|
-
|
|
179
|
+
state=BwtStatus.OK,
|
|
179
180
|
treated_day=181,
|
|
180
181
|
treated_month=3137,
|
|
181
182
|
treated_year=80700,
|
|
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
|
|
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
|