This commit is contained in:
atse 2024-08-22 12:33:30 +08:00
parent f7665ea736
commit 12a3154493

View File

@ -241,17 +241,16 @@ class MainWindow(QtWidgets.QMainWindow):
@asyncSlot() @asyncSlot()
async def on_connect_btn_clicked(self): async def on_connect_btn_clicked(self):
host, port = (
self.conn_menu.host_set_line.text(),
self.conn_menu.port_set_spin.value(),
)
if (self._connecting_task is None) and (not self.thermostat.connected()): if (self._connecting_task is None) and (not self.thermostat.connected()):
self.status_lbl.setText("Connecting...") self.status_lbl.setText("Connecting...")
self.connect_btn.setText("Stop") self.connect_btn.setText("Stop")
self.conn_menu.host_set_line.setEnabled(False) self.conn_menu.host_set_line.setEnabled(False)
self.conn_menu.port_set_spin.setEnabled(False) self.conn_menu.port_set_spin.setEnabled(False)
host, port = (
self.conn_menu.host_set_line.text(),
self.conn_menu.port_set_spin.value(),
)
self._connecting_task = asyncio.create_task( self._connecting_task = asyncio.create_task(
asyncio.wait_for( asyncio.wait_for(
self.thermostat.start_session(host=host, port=port), timeout=5 self.thermostat.start_session(host=host, port=port), timeout=5