compit-inext-api-beta 0.4.0b10__tar.gz → 0.6.0b7__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 (25) hide show
  1. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/PKG-INFO +1 -1
  2. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/__init__.py +6 -2
  3. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/api.py +9 -9
  4. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/connector.py +75 -32
  5. compit_inext_api_beta-0.6.0b7/compit_inext_api/consts.py +177 -0
  6. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/definitions/devices_en.json +168 -1
  7. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/device_definitions.py +16 -3
  8. compit_inext_api_beta-0.6.0b7/compit_inext_api/params_dictionary.py +530 -0
  9. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/types/DeviceState.py +2 -2
  10. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/types/SystemInfo.py +4 -1
  11. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/PKG-INFO +1 -1
  12. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/pyproject.toml +1 -1
  13. compit_inext_api_beta-0.4.0b10/compit_inext_api/consts.py +0 -94
  14. compit_inext_api_beta-0.4.0b10/compit_inext_api/params_dictionary.py +0 -369
  15. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/LICENSE +0 -0
  16. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/README.md +0 -0
  17. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/definitions/__init__.py +0 -0
  18. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/definitions/devices_pl.json +0 -0
  19. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/py.typed +0 -0
  20. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/types/DeviceDefinitions.py +0 -0
  21. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/SOURCES.txt +0 -0
  22. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/dependency_links.txt +0 -0
  23. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/requires.txt +0 -0
  24. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/top_level.txt +0 -0
  25. {compit_inext_api_beta-0.4.0b10 → compit_inext_api_beta-0.6.0b7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compit-inext-api-beta
3
- Version: 0.4.0b10
3
+ Version: 0.6.0b7
4
4
  Summary: Compit Inext API - Python client
5
5
  Author: Przemyslaw Grzywa
6
6
  License: Apache-2.0
@@ -5,8 +5,9 @@ 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
+ from .params_dictionary import PARAMS, PARAM_VALUES
10
11
 
11
12
  __all__ = [
12
13
  "DeviceDefinitionsLoader",
@@ -22,9 +23,12 @@ __all__ = [
22
23
  "Device",
23
24
  "InvalidAuth",
24
25
  "CannotConnect",
26
+ "CompitDevice",
25
27
  "CompitHVACMode",
26
28
  "CompitParameter",
27
29
  "CompitFanMode",
28
30
  "CompitPresetMode",
29
- "CompitApiConnector"
31
+ "CompitApiConnector",
32
+ "PARAMS",
33
+ "PARAM_VALUES",
30
34
  ]
@@ -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."""
@@ -3,9 +3,9 @@ import logging
3
3
 
4
4
  from compit_inext_api.api import CompitAPI
5
5
  from compit_inext_api.consts import CompitParameter
6
- from compit_inext_api.params_dictionary import PARAMS
7
6
  from compit_inext_api.device_definitions import DeviceDefinitionsLoader
8
- from compit_inext_api.types.DeviceState import DeviceInstance, DeviceState, GateInstance, Param
7
+ from compit_inext_api.params_dictionary import PARAMS, PARAM_VALUES
8
+ from compit_inext_api.types.DeviceState import DeviceInstance, GateInstance, Param
9
9
 
10
10
 
11
11
  _LOGGER: logging.Logger = logging.getLogger(__package__)
@@ -18,7 +18,7 @@ class CompitApiConnector:
18
18
 
19
19
  @property
20
20
  def all_devices(self) -> dict[int, DeviceInstance]:
21
- devices = {}
21
+ devices: dict[int, DeviceInstance] = {}
22
22
  for gate in self.gates.values():
23
23
  devices.update(gate.devices)
24
24
  return devices
@@ -26,13 +26,23 @@ class CompitApiConnector:
26
26
  def __init__(self, session: aiohttp.ClientSession) -> None:
27
27
  self.session = session
28
28
 
29
+ def _resolve_parameter_code(self, device_code: int, parameter: CompitParameter) -> str:
30
+ mapping = PARAMS.get(parameter)
31
+ if not mapping:
32
+ return parameter.value
33
+
34
+ if device_code in mapping:
35
+ return mapping[device_code]
36
+
37
+ return parameter.value
38
+
29
39
  def get_device(self, device_id: int) -> DeviceInstance | None:
30
40
  for gate in self.gates.values():
31
41
  if device_id in gate.devices:
32
42
  return gate.devices[device_id]
33
43
  return None
34
44
 
35
- async def init(self, email: str, password: str, lang: str = "en") -> bool:
45
+ async def init(self, email: str, password: str, lang: str | None = None) -> bool:
36
46
  self.api = CompitAPI(email, password, self.session)
37
47
  self.systemInfo = await self.api.authenticate()
38
48
  if self.systemInfo is None:
@@ -43,7 +53,13 @@ class CompitApiConnector:
43
53
  self.gates[gates.id] = GateInstance(gates.id, gates.label)
44
54
  for device in gates.devices:
45
55
  try:
46
- self.gates[gates.id].devices[device.id] = DeviceInstance(device.label, await DeviceDefinitionsLoader.get_device_definition(device.type, lang))
56
+ self.gates[gates.id].devices[device.id] = DeviceInstance(
57
+ device.label,
58
+ await DeviceDefinitionsLoader.get_device_definition(
59
+ device.type,
60
+ lang=lang,
61
+ ),
62
+ )
47
63
  state = await self.api.get_state(device.id)
48
64
  if state:
49
65
  self.gates[gates.id].devices[device.id].state = state
@@ -71,54 +87,81 @@ class CompitApiConnector:
71
87
  else:
72
88
  _LOGGER.error("Failed to get state for device %s", device_id)
73
89
 
74
- def get_current_option(self, device_id: int, parameter: str | CompitParameter) -> str | None:
75
- if isinstance(parameter, str):
76
- parameter = CompitParameter(parameter)
90
+ def get_current_option(self, device_id: int, parameter: CompitParameter) -> str | None:
77
91
  device = self.get_device(device_id)
78
92
  if not device:
79
93
  return None
80
- val = device.state.get_parameter_value(parameter.value)
81
- param = PARAMS.get(parameter, None)
94
+
95
+ code = self._resolve_parameter_code(device.definition.code, parameter)
96
+ val = device.state.get_parameter_value(code)
97
+
98
+ if val is None:
99
+ return None
100
+
101
+ param = PARAM_VALUES.get(parameter, None)
82
102
  if param is None:
83
103
  return None
104
+
84
105
  for key, value in param.items():
85
- if value == val:
106
+ if value == val.value:
86
107
  return key
87
- return None
108
+
109
+ return None
88
110
 
89
- def get_device_parameter(self, device_id: int, parameter: str | CompitParameter) -> Param | str | None:
111
+ def get_device_parameter(self, device_id: int, parameter: CompitParameter) -> Param | None:
90
112
  device = self.get_device(device_id)
91
113
  if not device:
92
114
  return None
93
- return device.state.get_parameter_value(parameter if isinstance(parameter, str) else parameter.value)
115
+ code = self._resolve_parameter_code(device.definition.code, parameter)
116
+ param = device.state.get_parameter_value(code)
117
+ if param is None:
118
+ return None
119
+
120
+ if param.value_label is None:
121
+ return param
122
+
123
+ parameter_values = PARAM_VALUES.get(parameter, None)
94
124
 
95
- async def select_device_option(self, device_id: int, parameter: str | CompitParameter, value: str) -> bool:
96
- if isinstance(parameter, str):
97
- parameter = CompitParameter(parameter)
125
+ if parameter_values is None:
126
+ return param
98
127
 
99
- param = PARAMS.get(parameter, None)
100
- if param is None:
128
+ for key, value in parameter_values.items():
129
+ if value == param.value:
130
+ param.value = key
131
+ break
132
+
133
+ return param
134
+
135
+ async def select_device_option(self, device_id: int, parameter: CompitParameter, value: str) -> bool:
136
+ device = self.get_device(device_id)
137
+ if device is None:
101
138
  return False
102
- val = param.get(value, None)
139
+
140
+ code = self._resolve_parameter_code(device.definition.code, parameter)
141
+
142
+ val = PARAM_VALUES.get(parameter, None)
103
143
  if val is None:
104
144
  return False
105
- result = await self.api.update_device_parameter(device_id, parameter, val)
145
+
146
+ mapped_value = val.get(value, None)
147
+ if mapped_value is None:
148
+ return False
149
+
150
+ result = await self.api.update_device_parameter(device_id, code, mapped_value)
106
151
  if result is None:
107
152
  return False
108
-
153
+ device.state.set_parameter_value(code, mapped_value)
154
+ return result
155
+
156
+ async def set_device_parameter(self, device_id: int, parameter: CompitParameter, value: str | float) -> bool:
109
157
  device = self.get_device(device_id)
110
158
  if device is None:
111
159
  return False
112
-
113
- device.state.set_parameter_value(parameter if isinstance(parameter, str) else parameter.value, val)
114
- return result
160
+
161
+ code = self._resolve_parameter_code(device.definition.code, parameter)
115
162
 
116
- async def set_device_parameter(self, device_id: int, parameter: str | CompitParameter, value: str | float) -> bool:
117
- result = await self.api.update_device_parameter(device_id, parameter, value)
163
+ result = await self.api.update_device_parameter(device_id, code, value)
118
164
  if result:
119
- device = self.get_device(device_id)
120
- if device:
121
- device.state.set_parameter_value(parameter if isinstance(parameter, str) else parameter.value, value)
122
- return result
165
+ device.state.set_parameter_value(code, value)
123
166
 
124
-
167
+ return result
@@ -0,0 +1,177 @@
1
+ from enum import Enum
2
+
3
+
4
+ class CompitHVACMode(Enum):
5
+ """Enum for available HVAC modes."""
6
+
7
+ HEAT = 0
8
+ OFF = 1
9
+ COOL = 2
10
+
11
+ class CompitParameter(Enum):
12
+ """Enum for Compit device parameters."""
13
+ # Climate
14
+ CURRENT_TEMPERATURE = "CURRENT_TEMPERATURE"
15
+ SET_TARGET_TEMPERATURE = "SET_TARGET_TEMPERATURE"
16
+ FAN_MODE = "FAN_MODE"
17
+ PRESET_MODE = "PRESET_MODE"
18
+ HVAC_MODE = "HVAC_MODE"
19
+ TARGET_TEMPERATURE = "TARGET_TEMPERATURE"
20
+
21
+ # Select
22
+ AEROKONFBYPASS = "__aerokonfbypass"
23
+ DHW_CIRCULATION_MODE = "__cwucyrkpraca"
24
+ BIOMAX_HEATING_SOURCE_OF_CORRECTION = "__pracakotla"
25
+ BIOMAX_MIXER_MODE_ZONE_1 = "__m1praca"
26
+ BIOMAX_MIXER_MODE_ZONE_2 = "__m2praca"
27
+ BUFFER_MODE = "__tr_buf"
28
+ HEATING_SOURCE_OF_CORRECTION = "__comode"
29
+ LANGUAGE = "_jezyk"
30
+ NANO_MODE = "__nano_mode"
31
+ WORK_MODE = "__sezprinst"
32
+ OPERATING_MODE = "OPERATING_MODE"
33
+ R470_OPERATING_MODE = "__mode"
34
+ R480_OPERATING_MODE = "__praca_pc"
35
+ R490_OPERATING_MODE = "__trprpompyciepla"
36
+ R900_OPERATING_MODE = "__tr_pracy_pc"
37
+ SOLAR_COMP_OPERATING_MODE = "__trybpracy"
38
+ MIXER_MODE = "__pracamieszacza"
39
+
40
+ # Sensor
41
+ OUTDOOR_TEMPERATURE = "OUTDOOR_TEMPERATURE"
42
+ CO2_LEVEL = "CO2_LEVEL"
43
+ HUMIDITY = "HUMIDITY"
44
+ PM1_LEVEL = "PM1_LEVEL"
45
+ PM25_LEVEL = "PM25_LEVEL"
46
+ PM10_LEVEL = "PM10_LEVEL"
47
+ PM4_LEVEL = "PM4_LEVEL"
48
+ DUST_ALERT = "DUST_ALERT"
49
+ CO2_ALERT = "CO2_ALERT"
50
+ TEMPERATURE_ALERT = "TEMPERATURE_ALERT"
51
+ CO2_PERCENT = "CO2_PERCENT"
52
+ VENTILATION_ALARM = "VENTILATION_ALARM"
53
+ VENTILATION_GEAR = "VENTILATION_GEAR"
54
+ AIRING = "AIRING"
55
+ MIXER_TEMPERATURE = "MIXER_TEMPERATURE"
56
+ CIRCUIT_TARGET_TEMPERATURE = "CIRCUIT_TARGET_TEMPERATURE"
57
+ PROTECTION_TEMPERATURE = "PROTECTION_TEMPERATURE"
58
+ WEATHER_CURVE = "WEATHER_CURVE"
59
+ ENERGY_SGREADY_YESTERDAY = "ENERGY_SGREADY_YESTERDAY"
60
+ DHW_MEASURED_TEMPERATURE = "DHW_MEASURED_TEMPERATURE"
61
+ CALCULATED_TARGET_TEMPERATURE = "CALCULATED_TARGET_TEMPERATURE"
62
+ ENERGY_TOTAL = "ENERGY_TOTAL"
63
+ ENERGY_YESTERDAY = "ENERGY_YESTERDAY"
64
+ BOILER_TEMPERATURE = "BOILER_TEMPERATURE"
65
+ FUEL_LEVEL = "FUEL_LEVEL"
66
+ MIXER1_TEMPERATURE = "MIXER1_TEMPERATURE"
67
+ MIXER2_TEMPERATURE = "MIXER2_TEMPERATURE"
68
+ DHW_TEMPERATURE = "DHW_TEMPERATURE"
69
+ BUFFER_RETURN_TEMPERATURE = "BUFFER_RETURN_TEMPERATURE"
70
+ BUFFER_MEASURED_TEMPERATURE = "BUFFER_MEASURED_TEMPERATURE"
71
+ ACTUAL_BUFFER_TEMP = "ACTUAL_BUFFER_TEMP"
72
+ ACTUAL_DHW_TEMP = "ACTUAL_DHW_TEMP"
73
+ ACTUAL_UPPER_SOURCE_TEMP = "ACTUAL_UPPER_SOURCE_TEMP"
74
+ CALCULATED_BUFFER_TEMP = "CALCULATED_BUFFER_TEMP"
75
+ CALCULATED_DHW_TEMP = "CALCULATED_DHW_TEMP"
76
+ CALCULATED_UPPER_SOURCE_TEMP = "CALCULATED_UPPER_SOURCE_TEMP"
77
+ ACTUAL_CO1_TEMPERATURE = "ACTUAL_CO1_TEMPERATURE"
78
+ ACTUAL_CO2_TEMPERATURE = "ACTUAL_CO2_TEMPERATURE"
79
+ ACTUAL_CO3_TEMPERATURE = "ACTUAL_CO3_TEMPERATURE"
80
+ ACTUAL_CO4_TEMPERATURE = "ACTUAL_CO4_TEMPERATURE"
81
+ HEATING1_TARGET_TEMPERATURE = "HEATING1_TARGET_TEMPERATURE"
82
+ HEATING2_TARGET_TEMPERATURE = "HEATING2_TARGET_TEMPERATURE"
83
+ HEATING3_TARGET_TEMPERATURE = "HEATING3_TARGET_TEMPERATURE"
84
+ HEATING4_TARGET_TEMPERATURE = "HEATING4_TARGET_TEMPERATURE"
85
+ ALARM_CODE = "ALARM_CODE"
86
+ BATTERY_LEVEL = "BATTERY_LEVEL"
87
+ BATTERY_CHARGE_STATUS = "BATTERY_CHARGE_STATUS"
88
+ CHARGING_POWER = "CHARGING_POWER"
89
+ PUMP_STATUS = "PUMPE_STATUS"
90
+ RETURN_CIRCUT_TEMPERATURE = "RETURN_CIRCUT_TEMPERATURE"
91
+ HAS_BATTERY = "HAS_BATTERY"
92
+ HAS_EXTERNAL_POWER = "HAS_EXTERNAL_POWER"
93
+ CALCULATED_HEATING_TEMPERATURE = "CALCULATED_HEATING_TEMPERATURE"
94
+ TARGET_HEATING_TEMPERATURE = "TARGET_HEATING_TEMPERATURE"
95
+ CURRENT_HEATING_TEMP = "CURRENT_HEATING_TEMP"
96
+ RETURN_CIRCUIT_TEMPERATURE = "RETURN_CIRCUIT_TEMPERATURE"
97
+ COLLECTOR_TEMPERATURE = "COLLECTOR_TEMPERATURE"
98
+ TANK_BOTTOM_T2_TEMPERATURE = "TANK_BOTTOM_T2_TEMPERATURE"
99
+ TANK_TOP_T3_TEMPERATURE = "TANK_TOP_T3_TEMPERATURE"
100
+ COLLECTOR_POWER = "COLLECTOR_POWER"
101
+ BUFFER_SET_TEMPERATURE = "BUFFER_SET_TEMPERATURE"
102
+ ENERGY_TODAY = "ENERGY_TODAY"
103
+ TANK_T4_TEMPERATURE = "TANK_T4_TEMPERATURE"
104
+ UPPER_SOURCE_TEMPERATURE = "UPPER_SOURCE_TEMPERATURE"
105
+ LOWER_SOURCE_TEMPERATURE = "LOWER_SOURCE_TEMPERATURE"
106
+ CO_PUMP_ON_DELAY = "CO_PUMP_ON_DELAY"
107
+ CO_PUMP_OFF_DELAY = "CO_PUMP_OFF_DELAY"
108
+ PK1_FUNCTION = "PK1_FUNCTION"
109
+
110
+ class CompitFanMode(Enum):
111
+ """Enum for available fan modes."""
112
+
113
+ OFF = 0
114
+ LOW = 1
115
+ MEDIUM = 2
116
+ HIGH = 3
117
+ HOLIDAY = 4
118
+ AUTO = 5
119
+
120
+ class CompitPresetMode(Enum):
121
+ """Enum for available preset modes."""
122
+
123
+ AUTO = 0
124
+ HOLIDAY = 1
125
+ MANUAL = 2
126
+ AWAY = 3
127
+
128
+ class CompitDevice(Enum):
129
+ """Enum for Compit devices.
130
+
131
+ The enum value is the device `Code`, so you can look up a device by code:
132
+ `CompitDevice(223) -> CompitDevice.NANO_COLOR_2`.
133
+
134
+ Each member also exposes:
135
+ - `label`: original device name
136
+ - `device_class`: device class id
137
+ """
138
+
139
+ label: str
140
+ device_class: int
141
+
142
+ def __new__(cls, label: str, code: int, device_class: int):
143
+ obj = object.__new__(cls)
144
+ obj._value_ = code
145
+ obj.label = label
146
+ obj.device_class = device_class
147
+ return obj
148
+
149
+ AF_1 = ("AF-1", 226, 48)
150
+ BIOMAX742_2 = ("BioMax742", 36, 15)
151
+ BIOMAX742 = ("BioMax742", 212, 15)
152
+ BIOMAX772 = ("BioMax772", 75, 15)
153
+ BIOMAX775 = ("BioMax775", 201, 15)
154
+ BWC310 = ("BWC310", 14, 69)
155
+ COMBO = ("COMBO", 227, 49)
156
+ COMBO_PRO = ("COMBO PRO", 229, 37)
157
+ EL750 = ("EL750", 210, 29)
158
+ L2 = ("L2", 17, 12)
159
+ NANO_COLOR = ("Nano Color", 12, 10)
160
+ NANO_COLOR_2 = ("Nano Color 2", 223, 10)
161
+ NANO_ONE = ("Nano One", 7, 10)
162
+ R_900 = ("R 900", 224, 47)
163
+ R350CWU = ("R350.CWU", 53, 36)
164
+ R350M = ("R350.M", 221, 14)
165
+ R350_T3 = ("R350 T3", 5, 14)
166
+ R470 = ("r470", 34, 16)
167
+ R480 = ("R480", 215, 43)
168
+ R490 = ("r490", 92, 33)
169
+ R770RS_R771RS = ("R770RS / R771RS", 91, 25)
170
+ R810 = ("R810", 3, 14)
171
+ R810_1 = ("R810", 222, 34)
172
+ CO2_SHC = ("SHC", 27, 15)
173
+ SOLARCOMP_951 = ("SolarComp 951", 44, 18)
174
+ SOLARCOMP971 = ("SolarComp971", 45, 18)
175
+ SPM_NANO_COLOR = ("SPM - Nano Color", 225, 27)
176
+ SPM_NANO_COLOR2 = ("SPM - Nano Color2", 0, 46)
177
+ SPM_NANO_COLOR2_1 = ("SPM - Nano Color2", 78, 46)
@@ -1,6 +1,6 @@
1
1
  [
2
2
  {
3
- "Name": "Nano Color 3",
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 = "en") -> Device:
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: