mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-11 00:54:28 +05:00
new config adressation
This commit is contained in:
@@ -86,7 +86,6 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
self.mega.ds2413_ports |= {self.port}
|
||||
super().__init__(coordinator=mega.updater)
|
||||
|
||||
|
||||
@property
|
||||
def is_ws(self):
|
||||
return False
|
||||
@@ -131,9 +130,6 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
return {}
|
||||
if self._customize is None:
|
||||
c_entity_id = self.hass.data.get(DOMAIN, {}).get(CONF_CUSTOM).get('entities', {}).get(self.entity_id, {})
|
||||
self.lg.debug(
|
||||
'customize %s with %s', self.entity_id, c_entity_id
|
||||
)
|
||||
c = self.hass.data.get(DOMAIN, {}).get(CONF_CUSTOM) or {}
|
||||
c = c.get(self._mega_id) or {}
|
||||
c = c.get(self.port) or {}
|
||||
|
||||
@@ -427,7 +427,7 @@ class MegaD:
|
||||
def subscribe(self, port, callback):
|
||||
port = int_ignore(port)
|
||||
self.lg.debug(
|
||||
f'subscribe %s %s', port, str(callback)
|
||||
f'subscribe %s', port,
|
||||
)
|
||||
self.http.callbacks[self.id][port].append(callback)
|
||||
|
||||
|
||||
@@ -41,41 +41,40 @@ def parse_scan_page(page: str):
|
||||
continue
|
||||
classes = i2c_classes.get(dev, [])
|
||||
for i, c in enumerate(classes):
|
||||
_params = params.copy()
|
||||
if c is Skip:
|
||||
continue
|
||||
elif c is Request:
|
||||
req.append(params)
|
||||
req.append(_params)
|
||||
continue
|
||||
elif isinstance(c, Request):
|
||||
if c.delay:
|
||||
params = params.copy()
|
||||
params['delay'] = c.delay
|
||||
req.append(params)
|
||||
_params['delay'] = c.delay
|
||||
req.append(_params)
|
||||
continue
|
||||
elif isinstance(c, DeviceType):
|
||||
c, m, suffix, delay = astuple(c)
|
||||
if delay is not None:
|
||||
params['delay'] = delay
|
||||
_params['delay'] = delay
|
||||
else:
|
||||
continue
|
||||
suffix = suffix or c
|
||||
if 'addr' in params:
|
||||
suffix += f"_{params['addr']}" if suffix else str(params['addr'])
|
||||
if 'addr' in _params:
|
||||
suffix += f"_{_params['addr']}" if suffix else str(_params['addr'])
|
||||
if suffix:
|
||||
_dev = f'{dev}_{suffix}'
|
||||
else:
|
||||
_dev = dev
|
||||
params = params.copy()
|
||||
if i > 0:
|
||||
params['i2c_par'] = i
|
||||
_params['i2c_par'] = i
|
||||
|
||||
ret.append({
|
||||
'id_suffix': _dev,
|
||||
'device_class': c,
|
||||
'params': params,
|
||||
'params': _params,
|
||||
'unit_of_measurement': m,
|
||||
})
|
||||
req.append(params)
|
||||
req.append(_params)
|
||||
return req, ret
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user