electrolux-group-developer-sdk 0.1.0__py3-none-any.whl
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.
- electrolux_group_developer_sdk/__init__.py +0 -0
- electrolux_group_developer_sdk/appliance_config/__init__.py +0 -0
- electrolux_group_developer_sdk/appliance_config/ac_config.py +167 -0
- electrolux_group_developer_sdk/appliance_config/ap_config.py +204 -0
- electrolux_group_developer_sdk/appliance_config/config.py +31 -0
- electrolux_group_developer_sdk/appliance_config/cr_config.py +156 -0
- electrolux_group_developer_sdk/appliance_config/dam_ac_config.py +112 -0
- electrolux_group_developer_sdk/appliance_config/dh_config.py +104 -0
- electrolux_group_developer_sdk/appliance_config/dw_config.py +120 -0
- electrolux_group_developer_sdk/appliance_config/hb_config.py +166 -0
- electrolux_group_developer_sdk/appliance_config/hd_config.py +137 -0
- electrolux_group_developer_sdk/appliance_config/ov_config.py +230 -0
- electrolux_group_developer_sdk/appliance_config/rvc_config.py +217 -0
- electrolux_group_developer_sdk/appliance_config/so_config.py +277 -0
- electrolux_group_developer_sdk/appliance_config/td_config.py +120 -0
- electrolux_group_developer_sdk/appliance_config/wd_config.py +247 -0
- electrolux_group_developer_sdk/appliance_config/wm_config.py +246 -0
- electrolux_group_developer_sdk/auth/__init__.py +0 -0
- electrolux_group_developer_sdk/auth/auth_data.py +5 -0
- electrolux_group_developer_sdk/auth/invalid_credentials_exception.py +5 -0
- electrolux_group_developer_sdk/auth/invalid_token_exception.py +5 -0
- electrolux_group_developer_sdk/auth/token_manager.py +130 -0
- electrolux_group_developer_sdk/cli_test.py +139 -0
- electrolux_group_developer_sdk/client/__init__.py +0 -0
- electrolux_group_developer_sdk/client/appliance_client.py +447 -0
- electrolux_group_developer_sdk/client/appliance_data_factory.py +71 -0
- electrolux_group_developer_sdk/client/appliances/__init__.py +0 -0
- electrolux_group_developer_sdk/client/appliances/ac_appliance.py +113 -0
- electrolux_group_developer_sdk/client/appliances/ap_appliance.py +85 -0
- electrolux_group_developer_sdk/client/appliances/appliance_data.py +18 -0
- electrolux_group_developer_sdk/client/appliances/cr_appliance.py +105 -0
- electrolux_group_developer_sdk/client/appliances/dam_ac_appliance.py +113 -0
- electrolux_group_developer_sdk/client/appliances/dh_appliance.py +100 -0
- electrolux_group_developer_sdk/client/appliances/dw_appliance.py +107 -0
- electrolux_group_developer_sdk/client/appliances/hb_appliance.py +135 -0
- electrolux_group_developer_sdk/client/appliances/hd_appliance.py +132 -0
- electrolux_group_developer_sdk/client/appliances/ov_appliance.py +174 -0
- electrolux_group_developer_sdk/client/appliances/rvc_appliance.py +162 -0
- electrolux_group_developer_sdk/client/appliances/so_appliance.py +172 -0
- electrolux_group_developer_sdk/client/appliances/td_appliance.py +107 -0
- electrolux_group_developer_sdk/client/appliances/wd_appliance.py +207 -0
- electrolux_group_developer_sdk/client/appliances/wm_appliance.py +207 -0
- electrolux_group_developer_sdk/client/client_exception.py +6 -0
- electrolux_group_developer_sdk/client/client_util.py +80 -0
- electrolux_group_developer_sdk/client/dto/__init__.py +0 -0
- electrolux_group_developer_sdk/client/dto/appliance.py +9 -0
- electrolux_group_developer_sdk/client/dto/appliance_details.py +18 -0
- electrolux_group_developer_sdk/client/dto/appliance_state.py +10 -0
- electrolux_group_developer_sdk/client/dto/interactive_map.py +24 -0
- electrolux_group_developer_sdk/client/dto/livestream_config.py +11 -0
- electrolux_group_developer_sdk/client/dto/memory_map.py +14 -0
- electrolux_group_developer_sdk/client/failed_connection_exception.py +5 -0
- electrolux_group_developer_sdk/client/rate_limiter.py +35 -0
- electrolux_group_developer_sdk/config.py +12 -0
- electrolux_group_developer_sdk/constants.py +79 -0
- electrolux_group_developer_sdk/feature_constants.py +132 -0
- electrolux_group_developer_sdk-0.1.0.dist-info/METADATA +102 -0
- electrolux_group_developer_sdk-0.1.0.dist-info/RECORD +60 -0
- electrolux_group_developer_sdk-0.1.0.dist-info/WHEEL +4 -0
- electrolux_group_developer_sdk-0.1.0.dist-info/licenses/LICENSE +201 -0
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Air conditioner configuration."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from .config import ApplianceConfig
|
|
5
|
+
from ..constants import VALUES, MAX, MIN, FAHRENHEIT, STEP, AC, CA, AZUL, BOGONG, PANTHER, TELICA
|
|
6
|
+
from ..feature_constants import *
|
|
7
|
+
|
|
8
|
+
# Configuration
|
|
9
|
+
AC_CONFIG = {
|
|
10
|
+
AC: {
|
|
11
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
12
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
13
|
+
FAN_SPEED_SETTING: "fanSpeedSetting",
|
|
14
|
+
MODE: "mode",
|
|
15
|
+
AMBIENT_TEMPERATURE_C: "ambientTemperatureC",
|
|
16
|
+
AMBIENT_TEMPERATURE_F: "ambientTemperatureF",
|
|
17
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
18
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
19
|
+
APPLIANCE_STATE: "applianceState"
|
|
20
|
+
},
|
|
21
|
+
CA: {
|
|
22
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
23
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
24
|
+
FAN_SPEED_SETTING: "fanSpeedSetting",
|
|
25
|
+
MODE: "mode",
|
|
26
|
+
AMBIENT_TEMPERATURE_C: "ambientTemperatureC",
|
|
27
|
+
AMBIENT_TEMPERATURE_F: "ambientTemperatureF",
|
|
28
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
29
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
30
|
+
APPLIANCE_STATE: "applianceState"
|
|
31
|
+
},
|
|
32
|
+
AZUL: {
|
|
33
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
34
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
35
|
+
FAN_SPEED_SETTING: "fanSpeedSetting",
|
|
36
|
+
MODE: "mode",
|
|
37
|
+
AMBIENT_TEMPERATURE_C: "ambientTemperatureC",
|
|
38
|
+
AMBIENT_TEMPERATURE_F: "ambientTemperatureF",
|
|
39
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
40
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
41
|
+
APPLIANCE_STATE: "applianceState"
|
|
42
|
+
},
|
|
43
|
+
BOGONG: {
|
|
44
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
45
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
46
|
+
FAN_SPEED_SETTING: "fanSpeedSetting",
|
|
47
|
+
MODE: "mode",
|
|
48
|
+
AMBIENT_TEMPERATURE_C: "ambientTemperatureC",
|
|
49
|
+
AMBIENT_TEMPERATURE_F: "ambientTemperatureF",
|
|
50
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
51
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
52
|
+
APPLIANCE_STATE: "applianceState"
|
|
53
|
+
},
|
|
54
|
+
PANTHER: {
|
|
55
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
56
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
57
|
+
FAN_SPEED_SETTING: "fanSpeedSetting",
|
|
58
|
+
MODE: "mode",
|
|
59
|
+
AMBIENT_TEMPERATURE_C: "ambientTemperatureC",
|
|
60
|
+
AMBIENT_TEMPERATURE_F: "ambientTemperatureF",
|
|
61
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
62
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
63
|
+
APPLIANCE_STATE: "applianceState"
|
|
64
|
+
},
|
|
65
|
+
TELICA: {
|
|
66
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
67
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
68
|
+
FAN_SPEED_SETTING: "fanSpeedSetting",
|
|
69
|
+
MODE: "mode",
|
|
70
|
+
AMBIENT_TEMPERATURE_C: "ambientTemperatureC",
|
|
71
|
+
AMBIENT_TEMPERATURE_F: "ambientTemperatureF",
|
|
72
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
73
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
74
|
+
APPLIANCE_STATE: "applianceState"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class AcConfig(ApplianceConfig):
|
|
80
|
+
"""Config for AC devices."""
|
|
81
|
+
|
|
82
|
+
def get_supported_modes(self) -> list[str]:
|
|
83
|
+
"""Get appliance modes."""
|
|
84
|
+
key = self.get_property(MODE)
|
|
85
|
+
values = self.capabilities.get(key, {}).get(VALUES, {})
|
|
86
|
+
return list(values.keys())
|
|
87
|
+
|
|
88
|
+
def get_supported_fan_speeds(self) -> list[str]:
|
|
89
|
+
"""Get appliance fan speeds."""
|
|
90
|
+
key = self.get_property(FAN_SPEED_SETTING)
|
|
91
|
+
values = self.capabilities.get(key, {}).get(VALUES, {})
|
|
92
|
+
return list(values.keys())
|
|
93
|
+
|
|
94
|
+
def _get_target_temperature_f_capability(self) -> dict[str, Any]:
|
|
95
|
+
"""Get target temperature F capability."""
|
|
96
|
+
return self.capabilities.get(
|
|
97
|
+
self.get_property(TARGET_TEMPERATURE_F)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
def _get_target_temperature_c_capability(self) -> dict[str, Any]:
|
|
101
|
+
"""Get target temperature C capability."""
|
|
102
|
+
return self.capabilities.get(
|
|
103
|
+
self.get_property(TARGET_TEMPERATURE_C)
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def get_supported_min_temp(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
107
|
+
"""Get MIN temperature based on the current unit. The default is CELSIUS."""
|
|
108
|
+
if self.get_current_temperature_unit(reported_appliance_state) == FAHRENHEIT:
|
|
109
|
+
return self._get_target_temperature_f_capability().get(MIN)
|
|
110
|
+
return self._get_target_temperature_c_capability().get(MIN)
|
|
111
|
+
|
|
112
|
+
def get_supported_max_temp(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
113
|
+
"""Get MAX temperature based on the current unit. The default is CELSIUS."""
|
|
114
|
+
if self.get_current_temperature_unit(reported_appliance_state) == FAHRENHEIT:
|
|
115
|
+
return self._get_target_temperature_f_capability().get(MAX)
|
|
116
|
+
return self._get_target_temperature_c_capability().get(MAX)
|
|
117
|
+
|
|
118
|
+
def get_supported_step_temp(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
119
|
+
"""Get temperature STEP based on the current unit. The default is CELSIUS."""
|
|
120
|
+
if self.get_current_temperature_unit(reported_appliance_state) == FAHRENHEIT:
|
|
121
|
+
return self._get_target_temperature_f_capability().get(STEP)
|
|
122
|
+
return self._get_target_temperature_c_capability().get(STEP)
|
|
123
|
+
|
|
124
|
+
def get_current_mode(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
125
|
+
"""Get the current mode from the reported state."""
|
|
126
|
+
return self._get_state(MODE, reported_appliance_state)
|
|
127
|
+
|
|
128
|
+
def get_current_temperature_unit(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
129
|
+
"""Get the current temperature unit from the reported state."""
|
|
130
|
+
return self._get_state(TEMPERATURE_REPRESENTATION, reported_appliance_state)
|
|
131
|
+
|
|
132
|
+
def get_current_target_temperature_c(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
133
|
+
"""Get the current target temperature C from the reported state."""
|
|
134
|
+
return self._get_state(TARGET_TEMPERATURE_C, reported_appliance_state)
|
|
135
|
+
|
|
136
|
+
def get_current_target_temperature_f(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
137
|
+
"""Get the current target temperature F from the reported state."""
|
|
138
|
+
return self._get_state(TARGET_TEMPERATURE_F, reported_appliance_state)
|
|
139
|
+
|
|
140
|
+
def get_current_ambient_temperature_c(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
141
|
+
"""Get the current ambient temperature C from the reported state."""
|
|
142
|
+
return self._get_state(AMBIENT_TEMPERATURE_C, reported_appliance_state)
|
|
143
|
+
|
|
144
|
+
def get_current_ambient_temperature_f(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
145
|
+
"""Get the current ambient temperature F from the reported state."""
|
|
146
|
+
return self._get_state(AMBIENT_TEMPERATURE_F, reported_appliance_state)
|
|
147
|
+
|
|
148
|
+
def get_current_appliance_state(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
149
|
+
"""Get the current appliance state from the reported state."""
|
|
150
|
+
return self._get_state(APPLIANCE_STATE, reported_appliance_state)
|
|
151
|
+
|
|
152
|
+
def get_current_fan_speed(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
153
|
+
"""Get the current fan speed from the reported state."""
|
|
154
|
+
return self._get_state(FAN_SPEED_SETTING, reported_appliance_state)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class AcConfigManager:
|
|
158
|
+
"""Manager for AC device configuration by model."""
|
|
159
|
+
|
|
160
|
+
def __init__(self) -> None:
|
|
161
|
+
"""Initialize with configuration data in AC_CONFIG."""
|
|
162
|
+
self._config = AC_CONFIG
|
|
163
|
+
|
|
164
|
+
def get_config(self, model_type: str, capabilities: dict[str, Any]) -> AcConfig:
|
|
165
|
+
"""Return the appliance_config for a given model type."""
|
|
166
|
+
|
|
167
|
+
return AcConfig(mapping=self._config.get(model_type, {}), capabilities=capabilities)
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"""Air Purifier configuration."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
from ..feature_constants import *
|
|
4
|
+
|
|
5
|
+
from .config import ApplianceConfig
|
|
6
|
+
from ..constants import (
|
|
7
|
+
FUJI,
|
|
8
|
+
MUJU,
|
|
9
|
+
PUREA9,
|
|
10
|
+
VERBIER,
|
|
11
|
+
WELLA5,
|
|
12
|
+
WELLA7,
|
|
13
|
+
)
|
|
14
|
+
from ..constants import VALUES, MIN, MAX
|
|
15
|
+
|
|
16
|
+
# Configuration
|
|
17
|
+
AP_CONFIG = {
|
|
18
|
+
MUJU: {
|
|
19
|
+
WORKMODE: "Workmode",
|
|
20
|
+
POWER_COMMAND: "Workmode",
|
|
21
|
+
POWER_STATE: "Workmode",
|
|
22
|
+
POWER_OFF_COMMAND: "PowerOff",
|
|
23
|
+
WORKMODE_POWER_OFF: "PowerOff",
|
|
24
|
+
POWER_ON_COMMAND: "Manual",
|
|
25
|
+
FAN_SPEED: "Fanspeed",
|
|
26
|
+
AIR_QUALITY: {
|
|
27
|
+
PM_10: "PM10",
|
|
28
|
+
PM_2_5: "PM2_5_approximate",
|
|
29
|
+
},
|
|
30
|
+
POWER_STATE_MAP: {
|
|
31
|
+
"Manual": True,
|
|
32
|
+
"Quiet": True,
|
|
33
|
+
"Auto": True,
|
|
34
|
+
"PowerOff": False,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
FUJI: {
|
|
38
|
+
WORKMODE: "Workmode",
|
|
39
|
+
POWER_COMMAND: "executeCommand",
|
|
40
|
+
POWER_STATE: "applianceState",
|
|
41
|
+
POWER_OFF_COMMAND: "off",
|
|
42
|
+
POWER_ON_COMMAND: "on",
|
|
43
|
+
WORKMODE_POWER_OFF: "PowerOff",
|
|
44
|
+
FAN_SPEED: "Fanspeed",
|
|
45
|
+
AIR_QUALITY: {
|
|
46
|
+
PM_1: "PM1",
|
|
47
|
+
PM_2_5: "PM2_5",
|
|
48
|
+
PM_10: "PM10",
|
|
49
|
+
TVOC: "TVOC",
|
|
50
|
+
},
|
|
51
|
+
POWER_STATE_MAP: {
|
|
52
|
+
"running": True,
|
|
53
|
+
"off": False,
|
|
54
|
+
"monitoring": False,
|
|
55
|
+
"alert": False,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
PUREA9: {
|
|
59
|
+
WORKMODE: "Workmode",
|
|
60
|
+
POWER_COMMAND: "Workmode",
|
|
61
|
+
POWER_STATE: "Workmode",
|
|
62
|
+
POWER_OFF_COMMAND: "PowerOff",
|
|
63
|
+
POWER_ON_COMMAND: "Auto",
|
|
64
|
+
WORKMODE_POWER_OFF: "PowerOff",
|
|
65
|
+
FAN_SPEED: "Fanspeed",
|
|
66
|
+
AIR_QUALITY: {
|
|
67
|
+
PM_1: "PM1",
|
|
68
|
+
PM_2_5: "PM2_5",
|
|
69
|
+
PM_10: "PM10",
|
|
70
|
+
TVOC: "TVOC",
|
|
71
|
+
},
|
|
72
|
+
POWER_STATE_MAP: {
|
|
73
|
+
"Manual": True,
|
|
74
|
+
"Quiet": True,
|
|
75
|
+
"Auto": True,
|
|
76
|
+
"PowerOff": False,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
VERBIER: {
|
|
80
|
+
WORKMODE: "Workmode",
|
|
81
|
+
POWER_COMMAND: "Workmode",
|
|
82
|
+
POWER_STATE: "Workmode",
|
|
83
|
+
POWER_OFF_COMMAND: "PowerOff",
|
|
84
|
+
POWER_ON_COMMAND: "Auto",
|
|
85
|
+
WORKMODE_POWER_OFF: "PowerOff",
|
|
86
|
+
FAN_SPEED: "Fanspeed",
|
|
87
|
+
AIR_QUALITY: {
|
|
88
|
+
PM_1: "PM1",
|
|
89
|
+
PM_2_5: "PM2_5",
|
|
90
|
+
PM_10: "PM10",
|
|
91
|
+
TVOC: "TVOC",
|
|
92
|
+
},
|
|
93
|
+
POWER_STATE_MAP: {
|
|
94
|
+
"Manual": True,
|
|
95
|
+
"Quiet": True,
|
|
96
|
+
"Auto": True,
|
|
97
|
+
"PowerOff": False,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
WELLA5: {
|
|
101
|
+
WORKMODE: "Workmode",
|
|
102
|
+
POWER_COMMAND: "Workmode",
|
|
103
|
+
POWER_STATE: "Workmode",
|
|
104
|
+
POWER_OFF_COMMAND: "PowerOff",
|
|
105
|
+
POWER_ON_COMMAND: "Auto",
|
|
106
|
+
WORKMODE_POWER_OFF: "PowerOff",
|
|
107
|
+
FAN_SPEED: "Fanspeed",
|
|
108
|
+
AIR_QUALITY: {
|
|
109
|
+
PM_1: "PM1",
|
|
110
|
+
PM_2_5: "PM2_5",
|
|
111
|
+
PM_10: "PM10",
|
|
112
|
+
TVOC: "TVOC",
|
|
113
|
+
},
|
|
114
|
+
POWER_STATE_MAP: {
|
|
115
|
+
"Manual": True,
|
|
116
|
+
"Quiet": True,
|
|
117
|
+
"Auto": True,
|
|
118
|
+
"PowerOff": False,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
WELLA7: {
|
|
122
|
+
WORKMODE: "Workmode",
|
|
123
|
+
POWER_COMMAND: "Workmode",
|
|
124
|
+
POWER_STATE: "Workmode",
|
|
125
|
+
POWER_OFF_COMMAND: "PowerOff",
|
|
126
|
+
POWER_ON_COMMAND: "Auto",
|
|
127
|
+
WORKMODE_POWER_OFF: "PowerOff",
|
|
128
|
+
FAN_SPEED: "Fanspeed",
|
|
129
|
+
AIR_QUALITY: {
|
|
130
|
+
PM_1: "PM1",
|
|
131
|
+
PM_2_5: "PM2_5",
|
|
132
|
+
PM_10: "PM10",
|
|
133
|
+
TVOC: "TVOC",
|
|
134
|
+
},
|
|
135
|
+
POWER_STATE_MAP: {
|
|
136
|
+
"Manual": True,
|
|
137
|
+
"Quiet": True,
|
|
138
|
+
"Auto": True,
|
|
139
|
+
"PowerOff": False,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class ApConfig(ApplianceConfig):
|
|
146
|
+
"""Config for AP devices."""
|
|
147
|
+
|
|
148
|
+
def _get_power_state_map(self) -> dict[str, bool]:
|
|
149
|
+
"""Return the power state map."""
|
|
150
|
+
return self.mapping.get(POWER_STATE_MAP)
|
|
151
|
+
|
|
152
|
+
def get_air_quality_map(self) -> dict[str, str]:
|
|
153
|
+
"""Return the air quality map."""
|
|
154
|
+
return self.mapping.get(AIR_QUALITY)
|
|
155
|
+
|
|
156
|
+
def get_supported_modes(self) -> list[str]:
|
|
157
|
+
"""Get appliance modes."""
|
|
158
|
+
key = self.get_property(WORKMODE)
|
|
159
|
+
values = self.capabilities.get(key, {}).get(VALUES, {})
|
|
160
|
+
return list(values.keys())
|
|
161
|
+
|
|
162
|
+
def _get_fan_speed_capability(self) -> dict[str, Any]:
|
|
163
|
+
"""Get fan speed capability."""
|
|
164
|
+
return self.capabilities.get(
|
|
165
|
+
self.get_property(FAN_SPEED)
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def get_min_fan_speed(self) -> int:
|
|
169
|
+
"""Get MIN fan speed."""
|
|
170
|
+
return self._get_fan_speed_capability().get(MIN, 0)
|
|
171
|
+
|
|
172
|
+
def get_max_fan_speed(self) -> int:
|
|
173
|
+
"""Get MAX fan speed."""
|
|
174
|
+
return self._get_fan_speed_capability().get(MAX, 0)
|
|
175
|
+
|
|
176
|
+
def get_current_mode(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
177
|
+
"""Get the current mode from the reported state."""
|
|
178
|
+
return self._get_state(WORKMODE, reported_appliance_state)
|
|
179
|
+
|
|
180
|
+
def get_current_fan_speed(self, reported_appliance_state: dict[str, Any]) -> int:
|
|
181
|
+
"""Get the current fan speed from the reported state."""
|
|
182
|
+
return self._get_state(FAN_SPEED, reported_appliance_state)
|
|
183
|
+
|
|
184
|
+
def is_appliance_on(self, reported_appliance_state: dict[str, Any]) -> bool:
|
|
185
|
+
"""Return true if the appliance is on."""
|
|
186
|
+
power_state = self._get_state(POWER_STATE, reported_appliance_state)
|
|
187
|
+
return self._get_power_state_map().get(power_state, False)
|
|
188
|
+
|
|
189
|
+
def get_air_quality(self, reported_appliance_state: dict[str, Any], air_quality_property: str) -> float:
|
|
190
|
+
"""Get the air quality from the reported state."""
|
|
191
|
+
return reported_appliance_state.get(self.get_air_quality_map().get(air_quality_property), 0)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class ApConfigManager:
|
|
195
|
+
"""Manager for AP device configuration by model."""
|
|
196
|
+
|
|
197
|
+
def __init__(self) -> None:
|
|
198
|
+
"""Initialize with configuration data in AP_CONFIG."""
|
|
199
|
+
self._config = AP_CONFIG
|
|
200
|
+
|
|
201
|
+
def get_config(self, model_type: str, capabilities: dict[str, Any]) -> ApConfig:
|
|
202
|
+
"""Return the appliance_config for a given model type."""
|
|
203
|
+
|
|
204
|
+
return ApConfig(mapping=self._config.get(model_type, {}), capabilities=capabilities)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ApplianceConfig(BaseModel):
|
|
7
|
+
"""Base appliance config class."""
|
|
8
|
+
|
|
9
|
+
mapping: dict[str, Any]
|
|
10
|
+
capabilities: dict[str, Any]
|
|
11
|
+
|
|
12
|
+
def _get_state(self, state_key: str, reported_appliance_state: dict[str, Any]) -> Any:
|
|
13
|
+
"""Return the state given a specific key."""
|
|
14
|
+
return reported_appliance_state.get(key) if (key := self.get_property(state_key)) else None
|
|
15
|
+
|
|
16
|
+
def is_capability_supported(self, feature):
|
|
17
|
+
"""Return True if the appliance supports this capability or any capability in a list."""
|
|
18
|
+
if isinstance(feature, str):
|
|
19
|
+
key = self.get_property(feature)
|
|
20
|
+
return key is not None and key in self.capabilities
|
|
21
|
+
elif isinstance(feature, list):
|
|
22
|
+
for f in feature:
|
|
23
|
+
key = self.get_property(f)
|
|
24
|
+
if key is not None and key in self.capabilities:
|
|
25
|
+
return True
|
|
26
|
+
return False
|
|
27
|
+
return False
|
|
28
|
+
|
|
29
|
+
def get_property(self, key: str) -> str:
|
|
30
|
+
"""Return the appliance type specific key."""
|
|
31
|
+
return self.mapping.get(key)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Combi Refrigerator configuration."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from .config import ApplianceConfig
|
|
5
|
+
from ..constants import VALUES, MIN, MAX, STEP, FAHRENHEIT, CR
|
|
6
|
+
from ..feature_constants import *
|
|
7
|
+
|
|
8
|
+
# cavities
|
|
9
|
+
FRIDGE = "fridge"
|
|
10
|
+
ICE_MAKER = "iceMaker"
|
|
11
|
+
FREEZER = "freezer"
|
|
12
|
+
EXTRA_CAVITY = "extraCavity"
|
|
13
|
+
CAVITIES = [FRIDGE, ICE_MAKER, EXTRA_CAVITY, FREEZER]
|
|
14
|
+
|
|
15
|
+
# Configuration
|
|
16
|
+
CR_CONFIG = {
|
|
17
|
+
CR: {
|
|
18
|
+
TARGET_TEMPERATURE_C: "targetTemperatureC",
|
|
19
|
+
TARGET_TEMPERATURE_F: "targetTemperatureF",
|
|
20
|
+
TEMPERATURE_REPRESENTATION: "temperatureRepresentation",
|
|
21
|
+
APPLIANCE_STATE: "applianceState",
|
|
22
|
+
ALERTS: "alerts",
|
|
23
|
+
DOOR_STATE: "doorState",
|
|
24
|
+
UI_LOCK_MODE: "uiLockMode",
|
|
25
|
+
WATER_FILTER_STATE: "waterFilterState",
|
|
26
|
+
AIR_FILTER_STATE: "airFilterState",
|
|
27
|
+
DEFROST_TEMPERATURE_C: "defrostTemperatureC", # iceMaker only
|
|
28
|
+
DEFROST_TEMPERATURE_F: "defrostTemperatureF", # iceMaker only
|
|
29
|
+
VACATION_HOLIDAY_MODE: "vacationHolidayMode",
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class CrConfig(ApplianceConfig):
|
|
35
|
+
"""Config for CR devices."""
|
|
36
|
+
|
|
37
|
+
def _get_nested_state(self, state_key: str, nested_state_key: str, reported_appliance_state: dict[str, Any]) -> Any:
|
|
38
|
+
"""Return the state given a nested specific key."""
|
|
39
|
+
if not state_key or not nested_state_key:
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
outer_value = reported_appliance_state.get(state_key)
|
|
43
|
+
if not isinstance(outer_value, dict):
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
return outer_value.get(nested_state_key)
|
|
47
|
+
|
|
48
|
+
def is_cavity_capability_supported(self, cavity: str, feature) -> bool:
|
|
49
|
+
"""Return True if the appliance supports this cavity capability or any capability in a list."""
|
|
50
|
+
cavity_capabilities = self.capabilities.get(cavity)
|
|
51
|
+
if cavity_capabilities is None:
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
if isinstance(feature, str):
|
|
55
|
+
key = self.get_property(feature)
|
|
56
|
+
return key is not None and key in cavity_capabilities
|
|
57
|
+
elif isinstance(feature, list):
|
|
58
|
+
for f in feature:
|
|
59
|
+
key = self.get_property(f)
|
|
60
|
+
if key is not None and key in cavity_capabilities:
|
|
61
|
+
return True
|
|
62
|
+
return False
|
|
63
|
+
return False
|
|
64
|
+
|
|
65
|
+
def get_supported_cavities(self) -> list[str]:
|
|
66
|
+
"""Get supported cavities name from the capabilities."""
|
|
67
|
+
return [key for key in CAVITIES if key in self.capabilities]
|
|
68
|
+
|
|
69
|
+
def get_temperature_range(self, cavity: str, reported_appliance_state: dict) -> dict[str, float]:
|
|
70
|
+
"""Extract temperature range for the given program based on temperature unit."""
|
|
71
|
+
current_unit = self.get_current_temperature_unit(reported_appliance_state)
|
|
72
|
+
|
|
73
|
+
temperature_key = self.get_property(
|
|
74
|
+
TARGET_TEMPERATURE_F) if (current_unit == FAHRENHEIT and self.get_property(
|
|
75
|
+
TARGET_TEMPERATURE_F) in self.capabilities) else self.get_property(TARGET_TEMPERATURE_C)
|
|
76
|
+
|
|
77
|
+
cavity_capabilities = self.capabilities.get(cavity)
|
|
78
|
+
temperature_capability = cavity_capabilities.get(temperature_key)
|
|
79
|
+
if all(k in temperature_capability and temperature_capability.get(k) is not None for k in (MIN, MAX, STEP)):
|
|
80
|
+
return {
|
|
81
|
+
MIN: temperature_capability.get(MIN),
|
|
82
|
+
MAX: temperature_capability.get(MAX),
|
|
83
|
+
STEP: temperature_capability.get(STEP),
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
MIN: 0,
|
|
87
|
+
MAX: 0,
|
|
88
|
+
STEP: 0,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
def get_supported_extra_cavity_temperature(self, reported_appliance_state: dict) -> list[float]:
|
|
92
|
+
"""Extract the ExtraCavity supported temperature from the capabilities."""
|
|
93
|
+
current_unit = self.get_current_temperature_unit(reported_appliance_state)
|
|
94
|
+
temperature_key = self.get_property(
|
|
95
|
+
TARGET_TEMPERATURE_F) if (current_unit == FAHRENHEIT and self.get_property(
|
|
96
|
+
TARGET_TEMPERATURE_F) in self.capabilities) else self.get_property(TARGET_TEMPERATURE_C)
|
|
97
|
+
|
|
98
|
+
extra_cavity_capabilities = self.capabilities.get(EXTRA_CAVITY)
|
|
99
|
+
temperature_capability = extra_cavity_capabilities.get(temperature_key)
|
|
100
|
+
return [float(temp) for temp in temperature_capability.get(VALUES, {}).keys()]
|
|
101
|
+
|
|
102
|
+
def get_current_temperature_unit(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
103
|
+
"""Get the current temperature unit from the reported state."""
|
|
104
|
+
return self._get_state(TEMPERATURE_REPRESENTATION, reported_appliance_state)
|
|
105
|
+
|
|
106
|
+
def get_current_alerts(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
107
|
+
"""Get the current alerts from the reported state."""
|
|
108
|
+
return self._get_state(ALERTS, reported_appliance_state)
|
|
109
|
+
|
|
110
|
+
def get_current_ui_lock_mode(self, reported_appliance_state: dict[str, Any]) -> bool:
|
|
111
|
+
"""Get the current UI lock mode from the reported state."""
|
|
112
|
+
return self._get_state(UI_LOCK_MODE, reported_appliance_state)
|
|
113
|
+
|
|
114
|
+
def get_current_water_filter_state(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
115
|
+
"""Get the current water filter state from the reported state."""
|
|
116
|
+
return self._get_state(WATER_FILTER_STATE, reported_appliance_state)
|
|
117
|
+
|
|
118
|
+
def get_current_air_filter_state(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
119
|
+
"""Get the current air filter state from the reported state."""
|
|
120
|
+
return self._get_state(AIR_FILTER_STATE, reported_appliance_state)
|
|
121
|
+
|
|
122
|
+
def get_current_vacation_holiday_mode(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
123
|
+
"""Get the current vacation holiday mode from the reported state."""
|
|
124
|
+
return self._get_state(VACATION_HOLIDAY_MODE, reported_appliance_state)
|
|
125
|
+
|
|
126
|
+
def get_current_cavity_target_temperature_c(self, cavity: str, reported_appliance_state: dict[str, Any]) -> float:
|
|
127
|
+
"""Get the current cavity target temperature C from the reported state."""
|
|
128
|
+
return self._get_nested_state(cavity, self.get_property(TARGET_TEMPERATURE_C), reported_appliance_state)
|
|
129
|
+
|
|
130
|
+
def get_current_cavity_target_temperature_f(self, cavity: str, reported_appliance_state: dict[str, Any]) -> float:
|
|
131
|
+
"""Get the current cavity target temperature F from the reported state."""
|
|
132
|
+
return self._get_nested_state(cavity, self.get_property(TARGET_TEMPERATURE_F), reported_appliance_state)
|
|
133
|
+
|
|
134
|
+
def get_current_cavity_appliance_state(self, cavity: str, reported_appliance_state: dict[str, Any]) -> str:
|
|
135
|
+
"""Get the current cavity appliance state from the reported state."""
|
|
136
|
+
return self._get_nested_state(cavity, self.get_property(APPLIANCE_STATE), reported_appliance_state)
|
|
137
|
+
|
|
138
|
+
def get_current_cavity_alerts(self, cavity: str, reported_appliance_state: dict[str, Any]) -> list[Any]:
|
|
139
|
+
"""Get the current cavity alerts from the reported state."""
|
|
140
|
+
return self._get_nested_state(cavity, self.get_property(ALERTS), reported_appliance_state)
|
|
141
|
+
|
|
142
|
+
def get_current_door_state(self, cavity: str, reported_appliance_state: dict[str, Any]) -> str:
|
|
143
|
+
"""Get the current cavity door state from the reported state."""
|
|
144
|
+
return self._get_nested_state(cavity, self.get_property(DOOR_STATE), reported_appliance_state)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class CrConfigManager:
|
|
148
|
+
"""Manager for CR device configuration by model."""
|
|
149
|
+
|
|
150
|
+
def __init__(self) -> None:
|
|
151
|
+
"""Initialize with configuration data in CR_CONFIG."""
|
|
152
|
+
self._config = CR_CONFIG
|
|
153
|
+
|
|
154
|
+
def get_config(self, model_type: str, capabilities: dict[str, Any]) -> CrConfig:
|
|
155
|
+
"""Return the appliance_config for a given model type."""
|
|
156
|
+
return CrConfig(mapping=self._config.get(model_type, {}), capabilities=capabilities)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""DAM Air conditioner configuration."""
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from .config import ApplianceConfig
|
|
5
|
+
from ..constants import VALUES, DAM_AC, PROPERTIES, CELSIUS, RANGE
|
|
6
|
+
from ..feature_constants import *
|
|
7
|
+
|
|
8
|
+
# Configuration
|
|
9
|
+
DAM_AC_CONFIG = {
|
|
10
|
+
DAM_AC: {
|
|
11
|
+
AIR_CONDITIONER: "airConditioner",
|
|
12
|
+
TARGET_TEMPERATURE: "targetTemperature",
|
|
13
|
+
FAN_MODE: "fanMode",
|
|
14
|
+
MODE: "mode",
|
|
15
|
+
AMBIENT_TEMPERATURE: "temperature",
|
|
16
|
+
EXECUTE_COMMAND: "executeCommand",
|
|
17
|
+
APPLIANCE_STATE: "applianceState"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DamAcConfig(ApplianceConfig):
|
|
23
|
+
"""Config for DAM AC devices."""
|
|
24
|
+
|
|
25
|
+
def _get_ac_nested_state(self, state_key: str, reported_appliance_state: dict[str, Any]) -> Any:
|
|
26
|
+
"""Return the state given a airConditioner nested specific key."""
|
|
27
|
+
if not state_key:
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
outer_value = reported_appliance_state.get(self.get_property(AIR_CONDITIONER))
|
|
31
|
+
if not isinstance(outer_value, dict):
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
return outer_value.get(self.get_property(state_key))
|
|
35
|
+
|
|
36
|
+
def _get_air_conditioner_capabilities(self) -> dict[str, Any]:
|
|
37
|
+
"""Get air conditioner capabilities."""
|
|
38
|
+
key = self.get_property(AIR_CONDITIONER)
|
|
39
|
+
return self.capabilities.get(key, {}).get(PROPERTIES, {})
|
|
40
|
+
|
|
41
|
+
def is_air_conditioner_capability_supported(self, feature: str) -> bool:
|
|
42
|
+
"""Return True if the appliance supports this ac capability."""
|
|
43
|
+
key = self.get_property(feature)
|
|
44
|
+
ac_capabilities = self._get_air_conditioner_capabilities()
|
|
45
|
+
return key is not None and ac_capabilities is not None and key in ac_capabilities
|
|
46
|
+
|
|
47
|
+
def get_supported_modes(self) -> list[str]:
|
|
48
|
+
"""Get appliance modes."""
|
|
49
|
+
key = self.get_property(MODE)
|
|
50
|
+
values = self._get_air_conditioner_capabilities().get(key, {}).get(VALUES, {})
|
|
51
|
+
return list(values.keys())
|
|
52
|
+
|
|
53
|
+
def get_supported_fan_speeds(self) -> list[str]:
|
|
54
|
+
"""Get appliance fan speeds."""
|
|
55
|
+
key = self.get_property(FAN_MODE)
|
|
56
|
+
values = self._get_air_conditioner_capabilities().get(key, {}).get(VALUES, {})
|
|
57
|
+
return list(values.keys())
|
|
58
|
+
|
|
59
|
+
def _get_target_temperature_capability(self) -> dict[str, Any]:
|
|
60
|
+
"""Get target temperature capability."""
|
|
61
|
+
return self._get_air_conditioner_capabilities().get(
|
|
62
|
+
self.get_property(TARGET_TEMPERATURE)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def get_supported_min_temp(self) -> float:
|
|
66
|
+
"""Get MIN temperature in Celsius."""
|
|
67
|
+
return self._get_target_temperature_capability().get(RANGE)[0]
|
|
68
|
+
|
|
69
|
+
def get_supported_max_temp(self) -> float:
|
|
70
|
+
"""Get MAX temperature in Celsius."""
|
|
71
|
+
return self._get_target_temperature_capability().get(RANGE)[1]
|
|
72
|
+
|
|
73
|
+
def get_supported_step_temp(self) -> float:
|
|
74
|
+
"""Get temperature STEP in Celsius."""
|
|
75
|
+
return self._get_target_temperature_capability().get(RANGE)[2]
|
|
76
|
+
|
|
77
|
+
def get_current_mode(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
78
|
+
"""Get the current mode from the reported state."""
|
|
79
|
+
return self._get_ac_nested_state(MODE, reported_appliance_state)
|
|
80
|
+
|
|
81
|
+
def get_current_temperature_unit(self) -> str:
|
|
82
|
+
"""Temperature unit for DAM AC is always Celsius."""
|
|
83
|
+
return CELSIUS
|
|
84
|
+
|
|
85
|
+
def get_current_target_temperature(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
86
|
+
"""Get the current target temperature from the reported state."""
|
|
87
|
+
return self._get_ac_nested_state(TARGET_TEMPERATURE, reported_appliance_state)
|
|
88
|
+
|
|
89
|
+
def get_current_ambient_temperature(self, reported_appliance_state: dict[str, Any]) -> float:
|
|
90
|
+
"""Get the current ambient temperature from the reported state."""
|
|
91
|
+
return self._get_state(AMBIENT_TEMPERATURE, reported_appliance_state)
|
|
92
|
+
|
|
93
|
+
def get_current_appliance_state(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
94
|
+
"""Get the current appliance state from the reported state."""
|
|
95
|
+
return self._get_ac_nested_state(APPLIANCE_STATE, reported_appliance_state)
|
|
96
|
+
|
|
97
|
+
def get_current_fan_speed(self, reported_appliance_state: dict[str, Any]) -> str:
|
|
98
|
+
"""Get the current fan speed from the reported state."""
|
|
99
|
+
return self._get_ac_nested_state(FAN_MODE, reported_appliance_state)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class DamAcConfigManager:
|
|
103
|
+
"""Manager for DAM AC device configuration by model."""
|
|
104
|
+
|
|
105
|
+
def __init__(self) -> None:
|
|
106
|
+
"""Initialize with configuration data in DAM_AC_CONFIG."""
|
|
107
|
+
self._config = DAM_AC_CONFIG
|
|
108
|
+
|
|
109
|
+
def get_config(self, model_type: str, capabilities: dict[str, Any]) -> DamAcConfig:
|
|
110
|
+
"""Return the appliance_config for a given model type."""
|
|
111
|
+
|
|
112
|
+
return DamAcConfig(mapping=self._config.get(model_type, {}), capabilities=capabilities)
|