Skip to content

Commit ad42639

Browse files
committed
Clean up inits, don't double-init
1 parent 4fe2784 commit ad42639

File tree

6 files changed

+18
-34
lines changed

6 files changed

+18
-34
lines changed

plugwise/__init__.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ def __init__(
6161
timeout,
6262
)
6363

64-
self._smile_api: SmileAPI | SmileLegacyAPI
6564
self._host = host
6665
self._passwd = password
66+
self._websession = websession
6767
self._user = username
6868
self._port = port
6969
self._timeout = timeout
70-
self._websession = websession
7170

7271
self._cooling_present = False
7372
self._elga = False
@@ -76,9 +75,9 @@ def __init__(
7675
self._on_off_device = False
7776
self._opentherm_device = False
7877
self._schedule_old_states: dict[str, dict[str, str]] = {}
78+
self._smile_api: SmileAPI | SmileLegacyAPI
7979
self._stretch_v2 = False
80-
self._stretch_v3 = False
81-
self._target_smile: str
80+
self._target_smile: str = NONE
8281
self.gateway_id: str = NONE
8382
self.loc_data: dict[str, ThermoLoc] = {}
8483
self.smile_fw_version: str | None
@@ -131,14 +130,14 @@ async def connect(self) -> bool:
131130
self._smile_api = SmileAPI(
132131
self._host,
133132
self._passwd,
133+
self._websession,
134134
self._cooling_present,
135135
self._elga,
136136
self._is_thermostat,
137137
self._last_active,
138138
self._on_off_device,
139139
self._opentherm_device,
140140
self._schedule_old_states,
141-
self._target_smile,
142141
self.gateway_id,
143142
self.loc_data,
144143
self.smile_fw_version,
@@ -150,7 +149,6 @@ async def connect(self) -> bool:
150149
self.smile_name,
151150
self.smile_type,
152151
self.smile_version,
153-
self._websession,
154152
self._user,
155153
self._port,
156154
self._timeout,
@@ -159,12 +157,11 @@ async def connect(self) -> bool:
159157
self._smile_api = SmileLegacyAPI(
160158
self._host,
161159
self._passwd,
160+
self._websession,
162161
self._is_thermostat,
163162
self._on_off_device,
164163
self._opentherm_device,
165-
self._schedule_old_states,
166164
self._stretch_v2,
167-
self._stretch_v3,
168165
self._target_smile,
169166
self.loc_data,
170167
self.smile_fw_version,
@@ -176,7 +173,6 @@ async def connect(self) -> bool:
176173
self.smile_type,
177174
self.smile_version,
178175
self.smile_zigbee_mac_address,
179-
self._websession,
180176
self._user,
181177
self._port,
182178
self._timeout,
@@ -236,7 +232,6 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
236232

237233
if self.smile_type == "stretch":
238234
self._stretch_v2 = self.smile_version[1].major == 2
239-
self._stretch_v3 = self.smile_version[1].major == 3
240235

241236
if self.smile_type == "thermostat":
242237
self._is_thermostat = True

plugwise/helper.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,28 +197,27 @@ def __init__(self) -> None:
197197
"""Set the constructor for this class."""
198198
self._cooling_activation_outdoor_temp: float
199199
self._cooling_deactivation_threshold: float
200-
self._cooling_present = False
200+
self._cooling_present: bool
201201
self._count: int
202202
self._dhw_allowed_modes: list[str] = []
203203
self._domain_objects: etree
204204
self._endpoint: str
205-
self._elga = False
205+
self._elga: bool
206206
self._gw_allowed_modes: list[str] = []
207207
self._heater_id: str
208208
self._home_location: str
209-
self._is_thermostat = False
209+
self._is_thermostat: bool
210210
self._last_active: dict[str, str | None]
211211
self._last_modified: dict[str, str] = {}
212212
self._notifications: dict[str, dict[str, str]] = {}
213-
self._on_off_device = False
214-
self._opentherm_device = False
213+
self._on_off_device: bool
214+
self._opentherm_device: bool
215215
self._outdoor_temp: float
216216
self._reg_allowed_modes: list[str] = []
217217
self._schedule_old_states: dict[str, dict[str, str]] = {}
218218
self._smile_legacy = False
219219
self._status: etree
220-
self._stretch_v2 = False
221-
self._stretch_v3 = False
220+
self._stretch_v2: bool
222221
self._system: etree
223222
self._thermo_locs: dict[str, ThermoLoc] = {}
224223
###################################################################

plugwise/legacy/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _all_device_data(self) -> None:
6060
)
6161
if self._is_thermostat:
6262
self.gw_data.update(
63-
{"heater_id": self._heater_id, "cooling_present": self._cooling_present}
63+
{"heater_id": self._heater_id, "cooling_present": False}
6464
)
6565

6666
def _device_data_switching_group(

plugwise/legacy/helper.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,23 +70,19 @@ def __init__(self) -> None:
7070
"""Set the constructor for this class."""
7171
self._appliances: etree
7272
self._count: int
73-
self._cooling_present = False
7473
self._domain_objects: etree
7574
self._heater_id: str
7675
self._home_location: str
77-
self._is_thermostat = False
78-
self._last_active: dict[str, str | None] = {}
76+
self._is_thermostat: bool
7977
self._last_modified: dict[str, str] = {}
8078
self._locations: etree
8179
self._modules: etree
8280
self._notifications: dict[str, dict[str, str]] = {}
83-
self._on_off_device = False
84-
self._opentherm_device = False
81+
self._on_off_device: bool
82+
self._opentherm_device: bool
8583
self._outdoor_temp: float
86-
self._schedule_old_states: dict[str, dict[str, str]] = {}
8784
self._status: etree
88-
self._stretch_v2 = False
89-
self._stretch_v3 = False
85+
self._stretch_v2: bool
9086
self._system: etree
9187

9288
self.device_items: int = 0

plugwise/legacy/smile.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ def __init__(
4141
self,
4242
host: str,
4343
password: str,
44+
websession: aiohttp.ClientSession,
4445
_is_thermostat: bool,
4546
_on_off_device: bool,
4647
_opentherm_device: bool,
47-
_schedule_old_states: dict[str, dict[str, str]],
4848
_stretch_v2: bool,
49-
_stretch_v3: bool,
5049
_target_smile: str,
5150
loc_data: dict[str, ThermoLoc],
5251
smile_fw_version: str | None,
@@ -58,7 +57,6 @@ def __init__(
5857
smile_type: str,
5958
smile_version: tuple[str, semver.version.Version],
6059
smile_zigbee_mac_address: str | None,
61-
websession: aiohttp.ClientSession,
6260
username: str = DEFAULT_USERNAME,
6361
port: int = DEFAULT_PORT,
6462
timeout: float = DEFAULT_TIMEOUT,
@@ -77,9 +75,7 @@ def __init__(
7775
self._is_thermostat = _is_thermostat
7876
self._on_off_device = _on_off_device
7977
self._opentherm_device = _opentherm_device
80-
self._schedule_old_states = _schedule_old_states
8178
self._stretch_v2 = _stretch_v2
82-
self._stretch_v3 = _stretch_v3
8379
self._target_smile = _target_smile
8480
self.loc_data = loc_data
8581
self.smile_fw_version = smile_fw_version

plugwise/smile.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ def __init__(
4848
self,
4949
host: str,
5050
password: str,
51+
websession: aiohttp.ClientSession,
5152
_cooling_present: bool,
5253
_elga: bool,
5354
_is_thermostat: bool,
5455
_last_active: dict[str, str | None],
5556
_on_off_device: bool,
5657
_opentherm_device: bool,
5758
_schedule_old_states: dict[str, dict[str, str]],
58-
_target_smile: str | None,
5959
gateway_id: str,
6060
loc_data: dict[str, ThermoLoc],
6161
smile_fw_version: str | None,
@@ -67,7 +67,6 @@ def __init__(
6767
smile_name: str,
6868
smile_type: str,
6969
smile_version: tuple[str, semver.version.Version],
70-
websession: aiohttp.ClientSession,
7170
username: str = DEFAULT_USERNAME,
7271
port: int = DEFAULT_PORT,
7372
timeout: float = DEFAULT_TIMEOUT,
@@ -91,7 +90,6 @@ def __init__(
9190
self._on_off_device = _on_off_device
9291
self._opentherm_device = _opentherm_device
9392
self._schedule_old_states = _schedule_old_states
94-
self._target_smile = _target_smile
9593
self.gateway_id = gateway_id
9694
self.loc_data = loc_data
9795
self.smile_fw_version = smile_fw_version

0 commit comments

Comments
 (0)