remove crap entities

This commit is contained in:
Andrey
2021-03-04 20:45:42 +03:00
parent 7135bb273e
commit 81d85ba1ed
8 changed files with 33 additions and 3 deletions

View File

@@ -57,6 +57,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
continue continue
hub.lg.debug(f'add binary_sensor on port %s', port) hub.lg.debug(f'add binary_sensor on port %s', port)
sensor = MegaBinarySensor(mega=hub, port=port, config_entry=config_entry) sensor = MegaBinarySensor(mega=hub, port=port, config_entry=config_entry)
if '<' in sensor.name:
continue
devices.append(sensor) devices.append(sensor)
async_add_devices(devices) async_add_devices(devices)

View File

@@ -11,7 +11,8 @@ from homeassistant.const import CONF_HOST, CONF_ID, CONF_PASSWORD, CONF_SCAN_INT
from homeassistant.core import callback, HomeAssistant from homeassistant.core import callback, HomeAssistant
from .const import DOMAIN, CONF_PORT_TO_SCAN, CONF_RELOAD, PLATFORMS, CONF_MQTT_INPUTS, \ 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_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 .hub import MegaD
from . import exceptions from . import exceptions
@@ -131,7 +132,10 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
cfg = dict(self.config_entry.data) cfg = dict(self.config_entry.data)
for x in PLATFORMS: for x in PLATFORMS:
cfg.pop(x, None) cfg.pop(x, None)
for x in REMOVE_CONFIG:
cfg.pop(x, default=None)
cfg.update(new) cfg.update(new)
cfg['new_naming'] = new_naming cfg['new_naming'] = new_naming
return self.async_create_entry( return self.async_create_entry(
title='', title='',

View File

@@ -55,4 +55,15 @@ LUX = 'lux'
SINGLE_CLICK = 'single' SINGLE_CLICK = 'single'
DOUBLE_CLICK = 'double' DOUBLE_CLICK = 'double'
PATT_FW = re.compile(r'fw:\s(.+)\)') PATT_FW = re.compile(r'fw:\s(.+)\)')
REMOVE_CONFIG = [
'extenders',
'ext_in',
'ext_acts',
'i2c_sensors',
'binary_sensor',
'light',
'i2c',
'sensor',
]

View File

@@ -69,6 +69,13 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
if self.http_cmd == 'ds2413': if self.http_cmd == 'ds2413':
self.mega.ds2413_ports |= {self.port} self.mega.ds2413_ports |= {self.port}
@property
def enabled(self):
if '<' in self.name:
return False
else:
return super().enabled
@property @property
def customize(self): def customize(self):
if self.hass is None: if self.hass is None:

View File

@@ -557,7 +557,7 @@ class MegaD:
ret['i2c_sensors'] = i2c_sensors = [] ret['i2c_sensors'] = i2c_sensors = []
async for port, cfg in self.scan_ports(nports): async for port, cfg in self.scan_ports(nports):
_cust = self.customize.get(port) _cust = self.customize.get(port)
if not isinstance(_customise, dict): if not isinstance(_cust, dict):
_cust = {} _cust = {}
if cfg.pty == "0": if cfg.pty == "0":
ret['binary_sensor'][port].append({}) ret['binary_sensor'][port].append({})

View File

@@ -69,6 +69,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
for data in cfg: for data in cfg:
hub.lg.debug(f'add light on port %s with data %s', port, data) 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) light = MegaLight(mega=hub, port=port, config_entry=config_entry, **data)
if '<' in light.name:
continue
devices.append(light) devices.append(light)
async_add_devices(devices) async_add_devices(devices)

View File

@@ -94,6 +94,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
config_entry=config_entry, config_entry=config_entry,
**data, **data,
) )
if '<' in sensor.name:
continue
devices.append(sensor) devices.append(sensor)
async_add_devices(devices) async_add_devices(devices)

View File

@@ -58,6 +58,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
for data in cfg: for data in cfg:
hub.lg.debug(f'add switch on port %s with data %s', port, data) 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) light = MegaSwitch(mega=hub, port=port, config_entry=config_entry, **data)
if '<' in light.name:
continue
devices.append(light) devices.append(light)
async_add_devices(devices) async_add_devices(devices)