diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 3444ace..10172e9 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -193,14 +193,12 @@ class MainWindow(QtWidgets.QMainWindow): async def on_connect_btn_clicked(self): match self._thermostat.connection_state: case ThermostatConnectionState.DISCONNECTED: - self._connecting_task = asyncio.create_task( - self._thermostat.start_session( - host=self.connection_details_menu.host_set_line.text(), - port=self.connection_details_menu.port_set_spin.value(), - ) - ) + self._connecting_task = asyncio.current_task() self._thermostat.connection_state = ThermostatConnectionState.CONNECTING - await self._connecting_task + await self._thermostat.start_session( + host=self.connection_details_menu.host_set_line.text(), + port=self.connection_details_menu.port_set_spin.value(), + ) self._connecting_task = None self._thermostat.connection_state = ThermostatConnectionState.CONNECTED self._thermostat.start_watching()