forked from M-Labs/thermostat
Reorder
This commit is contained in:
parent
524b6d9bce
commit
242b516acc
@ -41,6 +41,28 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
await self._client.connect(host, port)
|
await self._client.connect(host, port)
|
||||||
self.hw_rev = await self._client.hw_rev()
|
self.hw_rev = await self._client.hw_rev()
|
||||||
|
|
||||||
|
@asyncSlot()
|
||||||
|
async def end_session(self):
|
||||||
|
self.stop_watching()
|
||||||
|
|
||||||
|
if self.disconnect_cb is not None:
|
||||||
|
if asyncio.iscoroutinefunction(self.disconnect_cb):
|
||||||
|
await self.disconnect_cb()
|
||||||
|
else:
|
||||||
|
self.disconnect_cb()
|
||||||
|
|
||||||
|
await self._client.disconnect()
|
||||||
|
|
||||||
|
def start_watching(self):
|
||||||
|
self._watch_task = asyncio.create_task(self.run())
|
||||||
|
|
||||||
|
def stop_watching(self):
|
||||||
|
if self._watch_task is not None:
|
||||||
|
self._watch_task.cancel()
|
||||||
|
self._watch_task = None
|
||||||
|
self._update_params_task.cancel()
|
||||||
|
self._update_params_task = None
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
self._update_params_task = asyncio.create_task(self.update_params())
|
self._update_params_task = asyncio.create_task(self.update_params())
|
||||||
while True:
|
while True:
|
||||||
@ -74,27 +96,9 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
def connected(self):
|
def connected(self):
|
||||||
return self._client.connected()
|
return self._client.connected()
|
||||||
|
|
||||||
def start_watching(self):
|
@pyqtSlot(float)
|
||||||
self._watch_task = asyncio.create_task(self.run())
|
def set_update_s(self, update_s):
|
||||||
|
self._update_s = update_s
|
||||||
def stop_watching(self):
|
|
||||||
if self._watch_task is not None:
|
|
||||||
self._watch_task.cancel()
|
|
||||||
self._watch_task = None
|
|
||||||
self._update_params_task.cancel()
|
|
||||||
self._update_params_task = None
|
|
||||||
|
|
||||||
@asyncSlot()
|
|
||||||
async def end_session(self):
|
|
||||||
self.stop_watching()
|
|
||||||
|
|
||||||
if self.disconnect_cb is not None:
|
|
||||||
if asyncio.iscoroutinefunction(self.disconnect_cb):
|
|
||||||
await self.disconnect_cb()
|
|
||||||
else:
|
|
||||||
self.disconnect_cb()
|
|
||||||
|
|
||||||
await self._client.disconnect()
|
|
||||||
|
|
||||||
async def set_ipv4(self, ipv4):
|
async def set_ipv4(self, ipv4):
|
||||||
await self._client.set_param("ipv4", ipv4)
|
await self._client.set_param("ipv4", ipv4)
|
||||||
@ -116,10 +120,6 @@ class Thermostat(QObject, metaclass=PropertyMeta):
|
|||||||
async def reset(self):
|
async def reset(self):
|
||||||
await self._client.reset()
|
await self._client.reset()
|
||||||
|
|
||||||
@pyqtSlot(float)
|
|
||||||
def set_update_s(self, update_s):
|
|
||||||
self._update_s = update_s
|
|
||||||
|
|
||||||
async def set_fan(self, power="auto"):
|
async def set_fan(self, power="auto"):
|
||||||
await self._client.set_fan(power)
|
await self._client.set_fan(power)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user