|
1 | 1 | """Use of this source code is governed by the MIT license found in the LICENSE file. |
2 | 2 | Plugwise backend module for Home Assistant Core. |
3 | 3 | """ |
4 | | -from typing import Any, Optional, Tuple |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +from typing import Any |
5 | 7 |
|
6 | 8 | import aiohttp |
7 | 9 | from defusedxml import ElementTree as etree |
@@ -266,14 +268,14 @@ def __init__( |
266 | 268 | SmileData.__init__(self) |
267 | 269 |
|
268 | 270 | self._notifications: dict[str, str] = {} |
269 | | - self.smile_hostname: Optional[str] = None |
| 271 | + self.smile_hostname: str | None = None |
270 | 272 |
|
271 | 273 | async def connect(self) -> bool: |
272 | 274 | """Connect to Plugwise device and determine its name, type and version.""" |
273 | 275 | names: list[str] = [] |
274 | 276 |
|
275 | 277 | result: etree = await self._request(DOMAIN_OBJECTS) |
276 | | - dsmrmain: etree = result.find(".//module/protocols/dsmrmain") |
| 278 | + dsmrmain: etree | None = result.find(".//module/protocols/dsmrmain") |
277 | 279 |
|
278 | 280 | vendor_names: list[etree] = result.findall(".//module/vendor_name") |
279 | 281 | if not vendor_names: |
@@ -302,14 +304,14 @@ async def connect(self) -> bool: |
302 | 304 |
|
303 | 305 | return True |
304 | 306 |
|
305 | | - async def _smile_detect_legacy(self, result, dsmrmain) -> Tuple[str, str]: |
| 307 | + async def _smile_detect_legacy(self, result, dsmrmain) -> tuple[str, str]: |
306 | 308 | """Helper-function for _smile_detect().""" |
307 | | - network: etree = result.find(".//module/protocols/master_controller") |
| 309 | + network: etree | None = result.find(".//module/protocols/master_controller") |
308 | 310 |
|
309 | 311 | # Assume legacy |
310 | 312 | self._smile_legacy = True |
311 | 313 | # Try if it is an Anna, assuming appliance thermostat |
312 | | - anna: etree = result.find('.//appliance[type="thermostat"]') |
| 314 | + anna: etree | None = result.find('.//appliance[type="thermostat"]') |
313 | 315 | # Fake insert version assuming Anna |
314 | 316 | # couldn't find another way to identify as legacy Anna |
315 | 317 | version: str = "1.8.0" |
@@ -424,7 +426,7 @@ async def _update_domain_objects(self) -> None: |
424 | 426 | f"{self._endpoint}{DOMAIN_OBJECTS}", |
425 | 427 | ) |
426 | 428 |
|
427 | | - async def async_update(self) -> Tuple[dict, dict]: |
| 429 | + async def async_update(self) -> tuple[dict, dict]: |
428 | 430 | """Perform an incremental update for updating the various device states.""" |
429 | 431 | if self.smile_type != "power": |
430 | 432 | await self._update_domain_objects() |
|
0 commit comments