mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-11 00:54:28 +05:00
fix get_port
This commit is contained in:
@@ -71,6 +71,7 @@ class MegaD:
|
|||||||
self._callbacks: typing.DefaultDict[int, typing.List[typing.Callable[[dict], typing.Coroutine]]] = defaultdict(list)
|
self._callbacks: typing.DefaultDict[int, typing.List[typing.Callable[[dict], typing.Coroutine]]] = defaultdict(list)
|
||||||
self._loop = loop
|
self._loop = loop
|
||||||
self.values = {}
|
self.values = {}
|
||||||
|
self.last_port = None
|
||||||
self.updater = DataUpdateCoordinator(
|
self.updater = DataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
self.lg,
|
self.lg,
|
||||||
@@ -176,7 +177,7 @@ class MegaD:
|
|||||||
qos=2,
|
qos=2,
|
||||||
retain=False,
|
retain=False,
|
||||||
)
|
)
|
||||||
await asyncio.wait_for(self.cnd.wait(), timeout=15)
|
await asyncio.wait_for(self.cnd.wait_for(lambda: self.last_port == port), timeout=15)
|
||||||
|
|
||||||
async def get_all_ports(self):
|
async def get_all_ports(self):
|
||||||
for x in range(37):
|
for x in range(37):
|
||||||
@@ -189,7 +190,8 @@ class MegaD:
|
|||||||
async with self.cnd:
|
async with self.cnd:
|
||||||
self.last_update = datetime.now()
|
self.last_update = datetime.now()
|
||||||
self.values[port] = value
|
self.values[port] = value
|
||||||
self.cnd.notify()
|
self.last_port = port
|
||||||
|
self.cnd.notify_all()
|
||||||
|
|
||||||
def _process_msg(self, msg):
|
def _process_msg(self, msg):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user