From 3a1c7792c9ad72781e5504d62d0bc0cf4f8cdf92 Mon Sep 17 00:00:00 2001 From: atse Date: Thu, 22 Aug 2024 12:58:52 +0800 Subject: [PATCH] {start,end}_session -> [dis]connect --- pytec/examples/aioexample.py | 2 +- pytec/pytec/aioclient.py | 14 +++++++------- pytec/pytec/gui/model/thermostat.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pytec/examples/aioexample.py b/pytec/examples/aioexample.py index 598aef2..15fd483 100644 --- a/pytec/examples/aioexample.py +++ b/pytec/examples/aioexample.py @@ -4,7 +4,7 @@ from pytec.aioclient import AsyncioClient async def main(): tec = AsyncioClient() - await tec.start_session() # (host="192.168.1.26", port=23) + await tec.connect() # (host="192.168.1.26", port=23) await tec.set_param("s-h", 1, "t0", 20) print(await tec.get_pwm()) print(await tec.get_pid()) diff --git a/pytec/pytec/aioclient.py b/pytec/pytec/aioclient.py index 7b568e9..c06fef8 100644 --- a/pytec/pytec/aioclient.py +++ b/pytec/pytec/aioclient.py @@ -15,12 +15,12 @@ class AsyncioClient: self._report_mode_on = False self.timeout = None - async def start_session(self, host="192.168.1.26", port=23): - """Start session to Thermostat at specified host and port. + async def connect(self, host="192.168.1.26", port=23): + """Connect to Thermostat at specified host and port. Example:: client = AsyncioClient() - await client.start_session() + await client.connect() """ self._reader, self._writer = await asyncio.open_connection(host, port) await self._check_zero_limits() @@ -29,8 +29,8 @@ class AsyncioClient: """Returns True if client is connected""" return self._writer is not None - async def end_session(self): - """End session to Thermostat""" + async def disconnect(self): + """Disconnect from the Thermostat""" if self._writer is None: return @@ -243,7 +243,7 @@ class AsyncioClient: self._writer.write("reset\n".encode("utf-8")) await self._writer.drain() - await self.end_session() + await self.disconnect() async def dfu(self): """Put the Thermostat in DFU update mode @@ -256,7 +256,7 @@ class AsyncioClient: self._writer.write("dfu\n".encode("utf-8")) await self._writer.drain() - await self.end_session() + await self.disconnect() async def ipv4(self): """Get the IPv4 settings of the Thermostat""" diff --git a/pytec/pytec/gui/model/thermostat.py b/pytec/pytec/gui/model/thermostat.py index 061039f..8ce98d0 100644 --- a/pytec/pytec/gui/model/thermostat.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -29,7 +29,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): super().__init__(parent) async def start_session(self, host, port): - await self._client.start_session(host, port) + await self._client.connect(host, port) async def run(self): self._update_params_task = asyncio.create_task(self.update_params()) @@ -97,7 +97,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): ] async def end_session(self): - await self._client.end_session() + await self._client.disconnect() self.connection_errored = False async def set_ipv4(self, ipv4):