compit-inext-api-beta 0.4.3b2__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.3b2 → compit_inext_api_beta-0.6.0b7}/PKG-INFO +1 -1
  2. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/__init__.py +4 -1
  3. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/connector.py +61 -31
  4. compit_inext_api_beta-0.6.0b7/compit_inext_api/consts.py +177 -0
  5. compit_inext_api_beta-0.6.0b7/compit_inext_api/params_dictionary.py +530 -0
  6. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/types/DeviceState.py +1 -1
  7. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/PKG-INFO +1 -1
  8. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/pyproject.toml +1 -1
  9. compit_inext_api_beta-0.4.3b2/compit_inext_api/consts.py +0 -145
  10. compit_inext_api_beta-0.4.3b2/compit_inext_api/params_dictionary.py +0 -369
  11. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/LICENSE +0 -0
  12. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/README.md +0 -0
  13. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/api.py +0 -0
  14. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/definitions/__init__.py +0 -0
  15. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/definitions/devices_en.json +0 -0
  16. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/definitions/devices_pl.json +0 -0
  17. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/device_definitions.py +0 -0
  18. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/py.typed +0 -0
  19. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/types/DeviceDefinitions.py +0 -0
  20. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api/types/SystemInfo.py +0 -0
  21. {compit_inext_api_beta-0.4.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/SOURCES.txt +0 -0
  22. {compit_inext_api_beta-0.4.3b2 → 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.3b2 → compit_inext_api_beta-0.6.0b7}/compit_inext_api_beta.egg-info/requires.txt +0 -0
  24. {compit_inext_api_beta-0.4.3b2 → 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.3b2 → 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.3b2
3
+ Version: 0.6.0b7
4
4
  Summary: Compit Inext API - Python client
5
5
  Author: Przemyslaw Grzywa
6
6
  License: Apache-2.0
@@ -7,6 +7,7 @@ from .types.DeviceDefinitions import DeviceDefinitions, Parameter, ParameterDeta
7
7
  from .types.SystemInfo import SystemInfo, Gate, Device
8
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",
@@ -27,5 +28,7 @@ __all__ = [
27
28
  "CompitParameter",
28
29
  "CompitFanMode",
29
30
  "CompitPresetMode",
30
- "CompitApiConnector"
31
+ "CompitApiConnector",
32
+ "PARAMS",
33
+ "PARAM_VALUES",
31
34
  ]
@@ -3,9 +3,8 @@ 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.params_dictionary import PARAMS
7
+ from compit_inext_api.params_dictionary import PARAMS, PARAM_VALUES
9
8
  from compit_inext_api.types.DeviceState import DeviceInstance, GateInstance, Param
10
9
 
11
10
 
@@ -27,6 +26,16 @@ class CompitApiConnector:
27
26
  def __init__(self, session: aiohttp.ClientSession) -> None:
28
27
  self.session = session
29
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
+
30
39
  def get_device(self, device_id: int) -> DeviceInstance | None:
31
40
  for gate in self.gates.values():
32
41
  if device_id in gate.devices:
@@ -78,60 +87,81 @@ class CompitApiConnector:
78
87
  else:
79
88
  _LOGGER.error("Failed to get state for device %s", device_id)
80
89
 
81
- def get_current_option(self, device_id: int, parameter: str | CompitParameter) -> str | None:
82
- if isinstance(parameter, str):
83
- parameter = CompitParameter(parameter)
90
+ def get_current_option(self, device_id: int, parameter: CompitParameter) -> str | None:
84
91
  device = self.get_device(device_id)
85
92
  if not device:
86
93
  return None
87
-
88
- param = PARAMS.get(parameter, None)
89
- if param is None:
90
- return None
94
+
95
+ code = self._resolve_parameter_code(device.definition.code, parameter)
96
+ val = device.state.get_parameter_value(code)
91
97
 
92
- val = device.state.get_parameter_value(parameter.value)
93
98
  if val is None:
94
99
  return None
95
100
 
101
+ param = PARAM_VALUES.get(parameter, None)
102
+ if param is None:
103
+ return None
104
+
96
105
  for key, value in param.items():
97
106
  if value == val.value:
98
107
  return key
99
108
 
100
- return None
109
+ return None
101
110
 
102
- 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:
103
112
  device = self.get_device(device_id)
104
113
  if not device:
105
114
  return None
106
- 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)
107
124
 
108
- async def select_device_option(self, device_id: int, parameter: str | CompitParameter, value: str) -> bool:
109
- if isinstance(parameter, str):
110
- parameter = CompitParameter(parameter)
125
+ if parameter_values is None:
126
+ return param
111
127
 
112
- param = PARAMS.get(parameter, None)
113
- 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:
114
138
  return False
115
- val = param.get(value, None)
139
+
140
+ code = self._resolve_parameter_code(device.definition.code, parameter)
141
+
142
+ val = PARAM_VALUES.get(parameter, None)
116
143
  if val is None:
117
144
  return False
118
- 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)
119
151
  if result is None:
120
152
  return False
121
-
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:
122
157
  device = self.get_device(device_id)
123
158
  if device is None:
124
159
  return False
125
-
126
- device.state.set_parameter_value(parameter if isinstance(parameter, str) else parameter.value, val)
127
- return result
160
+
161
+ code = self._resolve_parameter_code(device.definition.code, parameter)
128
162
 
129
- async def set_device_parameter(self, device_id: int, parameter: str | CompitParameter, value: str | float) -> bool:
130
- result = await self.api.update_device_parameter(device_id, parameter, value)
163
+ result = await self.api.update_device_parameter(device_id, code, value)
131
164
  if result:
132
- device = self.get_device(device_id)
133
- if device:
134
- device.state.set_parameter_value(parameter if isinstance(parameter, str) else parameter.value, value)
135
- return result
165
+ device.state.set_parameter_value(code, value)
136
166
 
137
-
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)