Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.38.2

- Lower connection-timeout for actual devices after initial connect

## v0.38.1

- Add missing exception-handling for set-function in `__init__.py`
Expand Down
10 changes: 7 additions & 3 deletions plugwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

from plugwise.constants import (
DEFAULT_LEGACY_TIMEOUT,
DEFAULT_PORT,
DEFAULT_TIMEOUT,
DEFAULT_USERNAME,
Expand Down Expand Up @@ -46,7 +47,7 @@ def __init__(
websession: aiohttp.ClientSession,
username: str = DEFAULT_USERNAME,
port: int = DEFAULT_PORT,
timeout: float = DEFAULT_TIMEOUT,
timeout: float = DEFAULT_LEGACY_TIMEOUT,

) -> None:
"""Set the constructor for this class."""
Expand Down Expand Up @@ -128,6 +129,7 @@ async def connect(self) -> bool:
self._smile_api = SmileAPI(
self._host,
self._passwd,
self._timeout,
self._websession,
self._cooling_present,
self._elga,
Expand All @@ -147,10 +149,10 @@ async def connect(self) -> bool:
self.smile_type,
self._user,
self._port,
self._timeout,
) if not self.smile_legacy else SmileLegacyAPI(
self._host,
self._passwd,
self._timeout,
self._websession,
self._is_thermostat,
self._on_off_device,
Expand All @@ -168,7 +170,6 @@ async def connect(self) -> bool:
self.smile_zigbee_mac_address,
self._user,
self._port,
self._timeout,
)

# Update all endpoints on first connect
Expand All @@ -192,6 +193,9 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
else:
model = await self._smile_detect_legacy(result, dsmrmain, model)

if not self.smile_legacy:
self._timeout = DEFAULT_TIMEOUT

if model == "Unknown" or self.smile_fw_version is None: # pragma: no cover
# Corner case check
LOGGER.error(
Expand Down
3 changes: 2 additions & 1 deletion plugwise/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

ADAM: Final = "Adam"
ANNA: Final = "Smile Anna"
DEFAULT_TIMEOUT: Final = 30
DEFAULT_TIMEOUT: Final = 10
DEFAULT_LEGACY_TIMEOUT: Final = 30
DEFAULT_USERNAME: Final = "smile"
DEFAULT_PORT: Final = 80
DEFAULT_PW_MAX: Final = 30.0
Expand Down
4 changes: 2 additions & 2 deletions plugwise/legacy/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from plugwise.constants import (
APPLIANCES,
DEFAULT_PORT,
DEFAULT_TIMEOUT,
DEFAULT_USERNAME,
DOMAIN_OBJECTS,
LOCATIONS,
Expand Down Expand Up @@ -41,6 +40,7 @@ def __init__(
self,
host: str,
password: str,
timeout: float,
websession: aiohttp.ClientSession,
_is_thermostat: bool,
_on_off_device: bool,
Expand All @@ -58,7 +58,6 @@ def __init__(
smile_zigbee_mac_address: str | None,
username: str = DEFAULT_USERNAME,
port: int = DEFAULT_PORT,
timeout: float = DEFAULT_TIMEOUT,
) -> None:
"""Set the constructor for this class."""
super().__init__(
Expand All @@ -77,6 +76,7 @@ def __init__(
self._opentherm_device = _opentherm_device
self._stretch_v2 = _stretch_v2
self._target_smile = _target_smile
self._timeout = timeout
self.loc_data = loc_data
self.smile_fw_version = smile_fw_version
self.smile_hostname = smile_hostname
Expand Down
5 changes: 2 additions & 3 deletions plugwise/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ANNA,
APPLIANCES,
DEFAULT_PORT,
DEFAULT_TIMEOUT,
DEFAULT_USERNAME,
DOMAIN_OBJECTS,
GATEWAY_REBOOT,
Expand Down Expand Up @@ -47,6 +46,7 @@ def __init__(
self,
host: str,
password: str,
timeout: float,
websession: aiohttp.ClientSession,
_cooling_present: bool,
_elga: bool,
Expand All @@ -66,8 +66,6 @@ def __init__(
smile_type: str,
username: str = DEFAULT_USERNAME,
port: int = DEFAULT_PORT,
timeout: float = DEFAULT_TIMEOUT,

) -> None:
"""Set the constructor for this class."""
super().__init__(
Expand All @@ -87,6 +85,7 @@ def __init__(
self._on_off_device = _on_off_device
self._opentherm_device = _opentherm_device
self._schedule_old_states = _schedule_old_states
self._timeout = timeout
self.gateway_id = gateway_id
self.loc_data = loc_data
self.smile_fw_version = smile_fw_version
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "plugwise"
version = "0.38.1"
version = "0.38.2"
license = {file = "LICENSE"}
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
readme = "README.md"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,10 @@ async def device_test(
await smile.full_update_device()
smile.get_all_devices()
data = await smile.async_update()
assert smile._timeout == 30
else:
data = await smile.async_update()
assert smile._timeout == 10
else:
_LOGGER.info("Asserting updated testdata:")
data = await smile.async_update()
Expand Down