mirror of
https://github.com/home-assistant/core.git
synced 2025-08-06 22:25:13 +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):
|
||||
"""Base class for ViCare entities."""
|
||||
|
||||
def __init__(self, device_config, has_multiple_devices: bool) -> None:
|
||||
"""Initialize the entity."""
|
||||
device_name = device_config.getModel()
|
||||
|
||||
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(
|
||||
identifiers={(DOMAIN, device_config.getConfig().serial)},
|
||||
|
@@ -174,21 +174,36 @@ async def async_setup_entry(
|
||||
|
||||
try:
|
||||
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:
|
||||
_LOGGER.info("No circuits found")
|
||||
|
||||
try:
|
||||
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:
|
||||
_LOGGER.info("No burners found")
|
||||
|
||||
try:
|
||||
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:
|
||||
_LOGGER.info("No compressors found")
|
||||
@@ -203,7 +218,12 @@ class ViCareBinarySensor(ViCareEntity, BinarySensorEntity):
|
||||
entity_description: ViCareBinarySensorEntityDescription
|
||||
|
||||
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:
|
||||
"""Initialize the sensor."""
|
||||
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."""
|
||||
_LOGGER.debug("Found device %s", name)
|
||||
try:
|
||||
@@ -113,7 +115,12 @@ class ViCareButton(ViCareEntity, ButtonEntity):
|
||||
entity_description: ViCareButtonEntityDescription
|
||||
|
||||
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:
|
||||
"""Initialize the button."""
|
||||
self.entity_description = description
|
||||
|
@@ -648,21 +648,36 @@ async def async_setup_entry(
|
||||
|
||||
try:
|
||||
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:
|
||||
_LOGGER.info("No circuits found")
|
||||
|
||||
try:
|
||||
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:
|
||||
_LOGGER.info("No burners found")
|
||||
|
||||
try:
|
||||
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:
|
||||
_LOGGER.info("No compressors found")
|
||||
@@ -677,7 +692,12 @@ class ViCareSensor(ViCareEntity, SensorEntity):
|
||||
entity_description: ViCareSensorEntityDescription
|
||||
|
||||
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:
|
||||
"""Initialize the sensor."""
|
||||
self.entity_description = description
|
||||
|
@@ -97,7 +97,7 @@ async def async_setup_entry(
|
||||
api,
|
||||
circuit,
|
||||
device,
|
||||
has_multiple_devices,
|
||||
has_multiple_devices,
|
||||
)
|
||||
entities.append(entity)
|
||||
|
||||
|
Reference in New Issue
Block a user