44"""
55from __future__ import annotations
66
7+ from collections .abc import Awaitable , Callable
78import datetime as dt
89from typing import Any
910
2425 ThermoLoc ,
2526)
2627from plugwise .exceptions import ConnectionFailedError , PlugwiseError
27- from plugwise .helper import SmileComm
2828from plugwise .legacy .data import SmileLegacyData
2929
3030import aiohttp
3131from munch import Munch
3232
3333
34- class SmileLegacyAPI (SmileComm , SmileLegacyData ):
34+ class SmileLegacyAPI (SmileLegacyData ):
3535 """The Plugwise SmileLegacyAPI class."""
3636
3737 # pylint: disable=too-many-instance-attributes, too-many-public-methods
@@ -40,7 +40,7 @@ def __init__(
4040 self ,
4141 host : str ,
4242 password : str ,
43- timeout : int ,
43+ request : Callable [..., Awaitable [ Any ]] ,
4444 websession : aiohttp .ClientSession ,
4545 _is_thermostat : bool ,
4646 _on_off_device : bool ,
@@ -60,14 +60,6 @@ def __init__(
6060 username : str = DEFAULT_USERNAME ,
6161 ) -> None :
6262 """Set the constructor for this class."""
63- super ().__init__ (
64- host ,
65- password ,
66- port ,
67- timeout ,
68- username ,
69- websession ,
70- )
7163 SmileLegacyData .__init__ (self )
7264
7365 self ._cooling_present = False
@@ -76,8 +68,8 @@ def __init__(
7668 self ._opentherm_device = _opentherm_device
7769 self ._stretch_v2 = _stretch_v2
7870 self ._target_smile = _target_smile
79- self ._timeout = timeout
8071 self .loc_data = loc_data
72+ self .request = request
8173 self .smile_fw_version = smile_fw_version
8274 self .smile_hostname = smile_hostname
8375 self .smile_hw_version = smile_hw_version
@@ -91,12 +83,12 @@ def __init__(
9183
9284 async def full_update_device (self ) -> None :
9385 """Perform a first fetch of all XML data, needed for initialization."""
94- self ._domain_objects = await self ._request (DOMAIN_OBJECTS )
95- self ._locations = await self ._request (LOCATIONS )
96- self ._modules = await self ._request (MODULES )
86+ self ._domain_objects = await self .request (DOMAIN_OBJECTS )
87+ self ._locations = await self .request (LOCATIONS )
88+ self ._modules = await self .request (MODULES )
9789 # P1 legacy has no appliances
9890 if self .smile_type != "power" :
99- self ._appliances = await self ._request (APPLIANCES )
91+ self ._appliances = await self .request (APPLIANCES )
10092
10193 def get_all_devices (self ) -> None :
10294 """Determine the evices present from the obtained XML-data.
@@ -131,12 +123,12 @@ async def async_update(self) -> PlugwiseData:
131123 self .get_all_devices ()
132124 # Otherwise perform an incremental update
133125 else :
134- self ._domain_objects = await self ._request (DOMAIN_OBJECTS )
126+ self ._domain_objects = await self .request (DOMAIN_OBJECTS )
135127 match self ._target_smile :
136128 case "smile_v2" :
137- self ._modules = await self ._request (MODULES )
129+ self ._modules = await self .request (MODULES )
138130 case self ._target_smile if self ._target_smile in REQUIRE_APPLIANCES :
139- self ._appliances = await self ._request (APPLIANCES )
131+ self ._appliances = await self .request (APPLIANCES )
140132
141133 self ._update_gw_devices ()
142134
@@ -291,10 +283,10 @@ async def set_temperature(self, _: str, items: dict[str, float]) -> None:
291283 await self .call_request (uri , method = "put" , data = data )
292284
293285 async def call_request (self , uri : str , ** kwargs : Any ) -> None :
294- """ConnectionFailedError wrapper for calling _request ()."""
286+ """ConnectionFailedError wrapper for calling request ()."""
295287 method : str = kwargs ["method" ]
296288 data : str | None = kwargs .get ("data" )
297289 try :
298- await self ._request (uri , method = method , data = data )
290+ await self .request (uri , method = method , data = data )
299291 except ConnectionFailedError as exc :
300292 raise ConnectionFailedError from exc
0 commit comments