Compare commits

..

3 Commits

Author SHA1 Message Date
Andrey
adb65529a2 hotfix 2021-01-14 23:05:30 +03:00
Andrey
768d46d952 hotfix 2021-01-14 22:48:07 +03:00
Andrey
359c6b99b7 hotfix 2021-01-14 22:27:07 +03:00
3 changed files with 15 additions and 13 deletions

View File

@@ -72,6 +72,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
asyncio.create_task(scan())
class MegaBinarySensor(BinarySensorEntity, BaseMegaEntity):
def __init__(self, *args, **kwargs):

View File

@@ -153,10 +153,12 @@ class MegaD:
try:
if '"value":NA' in msg.payload.decode():
ftr.set_result(None)
if not ftr.done():
ftr.set_result(None)
return
ret = json.loads(msg.payload).get('value')
ftr.set_result(ret)
if not ftr.done():
ftr.set_result(ret)
except Exception as exc:
ret = None
self.lg.exception(f'while parsing response from port {port}: {msg.payload}')
@@ -167,12 +169,12 @@ class MegaD:
)
async with self.lck:
unsub = await self.mqtt.async_subscribe(
topic=f'{self.mqtt_id}/{port}',
msg_callback=cb,
qos=1,
)
try:
unsub = await self.mqtt.async_subscribe(
topic=f'{self.mqtt_id}/{port}',
msg_callback=cb,
qos=1,
)
await self.mqtt.async_publish(
topic=f'{self.mqtt_id}/cmd',
payload=f'get:{port}',
@@ -268,8 +270,7 @@ class MegaD:
return pty, m
async def scan_ports(self,):
async with self.lck:
for x in range(38):
ret = await self.scan_port(x)
if ret:
yield [x, *ret]
for x in range(38):
ret = await self.scan_port(x)
if ret:
yield [x, *ret]

View File

@@ -95,7 +95,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
if values is None:
continue
if isinstance(values, str) and TEMP_PATT.search(values):
values = {TEMP: values}
values = {TEMP: values}
elif not isinstance(values, dict):
values = {None: values}
for key in values: