- fixed loosing connection to Pot task
This commit is contained in:
+3
-2
@@ -61,8 +61,9 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
|
||||
def on_pot_changed(self, msg):
|
||||
print("on_pot_changed {}".format(msg))
|
||||
if "Power" in msg:
|
||||
self.lcdNumber_2.display(msg['Power'])
|
||||
for key in msg:
|
||||
if "Power" in key:
|
||||
self.lcdNumber_2.display(msg['Power'])
|
||||
|
||||
def on_sensor_changed(self, msg):
|
||||
print("on_sensor_changed {}".format(msg))
|
||||
|
||||
+9
-5
@@ -113,10 +113,13 @@ class MessageDispatcherSync(IConnection):
|
||||
|
||||
async def on_connect(self):
|
||||
if self.auto_subscribe:
|
||||
for handler in self.msg_handlers:
|
||||
key = handler.get_key()
|
||||
print("Would subscribe {}".format(key))
|
||||
asyncio.get_event_loop().run_in_executor(None, self.send, {'+': key})
|
||||
asyncio.get_event_loop().run_in_executor(None, self.subscribe)
|
||||
|
||||
def subscribe(self):
|
||||
for handler in self.msg_handlers:
|
||||
key = handler.get_key()
|
||||
print("Would subscribe {}".format(key))
|
||||
self.send({'+': key})
|
||||
|
||||
async def on_disconnect(self):
|
||||
pass
|
||||
@@ -132,7 +135,8 @@ class MessageDispatcherSync(IConnection):
|
||||
result = None
|
||||
try:
|
||||
result = await asyncio.get_event_loop().run_in_executor(None, self.state.get, True, 1.0)
|
||||
except:
|
||||
print("Send subscribe {}".format(result))
|
||||
except Exception as e:
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user