mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 01:24:29 +05:00
fix multiple megas
This commit is contained in:
@@ -26,8 +26,7 @@ class MegaView(HomeAssistantView):
|
|||||||
def __init__(self, cfg: dict):
|
def __init__(self, cfg: dict):
|
||||||
self._try = 0
|
self._try = 0
|
||||||
self.allowed_hosts = {'::1'}
|
self.allowed_hosts = {'::1'}
|
||||||
self.callbacks: typing.DefaultDict[int, typing.List[typing.Callable[[dict], typing.Coroutine]]] \
|
self.callbacks = defaultdict(lambda: defaultdict(list))
|
||||||
= defaultdict(list)
|
|
||||||
self.templates: typing.Dict[str, typing.Dict[str, Template]] = {
|
self.templates: typing.Dict[str, typing.Dict[str, Template]] = {
|
||||||
mid: {
|
mid: {
|
||||||
pt: cfg[mid][pt][CONF_RESPONSE_TEMPLATE]
|
pt: cfg[mid][pt][CONF_RESPONSE_TEMPLATE]
|
||||||
@@ -64,7 +63,7 @@ class MegaView(HomeAssistantView):
|
|||||||
data = data.copy()
|
data = data.copy()
|
||||||
ret = 'd'
|
ret = 'd'
|
||||||
if port is not None:
|
if port is not None:
|
||||||
for cb in self.callbacks[port]:
|
for cb in self.callbacks[hub.id][port]:
|
||||||
cb(data)
|
cb(data)
|
||||||
template: Template = self.templates.get(hub.id, {}).get(port)
|
template: Template = self.templates.get(hub.id, {}).get(port)
|
||||||
if hub.update_all:
|
if hub.update_all:
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class MegaD:
|
|||||||
if self.mqtt_inputs:
|
if self.mqtt_inputs:
|
||||||
self._callbacks[port].append(callback)
|
self._callbacks[port].append(callback)
|
||||||
else:
|
else:
|
||||||
self.http.callbacks[port].append(callback)
|
self.http.callbacks[self.id][port].append(callback)
|
||||||
|
|
||||||
async def authenticate(self) -> bool:
|
async def authenticate(self) -> bool:
|
||||||
"""Test if we can authenticate with the host."""
|
"""Test if we can authenticate with the host."""
|
||||||
|
|||||||
Reference in New Issue
Block a user