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

## v1.5.0

- Make timeout an internal parameter.

## v1.4.4

- Change connect() function to output the gateway firmware-version.
Expand Down
36 changes: 20 additions & 16 deletions plugwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from __future__ import annotations

from plugwise.constants import (
DEFAULT_LEGACY_TIMEOUT,
DEFAULT_PORT,
DEFAULT_TIMEOUT,
DEFAULT_USERNAME,
DOMAIN_OBJECTS,
LOGGER,
Expand Down Expand Up @@ -43,26 +45,25 @@ def __init__(
self,
host: str,
password: str,
timeout: int,
websession: aiohttp.ClientSession,
port: int = DEFAULT_PORT,
username: str = DEFAULT_USERNAME,
) -> None:
"""Set the constructor for this class."""
super().__init__(
host,
password,
port,
timeout,
username,
websession,
)

self._host = host
self._passwd = password
self._password = password
self._port = port
self._user = username
self._timeout = DEFAULT_LEGACY_TIMEOUT
self._username = username
self._websession = websession
super().__init__(
self._host,
self._password,
self._port,
self._timeout,
self._username,
self._websession,
)

self._cooling_present = False
self._elga = False
Expand Down Expand Up @@ -126,7 +127,7 @@ async def connect(self) -> Version | None:

self._smile_api = SmileAPI(
self._host,
self._passwd,
self._password,
self._request,
self._websession,
self._cooling_present,
Expand All @@ -147,10 +148,10 @@ async def connect(self) -> Version | None:
self.smile_name,
self.smile_type,
self._port,
self._user,
self._username,
) if not self.smile_legacy else SmileLegacyAPI(
self._host,
self._passwd,
self._password,
self._request,
self._websession,
self._is_thermostat,
Expand All @@ -168,7 +169,7 @@ async def connect(self) -> Version | None:
self.smile_type,
self.smile_zigbee_mac_address,
self._port,
self._user,
self._username,
)

# Update all endpoints on first connect
Expand Down Expand Up @@ -212,6 +213,9 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
)
raise UnsupportedDeviceError

if not self.smile_legacy:
self._timeout = DEFAULT_TIMEOUT

if self._target_smile in ("smile_open_therm_v2", "smile_thermo_v3"):
LOGGER.error(
"Your Smile identified as %s needs a firmware update as it's firmware is severely outdated",
Expand Down
1 change: 0 additions & 1 deletion plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ async def _create_session() -> ClientSession:

self._auth = BasicAuth(username, password=password)
self._endpoint = f"http://{host}:{str(port)}"
self._timeout = timeout

async def _request(
self,
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 = "1.4.4"
version = "1.5.0"
license = {file = "LICENSE"}
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
readme = "README.md"
Expand Down
8 changes: 3 additions & 5 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ async def connect(
username=pw_constants.DEFAULT_USERNAME,
password=test_password,
port=server.port,
timeout=pw_constants.DEFAULT_TIMEOUT,
websession=None,
)
lack_of_websession = False
Expand All @@ -337,18 +336,18 @@ async def connect(
username=pw_constants.DEFAULT_USERNAME,
password=test_password,
port=server.port,
timeout=pw_constants.DEFAULT_TIMEOUT,
websession=websession,
)

if not timeout:
assert smile._timeout == 10
assert smile._timeout == 30

# Connect to the smile
version = None
try:
version = await smile.connect()
assert version is not None
assert smile._timeout == 10
return server, smile, client
except (
pw_exceptions.ConnectionFailedError,
Expand Down Expand Up @@ -408,7 +407,6 @@ async def connect_legacy(
username=pw_constants.DEFAULT_USERNAME,
password=test_password,
port=server.port,
timeout=pw_constants.DEFAULT_LEGACY_TIMEOUT,
websession=None,
)
lack_of_websession = False
Expand All @@ -422,7 +420,6 @@ async def connect_legacy(
username=pw_constants.DEFAULT_USERNAME,
password=test_password,
port=server.port,
timeout=pw_constants.DEFAULT_LEGACY_TIMEOUT,
websession=websession,
)

Expand All @@ -434,6 +431,7 @@ async def connect_legacy(
try:
version = await smile.connect()
assert version is not None
assert smile._timeout == 30
return server, smile, client
except (
pw_exceptions.ConnectionFailedError,
Expand Down