- fixed loosing connection to Pot task

This commit is contained in:
jens
2020-12-02 17:19:12 +01:00
parent 6a6ca8c92d
commit b5cdb1a973
2 changed files with 12 additions and 7 deletions
+3 -2
View File
@@ -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
View File
@@ -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