mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-10 16:44:28 +05:00
remove crap entities
This commit is contained in:
@@ -57,6 +57,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
||||
continue
|
||||
hub.lg.debug(f'add binary_sensor on port %s', port)
|
||||
sensor = MegaBinarySensor(mega=hub, port=port, config_entry=config_entry)
|
||||
if '<' in sensor.name:
|
||||
continue
|
||||
devices.append(sensor)
|
||||
async_add_devices(devices)
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ from homeassistant.const import CONF_HOST, CONF_ID, CONF_PASSWORD, CONF_SCAN_INT
|
||||
from homeassistant.core import callback, HomeAssistant
|
||||
from .const import DOMAIN, CONF_PORT_TO_SCAN, CONF_RELOAD, PLATFORMS, CONF_MQTT_INPUTS, \
|
||||
CONF_NPORTS, CONF_UPDATE_ALL, CONF_POLL_OUTS, CONF_FAKE_RESPONSE, CONF_FORCE_D, \
|
||||
CONF_ALLOW_HOSTS, CONF_PROTECTED, CONF_RESTORE_ON_RESTART, CONF_UPDATE_TIME # pylint:disable=unused-import
|
||||
CONF_ALLOW_HOSTS, CONF_PROTECTED, CONF_RESTORE_ON_RESTART, CONF_UPDATE_TIME, \
|
||||
REMOVE_CONFIG # pylint:disable=unused-import
|
||||
from .hub import MegaD
|
||||
from . import exceptions
|
||||
|
||||
@@ -131,7 +132,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||
cfg = dict(self.config_entry.data)
|
||||
for x in PLATFORMS:
|
||||
cfg.pop(x, None)
|
||||
for x in REMOVE_CONFIG:
|
||||
cfg.pop(x, default=None)
|
||||
cfg.update(new)
|
||||
|
||||
cfg['new_naming'] = new_naming
|
||||
return self.async_create_entry(
|
||||
title='',
|
||||
|
||||
@@ -56,3 +56,14 @@ SINGLE_CLICK = 'single'
|
||||
DOUBLE_CLICK = 'double'
|
||||
|
||||
PATT_FW = re.compile(r'fw:\s(.+)\)')
|
||||
|
||||
REMOVE_CONFIG = [
|
||||
'extenders',
|
||||
'ext_in',
|
||||
'ext_acts',
|
||||
'i2c_sensors',
|
||||
'binary_sensor',
|
||||
'light',
|
||||
'i2c',
|
||||
'sensor',
|
||||
]
|
||||
@@ -69,6 +69,13 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
|
||||
if self.http_cmd == 'ds2413':
|
||||
self.mega.ds2413_ports |= {self.port}
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
if '<' in self.name:
|
||||
return False
|
||||
else:
|
||||
return super().enabled
|
||||
|
||||
@property
|
||||
def customize(self):
|
||||
if self.hass is None:
|
||||
|
||||
@@ -557,7 +557,7 @@ class MegaD:
|
||||
ret['i2c_sensors'] = i2c_sensors = []
|
||||
async for port, cfg in self.scan_ports(nports):
|
||||
_cust = self.customize.get(port)
|
||||
if not isinstance(_customise, dict):
|
||||
if not isinstance(_cust, dict):
|
||||
_cust = {}
|
||||
if cfg.pty == "0":
|
||||
ret['binary_sensor'][port].append({})
|
||||
|
||||
@@ -69,6 +69,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
||||
for data in cfg:
|
||||
hub.lg.debug(f'add light on port %s with data %s', port, data)
|
||||
light = MegaLight(mega=hub, port=port, config_entry=config_entry, **data)
|
||||
if '<' in light.name:
|
||||
continue
|
||||
devices.append(light)
|
||||
async_add_devices(devices)
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
||||
config_entry=config_entry,
|
||||
**data,
|
||||
)
|
||||
if '<' in sensor.name:
|
||||
continue
|
||||
devices.append(sensor)
|
||||
|
||||
async_add_devices(devices)
|
||||
|
||||
@@ -58,6 +58,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
|
||||
for data in cfg:
|
||||
hub.lg.debug(f'add switch on port %s with data %s', port, data)
|
||||
light = MegaSwitch(mega=hub, port=port, config_entry=config_entry, **data)
|
||||
if '<' in light.name:
|
||||
continue
|
||||
devices.append(light)
|
||||
async_add_devices(devices)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user