compit-inext-api-beta 0.2.1__tar.gz → 0.4.0b2__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 (27) hide show
  1. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/PKG-INFO +3 -1
  2. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/api.py +2 -2
  3. compit_inext_api_beta-0.4.0b2/compit_inext_api/connector.py +95 -0
  4. compit_inext_api_beta-0.4.0b2/compit_inext_api/consts.py +94 -0
  5. compit_inext_api_beta-0.4.0b2/compit_inext_api/definitions/devices_en.json +35201 -0
  6. compit_inext_api_beta-0.4.0b2/compit_inext_api/definitions/devices_pl.json +32707 -0
  7. compit_inext_api_beta-0.4.0b2/compit_inext_api/params_dictionary.py +369 -0
  8. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/types/DeviceDefinitions.py +4 -1
  9. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/types/DeviceState.py +11 -1
  10. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api_beta.egg-info/PKG-INFO +3 -1
  11. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api_beta.egg-info/SOURCES.txt +2 -0
  12. compit_inext_api_beta-0.4.0b2/compit_inext_api_beta.egg-info/requires.txt +2 -0
  13. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/pyproject.toml +6 -3
  14. compit_inext_api_beta-0.2.1/compit_inext_api/connector.py +0 -66
  15. compit_inext_api_beta-0.2.1/compit_inext_api/consts.py +0 -37
  16. compit_inext_api_beta-0.2.1/compit_inext_api/definitions/devices_en.json +0 -32290
  17. compit_inext_api_beta-0.2.1/compit_inext_api/definitions/devices_pl.json +0 -32291
  18. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/LICENSE +0 -0
  19. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/README.md +0 -0
  20. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/__init__.py +0 -0
  21. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/definitions/__init__.py +0 -0
  22. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/device_definitions.py +0 -0
  23. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/py.typed +0 -0
  24. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api/types/SystemInfo.py +0 -0
  25. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api_beta.egg-info/dependency_links.txt +0 -0
  26. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/compit_inext_api_beta.egg-info/top_level.txt +0 -0
  27. {compit_inext_api_beta-0.2.1 → compit_inext_api_beta-0.4.0b2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compit-inext-api-beta
3
- Version: 0.2.1
3
+ Version: 0.4.0b2
4
4
  Summary: Compit Inext API - Python client
5
5
  Author: Przemyslaw Grzywa
6
6
  License: Apache-2.0
@@ -10,6 +10,8 @@ Project-URL: issues, https://github.com/Przemko92/compit-inext-api/issues
10
10
  Requires-Python: >=3.12
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
+ Requires-Dist: aiofiles
14
+ Requires-Dist: aiohttp
13
15
  Dynamic: license-file
14
16
 
15
17
  # Compit inext api
@@ -91,7 +91,7 @@ class CompitAPI:
91
91
  return None
92
92
 
93
93
  async def update_device_parameter(
94
- self, device_id: int, parameter: CompitParameter, value: str | float
94
+ self, device_id: int, parameter: CompitParameter | str, value: str | float
95
95
  ) -> Any:
96
96
  """Update the parameter of a device.
97
97
 
@@ -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, "value": value}]}
110
+ data = {"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
@@ -0,0 +1,95 @@
1
+ import aiohttp
2
+ import logging
3
+
4
+ from compit_inext_api.api import CompitAPI
5
+ from compit_inext_api.consts import CompitParameter
6
+ from compit_inext_api.params_dictionary import PARAMS
7
+ from compit_inext_api.device_definitions import DeviceDefinitionsLoader
8
+ from compit_inext_api.types.DeviceState import DeviceInstance, DeviceState, GateInstance, Param
9
+
10
+
11
+ _LOGGER: logging.Logger = logging.getLogger(__package__)
12
+
13
+
14
+ class CompitApiConnector:
15
+ """Connector class for Compit API."""
16
+
17
+ gates: dict[int, GateInstance] = {}
18
+
19
+ @property
20
+ def all_devices(self) -> dict[int, DeviceInstance]:
21
+ devices = {}
22
+ for gate in self.gates.values():
23
+ devices.update(gate.devices)
24
+ return devices
25
+
26
+ def __init__(self, session: aiohttp.ClientSession) -> None:
27
+ self.session = session
28
+
29
+ def get_device(self, device_id: int) -> DeviceInstance | None:
30
+ for gate in self.gates.values():
31
+ if device_id in gate.devices:
32
+ return gate.devices[device_id]
33
+ return None
34
+
35
+ async def init(self, email: str, password: str, lang: str = "en") -> bool:
36
+ self.api = CompitAPI(email, password, self.session)
37
+ self.systemInfo = await self.api.authenticate()
38
+ if self.systemInfo is None:
39
+ _LOGGER.error("Failed to authenticate with Compit API")
40
+ return False
41
+
42
+ for gates in self.systemInfo.gates:
43
+ self.gates[gates.id] = GateInstance(gates.id, gates.label)
44
+ for device in gates.devices:
45
+ try:
46
+ self.gates[gates.id].devices[device.id] = DeviceInstance(device.label, await DeviceDefinitionsLoader.get_device_definition(device.type, lang))
47
+ state = await self.api.get_state(device.id)
48
+ if state and isinstance(state, DeviceState):
49
+ self.gates[gates.id].devices[device.id].state = state
50
+ else:
51
+ _LOGGER.error("Failed to get state for device %s", device.id)
52
+ except ValueError:
53
+ _LOGGER.warning("No definition found for device with code %d", device.type)
54
+ return True
55
+
56
+ async def update_state(self, device_id: int | None) -> None:
57
+ if device_id is None:
58
+ for gate in self.gates.values():
59
+ for device in gate.devices.keys():
60
+ await self.update_state(device)
61
+ return
62
+
63
+ device = self.get_device(device_id)
64
+ if device is None:
65
+ _LOGGER.warning("No device found with ID %d", device_id)
66
+ return
67
+
68
+ state = await self.api.get_state(device_id)
69
+ if state:
70
+ device.state = state
71
+ else:
72
+ _LOGGER.error("Failed to get state for device %s", device_id)
73
+
74
+ def get_device_parameter(self, device_id: int, parameter: str | CompitParameter) -> Param | None:
75
+ device = self.get_device(device_id)
76
+ if device:
77
+ return device.state.get_parameter_value(parameter if isinstance(parameter, str) else parameter.value)
78
+ return None
79
+
80
+ async def set_device_parameter(self, device_id: int, parameter: str | CompitParameter, value: str | float) -> bool:
81
+ if isinstance(parameter, CompitParameter) and isinstance(value, str):
82
+ param = PARAMS.get(parameter, None)
83
+ if param is not None:
84
+ val = param.get(value, None)
85
+ if val is not None:
86
+ value = val
87
+
88
+ result = await self.api.update_device_parameter(device_id, parameter, value)
89
+ if result:
90
+ device = self.get_device(device_id)
91
+ if device:
92
+ device.state.set_parameter_value(parameter if isinstance(parameter, str) else parameter.value, value)
93
+ return result
94
+
95
+
@@ -0,0 +1,94 @@
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
+
14
+ AEROKONFBYPASS = "__aerokonfbypass"
15
+ AIRING_PROGRAM_ZONE_3 = "__a3programwietrzenia"
16
+ AIRING_PROGRAM_ZONE_4 = "__a4programwietrzenia"
17
+ AIRING_PROGRAM_ZONE_5 = "__a5prwietrz"
18
+ BIOMAX775_CIRCULATION_MODE = "__trybcyrkulacji"
19
+ BIOMAX775_DHW_CIRCULATION_MODE = "__cwucyrkpraca"
20
+ BIOMAX775_DHW_MODE = "__cwupraca"
21
+ BIOMAX775_HEATING_SOURCE_OF_CORRECTION_ZONE = "__pracakotla"
22
+ BIOMAX775_MIXER_MODE_ZONE_1 = "__m1praca"
23
+ BIOMAX775_MIXER_MODE_ZONE_2 = "__m2praca"
24
+ BUFFER_MODE = "__trprbufora"
25
+ CIRCUIT_MODE_HEATING_ZONE_1 = "__typ_obwo_co1"
26
+ CIRCUIT_MODE_HEATING_ZONE_2 = "__typ_obwo_co2"
27
+ CIRCUIT_MODE_HEATING_ZONE_3 = "__typ_obwo_co3"
28
+ CIRCUIT_MODE_HEATING_ZONE_4 = "__typ_obwo_co4"
29
+ CURRENT_TEMPERATURE = "__tpokojowa"
30
+ DHW_CIRCULATION_MODE = "__dhwcircmode"
31
+ DHW_MODE = "__dhwmode"
32
+ DHW_OPERATING_MODE = "__trybprcwu"
33
+ DHWC_CIRCULATION = "__cyrk_cwu"
34
+ FAN_MODE = "__trybaero"
35
+ HEATING_MODE_ZONE_1 = "__tr_pr_co1"
36
+ HEATING_MODE_ZONE_2 = "__tr_pr_co2"
37
+ HEATING_MODE_ZONE_3 = "__tr_pr_co3"
38
+ HEATING_MODE_ZONE_4 = "__tr_pr_co4"
39
+ HEATING_OPERATING_MODE_ZONE_1 = "__trprco1"
40
+ HEATING_OPERATING_MODE_ZONE_2 = "__trprco2"
41
+ HEATING_OPERATING_MODE_ZONE_3 = "__trprco3"
42
+ HEATING_OPERATING_MODE_ZONE_4 = "__trprco4"
43
+ HEATING_SOURCE_OF_CORRECTION_ZONE = "__comode"
44
+ HEATING_SOURCE_OF_CORRECTION_ZONE_1 = "__co1zrodlokorekty"
45
+ HEATING_SOURCE_OF_CORRECTION_ZONE_2 = "_co2zrodlokorekty"
46
+ HEATING_SOURCE_OF_CORRECTION_ZONE_3 = "__co3zrodlokorekty"
47
+ HEATING_SOURCE_OF_CORRECTION_ZONE_4 = "__co4zrkorekty"
48
+ HVAC_MODE = "__trybpracyinstalacji"
49
+ LANGUAGE = "_jezyk"
50
+ MIXER_MODE = "__pracamieszacza"
51
+ MIXERMODE_ZONE_1 = "__mixer1mode"
52
+ NANO_MODE = "__nano_mode"
53
+ OPERATING_MODE = "__tr_pracy_pc"
54
+ PRE_HEATER_ZONE_3 = "__a3konfignagwst"
55
+ PRE_HEATER_ZONE_5 = "__a5trybnagrzwst"
56
+ PRESET_MODE = "__trybpracytermostatu"
57
+ R350_HEATING_SOURCE_OF_CORRECTION_ZONE = "__tr_pr"
58
+ R470_OPERATING_MODE = "__mode"
59
+ R480_BUFFER_MODE = "__tr_buf"
60
+ R480_DHW_CIRCULATION = "__cwu_cyrkulacja"
61
+ R480_DHW_MODE = "__tryb_cwu"
62
+ R480_OPERATING_MODE = "__praca_pc"
63
+ R490_OPERATING_MODE = "__sezprinst"
64
+ R770_DHW_CIRCULATION_MODE = "__trybpracycyrkcwu"
65
+ R770_DHW_OPERATING_MODE = "__trybpracycwu"
66
+ R770_MIXER_MODE_ZONE_1 = "__trybmieszacza"
67
+ R770_MIXER_MODE_ZONE_2 = "__trybmie2"
68
+ SECONDARY_HEATER_ZONE_3 = "__a3konfignagwt"
69
+ SECONDARY_HEATER_ZONE_5 = "__a5trnagrzgl"
70
+ SET_TARGET_TEMPERATURE = "__tempzadpracareczna"
71
+ SOLAR_COMP_OPERATING_MODE = "__trybpracy"
72
+ TARGET_TEMPERATURE = "__tpokzadana"
73
+ TRYBAERO2 = "__trybaero2"
74
+ VENTILATION_COMFORT_ZONE = "__wentkomfort"
75
+ VENTILATION_ECO_ZONE = "__wenteko"
76
+ VENTILATION_HOLIDAY_MODE = "__wenturlop"
77
+
78
+ class CompitFanMode(Enum):
79
+ """Enum for available fan modes."""
80
+
81
+ OFF = 0
82
+ LOW = 1
83
+ MEDIUM = 2
84
+ HIGH = 3
85
+ HOLIDAY = 4
86
+ AUTO = 5
87
+
88
+ class CompitPresetMode(Enum):
89
+ """Enum for available preset modes."""
90
+
91
+ AUTO = 0
92
+ HOLIDAY = 1
93
+ MANUAL = 2
94
+ AWAY = 3