mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-12 01:24:29 +05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a71be693e | ||
|
|
8146148d0c | ||
|
|
e0eaafd0fa | ||
|
|
51f3eb3b19 | ||
|
|
1716651497 | ||
|
|
a87e8139a7 |
@@ -48,8 +48,9 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
index=None,
|
||||
):
|
||||
super().__init__(mega.updater)
|
||||
if self.http_cmd == 'ds2413':
|
||||
self.mega.ds2413_ports |= {self.port}
|
||||
|
||||
self.http_cmd = http_cmd
|
||||
|
||||
self._state: State = None
|
||||
self.port = port
|
||||
self.config_entry = config_entry
|
||||
@@ -62,9 +63,10 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
self._name = name or f"{mega.id}_{port}" + \
|
||||
(f"_{id_suffix}" if id_suffix else "")
|
||||
self._customize: dict = None
|
||||
self.http_cmd = http_cmd
|
||||
self.index = index
|
||||
self.addr = addr
|
||||
if self.http_cmd == 'ds2413':
|
||||
self.mega.ds2413_ports |= {self.port}
|
||||
|
||||
@property
|
||||
def customize(self):
|
||||
@@ -253,17 +255,17 @@ class MegaOutPort(MegaPushEntity):
|
||||
val = val.get("value")
|
||||
if self.index and self.addr:
|
||||
if not isinstance(val, dict):
|
||||
self.mega.lg.warning(f'{self.entity_id} has wrong state: {val}')
|
||||
self.mega.lg.warning(f'{self.entity_id}: {val} is not a dict')
|
||||
return
|
||||
_val = val.get(self.addr)
|
||||
if not isinstance(val, str):
|
||||
self.mega.lg.warning(f'{self.entity_id} has wrong state: {val}')
|
||||
_val = val.get(self.addr, val.get(self.addr.lower(), val.get(self.addr.upper())))
|
||||
if not isinstance(_val, str):
|
||||
self.mega.lg.warning(f'{self.entity_id}: can not get {self.addr} from {val}, recieved {_val}')
|
||||
return
|
||||
_val = _val.split('/')
|
||||
if len(_val) >= 2:
|
||||
val = val[self.index]
|
||||
val = _val[self.index]
|
||||
else:
|
||||
self.mega.lg.warning(f'{self.entity_id} has wrong state: {val}')
|
||||
self.mega.lg.warning(f'{self.entity_id}: {_val} has wrong length')
|
||||
return
|
||||
elif self.index and self.addr is None:
|
||||
self.mega.lg.warning(f'{self.entity_id} does not has addr')
|
||||
|
||||
@@ -198,14 +198,13 @@ class MegaD:
|
||||
:return:
|
||||
"""
|
||||
for x in self.ds2413_ports:
|
||||
if x.http_cmd == 'ds2413':
|
||||
self.lg.debug(f'poll ds2413 for %s', x)
|
||||
await self.get_port(
|
||||
port=x,
|
||||
force_http=True,
|
||||
http_cmd='list',
|
||||
conv=False
|
||||
)
|
||||
self.lg.debug(f'poll ds2413 for %s', x)
|
||||
await self.get_port(
|
||||
port=x,
|
||||
force_http=True,
|
||||
http_cmd='list',
|
||||
conv=False
|
||||
)
|
||||
|
||||
async def poll(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user