This commit is contained in:
Andrey
2021-01-14 23:05:30 +03:00
parent 768d46d952
commit adb65529a2

View File

@@ -153,10 +153,12 @@ class MegaD:
try: try:
if '"value":NA' in msg.payload.decode(): if '"value":NA' in msg.payload.decode():
ftr.set_result(None) if not ftr.done():
ftr.set_result(None)
return return
ret = json.loads(msg.payload).get('value') ret = json.loads(msg.payload).get('value')
ftr.set_result(ret) if not ftr.done():
ftr.set_result(ret)
except Exception as exc: except Exception as exc:
ret = None ret = None
self.lg.exception(f'while parsing response from port {port}: {msg.payload}') self.lg.exception(f'while parsing response from port {port}: {msg.payload}')
@@ -167,12 +169,12 @@ class MegaD:
) )
async with self.lck: async with self.lck:
unsub = await self.mqtt.async_subscribe(
topic=f'{self.mqtt_id}/{port}',
msg_callback=cb,
qos=1,
)
try: try:
unsub = await self.mqtt.async_subscribe(
topic=f'{self.mqtt_id}/{port}',
msg_callback=cb,
qos=1,
)
await self.mqtt.async_publish( await self.mqtt.async_publish(
topic=f'{self.mqtt_id}/cmd', topic=f'{self.mqtt_id}/cmd',
payload=f'get:{port}', payload=f'get:{port}',