Code linting
This commit is contained in:
@@ -31,18 +31,20 @@ def get_alias(hass, deviceID):
|
||||
|
||||
def get_config(hass, deviceID):
|
||||
config = hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DEVICES, {})
|
||||
return config.get(deviceID, config.get(deviceID.replace('-', '_'), {}))
|
||||
return config.get(deviceID, config.get(deviceID.replace("-", "_"), {}))
|
||||
|
||||
|
||||
def create_entity(hass, platform, deviceID, connection):
|
||||
conf = get_config(hass, deviceID)
|
||||
if conf and (platform in conf.get(CONFIG_DISABLE, [])
|
||||
or CONFIG_DISABLE_ALL in conf.get(CONFIG_DISABLE, [])):
|
||||
if conf and (
|
||||
platform in conf.get(CONFIG_DISABLE, [])
|
||||
or CONFIG_DISABLE_ALL in conf.get(CONFIG_DISABLE, [])
|
||||
):
|
||||
return None
|
||||
if not conf and \
|
||||
(platform in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])
|
||||
or CONFIG_DISABLE_ALL in
|
||||
hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])):
|
||||
if not conf and (
|
||||
platform in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])
|
||||
or CONFIG_DISABLE_ALL in hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_DISABLE, [])
|
||||
):
|
||||
return None
|
||||
adder = hass.data[DOMAIN][DATA_ADDERS][platform]
|
||||
entity = adder(hass, deviceID, connection, get_alias(hass, deviceID))
|
||||
@@ -57,6 +59,7 @@ def setup_platform(hass, config, async_add_devices, platform, cls):
|
||||
entity = cls(hass, connection, deviceID, alias)
|
||||
async_add_devices([entity])
|
||||
return entity
|
||||
|
||||
hass.data[DOMAIN][DATA_ADDERS][platform] = adder
|
||||
return True
|
||||
|
||||
@@ -66,19 +69,16 @@ def is_setup_complete(hass):
|
||||
|
||||
|
||||
class BrowserModEntity(Entity):
|
||||
|
||||
def __init__(self, hass, connection, deviceID, alias=None):
|
||||
self.hass = hass
|
||||
self.connection = connection
|
||||
self.deviceID = deviceID
|
||||
self._data = {}
|
||||
self._alias = alias
|
||||
prefix = hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_PREFIX, '')
|
||||
prefix = hass.data[DOMAIN][DATA_CONFIG].get(CONFIG_PREFIX, "")
|
||||
self.entity_id = async_generate_entity_id(
|
||||
self.domain+".{}",
|
||||
alias or f"{prefix}{deviceID}",
|
||||
hass=hass
|
||||
)
|
||||
self.domain + ".{}", alias or f"{prefix}{deviceID}", hass=hass
|
||||
)
|
||||
|
||||
def updated(self):
|
||||
pass
|
||||
@@ -86,10 +86,8 @@ class BrowserModEntity(Entity):
|
||||
@property
|
||||
def device_info(self):
|
||||
return {
|
||||
"identifiers": {
|
||||
(DOMAIN, self.deviceID)
|
||||
},
|
||||
"name": self._alias or self.deviceID
|
||||
"identifiers": {(DOMAIN, self.deviceID)},
|
||||
"name": self._alias or self.deviceID,
|
||||
}
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user