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:
@@ -19,3 +19,5 @@ first_value = 0
|
|||||||
[bumpversion:file:custom_components/mega/manifest.json]
|
[bumpversion:file:custom_components/mega/manifest.json]
|
||||||
search = "version": "v{current_version}"
|
search = "version": "v{current_version}"
|
||||||
replace = "version": "v{new_version}"
|
replace = "version": "v{new_version}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
|||||||
self.mega.ds2413_ports |= {self.port}
|
self.mega.ds2413_ports |= {self.port}
|
||||||
super().__init__(coordinator=mega.updater)
|
super().__init__(coordinator=mega.updater)
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_ws(self):
|
def is_ws(self):
|
||||||
return False
|
return False
|
||||||
@@ -131,9 +130,6 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
|||||||
return {}
|
return {}
|
||||||
if self._customize is None:
|
if self._customize is None:
|
||||||
c_entity_id = self.hass.data.get(DOMAIN, {}).get(CONF_CUSTOM).get('entities', {}).get(self.entity_id, {})
|
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 = self.hass.data.get(DOMAIN, {}).get(CONF_CUSTOM) or {}
|
||||||
c = c.get(self._mega_id) or {}
|
c = c.get(self._mega_id) or {}
|
||||||
c = c.get(self.port) or {}
|
c = c.get(self.port) or {}
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ class MegaD:
|
|||||||
def subscribe(self, port, callback):
|
def subscribe(self, port, callback):
|
||||||
port = int_ignore(port)
|
port = int_ignore(port)
|
||||||
self.lg.debug(
|
self.lg.debug(
|
||||||
f'subscribe %s %s', port, str(callback)
|
f'subscribe %s', port,
|
||||||
)
|
)
|
||||||
self.http.callbacks[self.id][port].append(callback)
|
self.http.callbacks[self.id][port].append(callback)
|
||||||
|
|
||||||
|
|||||||
@@ -41,41 +41,40 @@ def parse_scan_page(page: str):
|
|||||||
continue
|
continue
|
||||||
classes = i2c_classes.get(dev, [])
|
classes = i2c_classes.get(dev, [])
|
||||||
for i, c in enumerate(classes):
|
for i, c in enumerate(classes):
|
||||||
|
_params = params.copy()
|
||||||
if c is Skip:
|
if c is Skip:
|
||||||
continue
|
continue
|
||||||
elif c is Request:
|
elif c is Request:
|
||||||
req.append(params)
|
req.append(_params)
|
||||||
continue
|
continue
|
||||||
elif isinstance(c, Request):
|
elif isinstance(c, Request):
|
||||||
if c.delay:
|
if c.delay:
|
||||||
params = params.copy()
|
_params['delay'] = c.delay
|
||||||
params['delay'] = c.delay
|
req.append(_params)
|
||||||
req.append(params)
|
|
||||||
continue
|
continue
|
||||||
elif isinstance(c, DeviceType):
|
elif isinstance(c, DeviceType):
|
||||||
c, m, suffix, delay = astuple(c)
|
c, m, suffix, delay = astuple(c)
|
||||||
if delay is not None:
|
if delay is not None:
|
||||||
params['delay'] = delay
|
_params['delay'] = delay
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
suffix = suffix or c
|
suffix = suffix or c
|
||||||
if 'addr' in params:
|
if 'addr' in _params:
|
||||||
suffix += f"_{params['addr']}" if suffix else str(params['addr'])
|
suffix += f"_{_params['addr']}" if suffix else str(_params['addr'])
|
||||||
if suffix:
|
if suffix:
|
||||||
_dev = f'{dev}_{suffix}'
|
_dev = f'{dev}_{suffix}'
|
||||||
else:
|
else:
|
||||||
_dev = dev
|
_dev = dev
|
||||||
params = params.copy()
|
|
||||||
if i > 0:
|
if i > 0:
|
||||||
params['i2c_par'] = i
|
_params['i2c_par'] = i
|
||||||
|
|
||||||
ret.append({
|
ret.append({
|
||||||
'id_suffix': _dev,
|
'id_suffix': _dev,
|
||||||
'device_class': c,
|
'device_class': c,
|
||||||
'params': params,
|
'params': _params,
|
||||||
'unit_of_measurement': m,
|
'unit_of_measurement': m,
|
||||||
})
|
})
|
||||||
req.append(params)
|
req.append(_params)
|
||||||
return req, ret
|
return req, ret
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user