compit-inext-api-beta 0.4.0b10__tar.gz → 0.4.3b2__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.
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/PKG-INFO +1 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/__init__.py +2 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/api.py +9 -9
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/connector.py +19 -6
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/consts.py +52 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/definitions/devices_en.json +168 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/device_definitions.py +16 -3
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/params_dictionary.py +8 -8
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/types/DeviceState.py +3 -3
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/types/SystemInfo.py +4 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api_beta.egg-info/PKG-INFO +1 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/pyproject.toml +1 -1
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/LICENSE +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/README.md +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/definitions/__init__.py +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/definitions/devices_pl.json +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/py.typed +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/types/DeviceDefinitions.py +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api_beta.egg-info/SOURCES.txt +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api_beta.egg-info/dependency_links.txt +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api_beta.egg-info/requires.txt +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api_beta.egg-info/top_level.txt +0 -0
- {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/setup.cfg +0 -0
{compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/__init__.py
RENAMED
|
@@ -5,7 +5,7 @@ from .api import CompitAPI, CannotConnect, InvalidAuth
|
|
|
5
5
|
from .types.DeviceState import DeviceState, Param, DeviceInstance
|
|
6
6
|
from .types.DeviceDefinitions import DeviceDefinitions, Parameter, ParameterDetails
|
|
7
7
|
from .types.SystemInfo import SystemInfo, Gate, Device
|
|
8
|
-
from .consts import CompitHVACMode, CompitParameter, CompitFanMode, CompitPresetMode
|
|
8
|
+
from .consts import CompitHVACMode, CompitParameter, CompitFanMode, CompitPresetMode, CompitDevice
|
|
9
9
|
from .connector import CompitApiConnector
|
|
10
10
|
|
|
11
11
|
__all__ = [
|
|
@@ -22,6 +22,7 @@ __all__ = [
|
|
|
22
22
|
"Device",
|
|
23
23
|
"InvalidAuth",
|
|
24
24
|
"CannotConnect",
|
|
25
|
+
"CompitDevice",
|
|
25
26
|
"CompitHVACMode",
|
|
26
27
|
"CompitParameter",
|
|
27
28
|
"CompitFanMode",
|
|
@@ -19,7 +19,7 @@ API_URL = "https://inext.compit.pl/mobile/v2/compit"
|
|
|
19
19
|
class CompitAPI:
|
|
20
20
|
"""API client for Compit."""
|
|
21
21
|
|
|
22
|
-
def __init__(self, email, password, session: aiohttp.ClientSession) -> None:
|
|
22
|
+
def __init__(self, email: str, password: str, session: aiohttp.ClientSession) -> None:
|
|
23
23
|
"""Initialize the CompitAPI class."""
|
|
24
24
|
self.email = email
|
|
25
25
|
self.password = password
|
|
@@ -107,7 +107,7 @@ class CompitAPI:
|
|
|
107
107
|
try:
|
|
108
108
|
_LOGGER.info("Set %s to %s for device %s", parameter, value, device_id)
|
|
109
109
|
|
|
110
|
-
data = {"values": [{"code": parameter.value if isinstance(parameter, CompitParameter) else parameter, "value": value}]}
|
|
110
|
+
data: dict[str, Any] = {"values": [{"code": parameter.value if isinstance(parameter, CompitParameter) else parameter, "value": value}]}
|
|
111
111
|
|
|
112
112
|
response = await self._api_wrapper.put(
|
|
113
113
|
f"{API_URL}/devices/{device_id}/params", data=data, auth=self.token
|
|
@@ -157,7 +157,7 @@ class ApiWrapper:
|
|
|
157
157
|
self._session = session
|
|
158
158
|
|
|
159
159
|
async def get(
|
|
160
|
-
self, url: str, headers: dict | None = None, auth: Any = None
|
|
160
|
+
self, url: str, headers: dict[str, Any] | None = None, auth: Any = None
|
|
161
161
|
) -> aiohttp.ClientResponse:
|
|
162
162
|
"""Run http GET method."""
|
|
163
163
|
if headers is None:
|
|
@@ -171,8 +171,8 @@ class ApiWrapper:
|
|
|
171
171
|
async def post(
|
|
172
172
|
self,
|
|
173
173
|
url: str,
|
|
174
|
-
data: dict | None = None,
|
|
175
|
-
headers: dict | None = None,
|
|
174
|
+
data: dict[str, Any] | None = None,
|
|
175
|
+
headers: dict[str, Any] | None = None,
|
|
176
176
|
auth: Any = None,
|
|
177
177
|
) -> aiohttp.ClientResponse:
|
|
178
178
|
"""Run http POST method."""
|
|
@@ -189,8 +189,8 @@ class ApiWrapper:
|
|
|
189
189
|
async def put(
|
|
190
190
|
self,
|
|
191
191
|
url: str,
|
|
192
|
-
data: dict | None = None,
|
|
193
|
-
headers: dict | None = None,
|
|
192
|
+
data: dict[str, Any] | None = None,
|
|
193
|
+
headers: dict[str, Any] | None = None,
|
|
194
194
|
auth: Any = None,
|
|
195
195
|
) -> aiohttp.ClientResponse:
|
|
196
196
|
"""Run http PUT method."""
|
|
@@ -206,8 +206,8 @@ class ApiWrapper:
|
|
|
206
206
|
self,
|
|
207
207
|
method: str,
|
|
208
208
|
url: str,
|
|
209
|
-
data: dict | None = None,
|
|
210
|
-
headers: dict | None = None,
|
|
209
|
+
data: dict[str, Any] | None = None,
|
|
210
|
+
headers: dict[str, Any] | None = None,
|
|
211
211
|
auth: Any = None,
|
|
212
212
|
) -> Any:
|
|
213
213
|
"""Get information from the API."""
|
{compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.4.3b2}/compit_inext_api/connector.py
RENAMED
|
@@ -5,7 +5,8 @@ from compit_inext_api.api import CompitAPI
|
|
|
5
5
|
from compit_inext_api.consts import CompitParameter
|
|
6
6
|
from compit_inext_api.params_dictionary import PARAMS
|
|
7
7
|
from compit_inext_api.device_definitions import DeviceDefinitionsLoader
|
|
8
|
-
from compit_inext_api.
|
|
8
|
+
from compit_inext_api.params_dictionary import PARAMS
|
|
9
|
+
from compit_inext_api.types.DeviceState import DeviceInstance, GateInstance, Param
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
_LOGGER: logging.Logger = logging.getLogger(__package__)
|
|
@@ -18,7 +19,7 @@ class CompitApiConnector:
|
|
|
18
19
|
|
|
19
20
|
@property
|
|
20
21
|
def all_devices(self) -> dict[int, DeviceInstance]:
|
|
21
|
-
devices = {}
|
|
22
|
+
devices: dict[int, DeviceInstance] = {}
|
|
22
23
|
for gate in self.gates.values():
|
|
23
24
|
devices.update(gate.devices)
|
|
24
25
|
return devices
|
|
@@ -32,7 +33,7 @@ class CompitApiConnector:
|
|
|
32
33
|
return gate.devices[device_id]
|
|
33
34
|
return None
|
|
34
35
|
|
|
35
|
-
async def init(self, email: str, password: str, lang: str =
|
|
36
|
+
async def init(self, email: str, password: str, lang: str | None = None) -> bool:
|
|
36
37
|
self.api = CompitAPI(email, password, self.session)
|
|
37
38
|
self.systemInfo = await self.api.authenticate()
|
|
38
39
|
if self.systemInfo is None:
|
|
@@ -43,7 +44,13 @@ class CompitApiConnector:
|
|
|
43
44
|
self.gates[gates.id] = GateInstance(gates.id, gates.label)
|
|
44
45
|
for device in gates.devices:
|
|
45
46
|
try:
|
|
46
|
-
self.gates[gates.id].devices[device.id] = DeviceInstance(
|
|
47
|
+
self.gates[gates.id].devices[device.id] = DeviceInstance(
|
|
48
|
+
device.label,
|
|
49
|
+
await DeviceDefinitionsLoader.get_device_definition(
|
|
50
|
+
device.type,
|
|
51
|
+
lang=lang,
|
|
52
|
+
),
|
|
53
|
+
)
|
|
47
54
|
state = await self.api.get_state(device.id)
|
|
48
55
|
if state:
|
|
49
56
|
self.gates[gates.id].devices[device.id].state = state
|
|
@@ -77,13 +84,19 @@ class CompitApiConnector:
|
|
|
77
84
|
device = self.get_device(device_id)
|
|
78
85
|
if not device:
|
|
79
86
|
return None
|
|
80
|
-
|
|
87
|
+
|
|
81
88
|
param = PARAMS.get(parameter, None)
|
|
82
89
|
if param is None:
|
|
83
90
|
return None
|
|
91
|
+
|
|
92
|
+
val = device.state.get_parameter_value(parameter.value)
|
|
93
|
+
if val is None:
|
|
94
|
+
return None
|
|
95
|
+
|
|
84
96
|
for key, value in param.items():
|
|
85
|
-
if value == val:
|
|
97
|
+
if value == val.value:
|
|
86
98
|
return key
|
|
99
|
+
|
|
87
100
|
return None
|
|
88
101
|
|
|
89
102
|
def get_device_parameter(self, device_id: int, parameter: str | CompitParameter) -> Param | str | None:
|
|
@@ -91,4 +91,55 @@ class CompitPresetMode(Enum):
|
|
|
91
91
|
AUTO = 0
|
|
92
92
|
HOLIDAY = 1
|
|
93
93
|
MANUAL = 2
|
|
94
|
-
AWAY = 3
|
|
94
|
+
AWAY = 3
|
|
95
|
+
|
|
96
|
+
class CompitDevice(Enum):
|
|
97
|
+
"""Enum for Compit devices.
|
|
98
|
+
|
|
99
|
+
The enum value is the device `Code`, so you can look up a device by code:
|
|
100
|
+
`CompitDevice(223) -> CompitDevice.NANO_COLOR_2`.
|
|
101
|
+
|
|
102
|
+
Each member also exposes:
|
|
103
|
+
- `label`: original device name
|
|
104
|
+
- `device_class`: device class id
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
label: str
|
|
108
|
+
device_class: int
|
|
109
|
+
|
|
110
|
+
def __new__(cls, label: str, code: int, device_class: int):
|
|
111
|
+
obj = object.__new__(cls)
|
|
112
|
+
obj._value_ = code
|
|
113
|
+
obj.label = label
|
|
114
|
+
obj.device_class = device_class
|
|
115
|
+
return obj
|
|
116
|
+
|
|
117
|
+
AF_1 = ("AF-1", 226, 48)
|
|
118
|
+
BIOMAX742_2 = ("BioMax742", 36, 15)
|
|
119
|
+
BIOMAX742 = ("BioMax742", 212, 15)
|
|
120
|
+
BIOMAX772 = ("BioMax772", 75, 15)
|
|
121
|
+
BIOMAX775 = ("BioMax775", 201, 15)
|
|
122
|
+
BWC310 = ("BWC310", 14, 69)
|
|
123
|
+
COMBO = ("COMBO", 227, 49)
|
|
124
|
+
COMBO_PRO = ("COMBO PRO", 229, 37)
|
|
125
|
+
EL750 = ("EL750", 210, 29)
|
|
126
|
+
L2 = ("L2", 17, 12)
|
|
127
|
+
NANO_COLOR = ("Nano Color", 12, 10)
|
|
128
|
+
NANO_COLOR_2 = ("Nano Color 2", 223, 10)
|
|
129
|
+
NANO_ONE = ("Nano One", 7, 10)
|
|
130
|
+
R_900 = ("R 900", 224, 47)
|
|
131
|
+
R350CWU = ("R350.CWU", 53, 36)
|
|
132
|
+
R350M = ("R350.M", 221, 14)
|
|
133
|
+
R350_T3 = ("R350 T3", 5, 14)
|
|
134
|
+
R470 = ("r470", 34, 16)
|
|
135
|
+
R480 = ("R480", 215, 43)
|
|
136
|
+
R490 = ("r490", 92, 33)
|
|
137
|
+
R770RS_R771RS = ("R770RS / R771RS", 91, 25)
|
|
138
|
+
R810 = ("R810", 3, 14)
|
|
139
|
+
R810_1 = ("R810", 222, 34)
|
|
140
|
+
CO2_SHC = ("SHC", 27, 15)
|
|
141
|
+
SOLARCOMP_951 = ("SolarComp 951", 44, 18)
|
|
142
|
+
SOLARCOMP971 = ("SolarComp971", 45, 18)
|
|
143
|
+
SPM_NANO_COLOR = ("SPM - Nano Color", 225, 27)
|
|
144
|
+
SPM_NANO_COLOR2 = ("SPM - Nano Color2", 0, 46)
|
|
145
|
+
SPM_NANO_COLOR2_1 = ("SPM - Nano Color2", 78, 46)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"Name": "Nano Color
|
|
3
|
+
"Name": "Nano Color 2",
|
|
4
4
|
"Parameters": [
|
|
5
5
|
{
|
|
6
6
|
"ParameterCode": "__tpokojowa",
|
|
@@ -22104,6 +22104,173 @@
|
|
|
22104
22104
|
"Class": 46,
|
|
22105
22105
|
"ID": ""
|
|
22106
22106
|
},
|
|
22107
|
+
{
|
|
22108
|
+
"Name": "SPM - Nano Color2",
|
|
22109
|
+
"Parameters": [
|
|
22110
|
+
{
|
|
22111
|
+
"ParameterCode": "__rr_co2",
|
|
22112
|
+
"Label": "Co2",
|
|
22113
|
+
"ReadWrite": "R",
|
|
22114
|
+
"Details": null,
|
|
22115
|
+
"MinValue": null,
|
|
22116
|
+
"MaxValue": null,
|
|
22117
|
+
"Unit": "ppm"
|
|
22118
|
+
},
|
|
22119
|
+
{
|
|
22120
|
+
"ParameterCode": "__hig",
|
|
22121
|
+
"Label": "Humidity",
|
|
22122
|
+
"ReadWrite": "R",
|
|
22123
|
+
"Details": null,
|
|
22124
|
+
"MinValue": null,
|
|
22125
|
+
"MaxValue": null,
|
|
22126
|
+
"Unit": "%"
|
|
22127
|
+
},
|
|
22128
|
+
{
|
|
22129
|
+
"ParameterCode": "__vocindex",
|
|
22130
|
+
"Label": "Voc index (volatile compounds)",
|
|
22131
|
+
"ReadWrite": "R",
|
|
22132
|
+
"Details": null,
|
|
22133
|
+
"MinValue": null,
|
|
22134
|
+
"MaxValue": null,
|
|
22135
|
+
"Unit": null
|
|
22136
|
+
},
|
|
22137
|
+
{
|
|
22138
|
+
"ParameterCode": "__rr_pm1",
|
|
22139
|
+
"Label": "Pm1",
|
|
22140
|
+
"ReadWrite": "R",
|
|
22141
|
+
"Details": null,
|
|
22142
|
+
"MinValue": null,
|
|
22143
|
+
"MaxValue": null,
|
|
22144
|
+
"Unit": "ug/m3"
|
|
22145
|
+
},
|
|
22146
|
+
{
|
|
22147
|
+
"ParameterCode": "__rr_pm2_5",
|
|
22148
|
+
"Label": "Pm2.5",
|
|
22149
|
+
"ReadWrite": "R",
|
|
22150
|
+
"Details": null,
|
|
22151
|
+
"MinValue": null,
|
|
22152
|
+
"MaxValue": null,
|
|
22153
|
+
"Unit": "ug/m3"
|
|
22154
|
+
},
|
|
22155
|
+
{
|
|
22156
|
+
"ParameterCode": "__rr_pm4",
|
|
22157
|
+
"Label": "Pm4",
|
|
22158
|
+
"ReadWrite": "R",
|
|
22159
|
+
"Details": null,
|
|
22160
|
+
"MinValue": null,
|
|
22161
|
+
"MaxValue": null,
|
|
22162
|
+
"Unit": "ug/m3"
|
|
22163
|
+
},
|
|
22164
|
+
{
|
|
22165
|
+
"ParameterCode": "__temp",
|
|
22166
|
+
"Label": "Temperature",
|
|
22167
|
+
"ReadWrite": "R",
|
|
22168
|
+
"Details": null,
|
|
22169
|
+
"MinValue": null,
|
|
22170
|
+
"MaxValue": null,
|
|
22171
|
+
"Unit": "C"
|
|
22172
|
+
},
|
|
22173
|
+
{
|
|
22174
|
+
"ParameterCode": "__flaga_pyly",
|
|
22175
|
+
"Label": "Dust",
|
|
22176
|
+
"ReadWrite": "R",
|
|
22177
|
+
"Details": [
|
|
22178
|
+
{
|
|
22179
|
+
"State": 1,
|
|
22180
|
+
"Description": "Normal",
|
|
22181
|
+
"Param": "__nie"
|
|
22182
|
+
},
|
|
22183
|
+
{
|
|
22184
|
+
"State": 0,
|
|
22185
|
+
"Description": "Exceeded",
|
|
22186
|
+
"Param": "__tak"
|
|
22187
|
+
}
|
|
22188
|
+
],
|
|
22189
|
+
"MinValue": null,
|
|
22190
|
+
"MaxValue": null,
|
|
22191
|
+
"Unit": null
|
|
22192
|
+
},
|
|
22193
|
+
{
|
|
22194
|
+
"ParameterCode": "__osuszanie",
|
|
22195
|
+
"Label": "Drying",
|
|
22196
|
+
"ReadWrite": "R",
|
|
22197
|
+
"Details": [
|
|
22198
|
+
{
|
|
22199
|
+
"State": 1,
|
|
22200
|
+
"Description": "Yes",
|
|
22201
|
+
"Param": "__tak"
|
|
22202
|
+
},
|
|
22203
|
+
{
|
|
22204
|
+
"State": 0,
|
|
22205
|
+
"Description": "No",
|
|
22206
|
+
"Param": "__nie"
|
|
22207
|
+
}
|
|
22208
|
+
],
|
|
22209
|
+
"MinValue": null,
|
|
22210
|
+
"MaxValue": null,
|
|
22211
|
+
"Unit": null
|
|
22212
|
+
},
|
|
22213
|
+
{
|
|
22214
|
+
"ParameterCode": "__flaga_co2",
|
|
22215
|
+
"Label": "Co2",
|
|
22216
|
+
"ReadWrite": "R",
|
|
22217
|
+
"Details": null,
|
|
22218
|
+
"MinValue": null,
|
|
22219
|
+
"MaxValue": null,
|
|
22220
|
+
"Unit": null
|
|
22221
|
+
},
|
|
22222
|
+
{
|
|
22223
|
+
"ParameterCode": "__rr_pm10",
|
|
22224
|
+
"Label": "Pm10",
|
|
22225
|
+
"ReadWrite": "R",
|
|
22226
|
+
"Details": null,
|
|
22227
|
+
"MinValue": null,
|
|
22228
|
+
"MaxValue": null,
|
|
22229
|
+
"Unit": "ug/m3"
|
|
22230
|
+
},
|
|
22231
|
+
{
|
|
22232
|
+
"ParameterCode": "__rr_fl_temp",
|
|
22233
|
+
"Label": "Temperature (flaga)",
|
|
22234
|
+
"ReadWrite": "R",
|
|
22235
|
+
"Details": [
|
|
22236
|
+
{
|
|
22237
|
+
"State": 0,
|
|
22238
|
+
"Description": "Ok",
|
|
22239
|
+
"Param": "__ok"
|
|
22240
|
+
},
|
|
22241
|
+
{
|
|
22242
|
+
"State": 1,
|
|
22243
|
+
"Description": "Not ok",
|
|
22244
|
+
"Param": "__nie_ok"
|
|
22245
|
+
}
|
|
22246
|
+
],
|
|
22247
|
+
"MinValue": null,
|
|
22248
|
+
"MaxValue": null,
|
|
22249
|
+
"Unit": null
|
|
22250
|
+
},
|
|
22251
|
+
{
|
|
22252
|
+
"ParameterCode": "__rt_odczyt_co2",
|
|
22253
|
+
"Label": "Rt - co2 reading",
|
|
22254
|
+
"ReadWrite": "R",
|
|
22255
|
+
"Details": null,
|
|
22256
|
+
"MinValue": null,
|
|
22257
|
+
"MaxValue": null,
|
|
22258
|
+
"Unit": "ppm"
|
|
22259
|
+
},
|
|
22260
|
+
{
|
|
22261
|
+
"ParameterCode": "__rt_proc_co2",
|
|
22262
|
+
"Label": "Rt - procent co2",
|
|
22263
|
+
"ReadWrite": "R",
|
|
22264
|
+
"Details": null,
|
|
22265
|
+
"MinValue": null,
|
|
22266
|
+
"MaxValue": null,
|
|
22267
|
+
"Unit": "%"
|
|
22268
|
+
}
|
|
22269
|
+
],
|
|
22270
|
+
"Code": 0,
|
|
22271
|
+
"Class": 46,
|
|
22272
|
+
"ID": ""
|
|
22273
|
+
},
|
|
22107
22274
|
{
|
|
22108
22275
|
"Name": "SPM - Nano Color",
|
|
22109
22276
|
"Parameters": [
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from importlib import resources
|
|
2
2
|
import json
|
|
3
3
|
import logging
|
|
4
|
-
import aiofiles
|
|
4
|
+
import aiofiles # type: ignore
|
|
5
|
+
|
|
6
|
+
from compit_inext_api.consts import CompitDevice
|
|
5
7
|
|
|
6
8
|
from .types.DeviceDefinitions import DeviceDefinitions, Device
|
|
7
9
|
|
|
@@ -22,7 +24,7 @@ class DeviceDefinitionsLoader:
|
|
|
22
24
|
|
|
23
25
|
config_path = resources.files('compit_inext_api.definitions').joinpath(file_name)
|
|
24
26
|
try:
|
|
25
|
-
async with aiofiles.open(config_path, encoding="utf-8", mode='r') as file:
|
|
27
|
+
async with aiofiles.open(str(config_path), encoding="utf-8", mode='r') as file:
|
|
26
28
|
content = await file.read()
|
|
27
29
|
definitions = DeviceDefinitions.from_json(json.loads(content))
|
|
28
30
|
DeviceDefinitionsLoader.cache[lang] = definitions
|
|
@@ -35,8 +37,19 @@ class DeviceDefinitionsLoader:
|
|
|
35
37
|
raise ValueError("No definitions found") from None
|
|
36
38
|
|
|
37
39
|
@staticmethod
|
|
38
|
-
async def get_device_definition(code: int, lang: str =
|
|
40
|
+
async def get_device_definition(code: int, lang: str | None = None) -> Device:
|
|
39
41
|
"""Get the device definition for a specific device type."""
|
|
42
|
+
if not lang:
|
|
43
|
+
device = CompitDevice(code)
|
|
44
|
+
return Device(
|
|
45
|
+
name=device.label,
|
|
46
|
+
parameters=[],
|
|
47
|
+
code=int(device.value),
|
|
48
|
+
device_class=device.device_class,
|
|
49
|
+
id=None,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
40
53
|
definitions = await DeviceDefinitionsLoader.get_device_definitions(lang)
|
|
41
54
|
for device in definitions.devices:
|
|
42
55
|
if device.code == code:
|
|
@@ -226,7 +226,7 @@ PARAMS = {
|
|
|
226
226
|
"auto": 2,
|
|
227
227
|
"eco": 3,
|
|
228
228
|
},
|
|
229
|
-
CompitParameter.
|
|
229
|
+
CompitParameter.HEATING_SOURCE_OF_CORRECTION: {
|
|
230
230
|
"no_corrections": 1,
|
|
231
231
|
"schedule": 2,
|
|
232
232
|
"thermostat": 3,
|
|
@@ -286,7 +286,7 @@ PARAMS = {
|
|
|
286
286
|
"constant": 1,
|
|
287
287
|
"schedule": 2,
|
|
288
288
|
},
|
|
289
|
-
CompitParameter.
|
|
289
|
+
CompitParameter.BIOMAX_HEATING_SOURCE_OF_CORRECTION: {
|
|
290
290
|
"disabled": 0,
|
|
291
291
|
"no_corrections": 1,
|
|
292
292
|
"schedule": 2,
|
|
@@ -297,7 +297,7 @@ PARAMS = {
|
|
|
297
297
|
"nano_nr_4": 7,
|
|
298
298
|
"nano_nr_5": 8,
|
|
299
299
|
},
|
|
300
|
-
CompitParameter.
|
|
300
|
+
CompitParameter.BIOMAX_MIXER_MODE_ZONE_1: {
|
|
301
301
|
"disabled": 0,
|
|
302
302
|
"without_thermostat": 1,
|
|
303
303
|
"no_corrections": 1,
|
|
@@ -309,7 +309,7 @@ PARAMS = {
|
|
|
309
309
|
"nano_nr_4": 7,
|
|
310
310
|
"nano_nr_5": 8,
|
|
311
311
|
},
|
|
312
|
-
CompitParameter.
|
|
312
|
+
CompitParameter.BIOMAX_MIXER_MODE_ZONE_2: {
|
|
313
313
|
"disabled": 0,
|
|
314
314
|
"without_thermostat": 1,
|
|
315
315
|
"no_corrections": 1,
|
|
@@ -321,22 +321,22 @@ PARAMS = {
|
|
|
321
321
|
"nano_nr_4": 7,
|
|
322
322
|
"nano_nr_5": 8,
|
|
323
323
|
},
|
|
324
|
-
CompitParameter.
|
|
324
|
+
CompitParameter.BIOMAX_DHW_MODE: {
|
|
325
325
|
"disabled": 0,
|
|
326
326
|
"constant": 1,
|
|
327
327
|
"schedule": 2,
|
|
328
328
|
},
|
|
329
|
-
CompitParameter.
|
|
329
|
+
CompitParameter.BIOMAX_DHW_CIRCULATION_MODE: {
|
|
330
330
|
"disabled": 0,
|
|
331
331
|
"constant": 1,
|
|
332
332
|
"schedule": 2,
|
|
333
333
|
},
|
|
334
|
-
CompitParameter.
|
|
334
|
+
CompitParameter.BIOMAX_DHW_CIRCULATION_MODE: {
|
|
335
335
|
"disabled": 0,
|
|
336
336
|
"constant": 1,
|
|
337
337
|
"schedule": 2,
|
|
338
338
|
},
|
|
339
|
-
CompitParameter.
|
|
339
|
+
CompitParameter.R350_HEATING_SOURCE_OF_CORRECTION: {
|
|
340
340
|
"no_corrections": 1,
|
|
341
341
|
"schedule": 2,
|
|
342
342
|
"thermostat": 3,
|
|
@@ -18,7 +18,7 @@ class Param:
|
|
|
18
18
|
value_code: str | None,
|
|
19
19
|
value_label: str | None,
|
|
20
20
|
write: bool,
|
|
21
|
-
ext_info: dict | None = None,
|
|
21
|
+
ext_info: dict[str, Any] | None = None,
|
|
22
22
|
) -> None:
|
|
23
23
|
"""Initialize the Param object."""
|
|
24
24
|
self.code = code
|
|
@@ -95,7 +95,7 @@ class DeviceState:
|
|
|
95
95
|
return parameter is not None
|
|
96
96
|
|
|
97
97
|
@classmethod
|
|
98
|
-
def from_json(cls, data: dict):
|
|
98
|
+
def from_json(cls, data: dict[str, Any]):
|
|
99
99
|
"""Create a DeviceState object from JSON data."""
|
|
100
100
|
params = [
|
|
101
101
|
Param(
|
|
@@ -121,7 +121,7 @@ class DeviceState:
|
|
|
121
121
|
class DeviceInstance:
|
|
122
122
|
"""Class representing a device instance."""
|
|
123
123
|
|
|
124
|
-
def __init__(self, label: str, definition: Device) -> None:
|
|
124
|
+
def __init__(self, label: str, definition: Device | None) -> None:
|
|
125
125
|
"""Initialize the DeviceInstance object."""
|
|
126
126
|
self.label = label
|
|
127
127
|
self.definition = definition
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"""Module contains classes for system information.""" # noqa: INP001
|
|
2
2
|
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
class Device:
|
|
4
7
|
"""Class representing a device in the system."""
|
|
5
8
|
|
|
@@ -30,7 +33,7 @@ class SystemInfo:
|
|
|
30
33
|
self.gates = gates
|
|
31
34
|
|
|
32
35
|
@classmethod
|
|
33
|
-
def from_json(cls, data: dict):
|
|
36
|
+
def from_json(cls, data: dict[str, Any]):
|
|
34
37
|
"""Create a SystemInfo instance from JSON data."""
|
|
35
38
|
gates = [
|
|
36
39
|
Gate(
|
|
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
|