mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 06:35:10 +02:00
fix cdestyle findings
This commit is contained in:
@@ -93,11 +93,15 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
class ViCareEntity(Entity):
|
class ViCareEntity(Entity):
|
||||||
"""Base class for ViCare entities."""
|
"""Base class for ViCare entities."""
|
||||||
|
|
||||||
def __init__(self, device_config, has_multiple_devices: bool) -> None:
|
def __init__(self, device_config, has_multiple_devices: bool) -> None:
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
device_name = device_config.getModel()
|
device_name = device_config.getModel()
|
||||||
|
|
||||||
if has_multiple_devices:
|
if has_multiple_devices:
|
||||||
device_name = f"{device_config.getModel()}-{device_config.getConfig().serial}"
|
device_name = (
|
||||||
|
f"{device_config.getModel()}-{device_config.getConfig().serial}"
|
||||||
|
)
|
||||||
|
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, device_config.getConfig().serial)},
|
identifiers={(DOMAIN, device_config.getConfig().serial)},
|
||||||
|
@@ -174,21 +174,36 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
hass, entities, CIRCUIT_SENSORS, api.circuits, device, has_multiple_devices
|
hass,
|
||||||
|
entities,
|
||||||
|
CIRCUIT_SENSORS,
|
||||||
|
api.circuits,
|
||||||
|
device,
|
||||||
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
except PyViCareNotSupportedFeatureError:
|
except PyViCareNotSupportedFeatureError:
|
||||||
_LOGGER.info("No circuits found")
|
_LOGGER.info("No circuits found")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
hass, entities, BURNER_SENSORS, api.burners, device, has_multiple_devices
|
hass,
|
||||||
|
entities,
|
||||||
|
BURNER_SENSORS,
|
||||||
|
api.burners,
|
||||||
|
device,
|
||||||
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
except PyViCareNotSupportedFeatureError:
|
except PyViCareNotSupportedFeatureError:
|
||||||
_LOGGER.info("No burners found")
|
_LOGGER.info("No burners found")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
hass, entities, COMPRESSOR_SENSORS, api.compressors, device, has_multiple_devices
|
hass,
|
||||||
|
entities,
|
||||||
|
COMPRESSOR_SENSORS,
|
||||||
|
api.compressors,
|
||||||
|
device,
|
||||||
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
except PyViCareNotSupportedFeatureError:
|
except PyViCareNotSupportedFeatureError:
|
||||||
_LOGGER.info("No compressors found")
|
_LOGGER.info("No compressors found")
|
||||||
@@ -203,7 +218,12 @@ class ViCareBinarySensor(ViCareEntity, BinarySensorEntity):
|
|||||||
entity_description: ViCareBinarySensorEntityDescription
|
entity_description: ViCareBinarySensorEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, name, api, device_config, description: ViCareBinarySensorEntityDescription, has_multiple_devices: bool
|
self,
|
||||||
|
name,
|
||||||
|
api,
|
||||||
|
device_config,
|
||||||
|
description: ViCareBinarySensorEntityDescription,
|
||||||
|
has_multiple_devices: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
@@ -51,7 +51,9 @@ BUTTON_DESCRIPTIONS: tuple[ViCareButtonEntityDescription, ...] = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _build_entity(name, vicare_api, device_config, description, has_multiple_devices: bool):
|
def _build_entity(
|
||||||
|
name, vicare_api, device_config, description, has_multiple_devices: bool
|
||||||
|
):
|
||||||
"""Create a ViCare button entity."""
|
"""Create a ViCare button entity."""
|
||||||
_LOGGER.debug("Found device %s", name)
|
_LOGGER.debug("Found device %s", name)
|
||||||
try:
|
try:
|
||||||
@@ -113,7 +115,12 @@ class ViCareButton(ViCareEntity, ButtonEntity):
|
|||||||
entity_description: ViCareButtonEntityDescription
|
entity_description: ViCareButtonEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, name, api, device_config, description: ViCareButtonEntityDescription, has_multiple_devices: bool
|
self,
|
||||||
|
name,
|
||||||
|
api,
|
||||||
|
device_config,
|
||||||
|
description: ViCareButtonEntityDescription,
|
||||||
|
has_multiple_devices: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the button."""
|
"""Initialize the button."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
@@ -648,21 +648,36 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
hass, entities, CIRCUIT_SENSORS, api.circuits, device, has_multiple_devices
|
hass,
|
||||||
|
entities,
|
||||||
|
CIRCUIT_SENSORS,
|
||||||
|
api.circuits,
|
||||||
|
device,
|
||||||
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
except PyViCareNotSupportedFeatureError:
|
except PyViCareNotSupportedFeatureError:
|
||||||
_LOGGER.info("No circuits found")
|
_LOGGER.info("No circuits found")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
hass, entities, BURNER_SENSORS, api.burners, device, has_multiple_devices
|
hass,
|
||||||
|
entities,
|
||||||
|
BURNER_SENSORS,
|
||||||
|
api.burners,
|
||||||
|
device,
|
||||||
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
except PyViCareNotSupportedFeatureError:
|
except PyViCareNotSupportedFeatureError:
|
||||||
_LOGGER.info("No burners found")
|
_LOGGER.info("No burners found")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await _entities_from_descriptions(
|
await _entities_from_descriptions(
|
||||||
hass, entities, COMPRESSOR_SENSORS, api.compressors, device, has_multiple_devices
|
hass,
|
||||||
|
entities,
|
||||||
|
COMPRESSOR_SENSORS,
|
||||||
|
api.compressors,
|
||||||
|
device,
|
||||||
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
except PyViCareNotSupportedFeatureError:
|
except PyViCareNotSupportedFeatureError:
|
||||||
_LOGGER.info("No compressors found")
|
_LOGGER.info("No compressors found")
|
||||||
@@ -677,7 +692,12 @@ class ViCareSensor(ViCareEntity, SensorEntity):
|
|||||||
entity_description: ViCareSensorEntityDescription
|
entity_description: ViCareSensorEntityDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, name, api, device_config, description: ViCareSensorEntityDescription, has_multiple_devices: bool
|
self,
|
||||||
|
name,
|
||||||
|
api,
|
||||||
|
device_config,
|
||||||
|
description: ViCareSensorEntityDescription,
|
||||||
|
has_multiple_devices: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
@@ -97,7 +97,7 @@ async def async_setup_entry(
|
|||||||
api,
|
api,
|
||||||
circuit,
|
circuit,
|
||||||
device,
|
device,
|
||||||
has_multiple_devices,
|
has_multiple_devices,
|
||||||
)
|
)
|
||||||
entities.append(entity)
|
entities.append(entity)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user