diff --git a/custom_components/econet300/common_functions.py b/custom_components/econet300/common_functions.py index 3b0c7c7..5c3817a 100644 --- a/custom_components/econet300/common_functions.py +++ b/custom_components/econet300/common_functions.py @@ -1,8 +1,8 @@ -"""Functionsd used in Econet300 integration""" +"""Functionsd used in Econet300 integration,.""" import re def camel_to_snake(key: str) -> str: - """Converting camel case return from api ti snake case to mach translations keys structure""" + """Convert camel case return from API to snake case to match translations keys structure.""" key = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", key) return re.sub("([a-z0-9])([A-Z])", r"\1_\2", key).lower() diff --git a/custom_components/econet300/const.py b/custom_components/econet300/const.py index cfb528c..06df908 100644 --- a/custom_components/econet300/const.py +++ b/custom_components/econet300/const.py @@ -1,11 +1,11 @@ -"""Constants from the Home Assistant""" -from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass +"""Constants from the Home Assistant.""" from homeassistant.components.binary_sensor import BinarySensorDeviceClass +from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.const import ( - UnitOfTemperature, - EntityCategory, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, + EntityCategory, + UnitOfTemperature, ) # Constant for the econet Integration integration diff --git a/custom_components/econet300/number.py b/custom_components/econet300/number.py index 50c6807..9ebb9bc 100644 --- a/custom_components/econet300/number.py +++ b/custom_components/econet300/number.py @@ -85,7 +85,7 @@ def __init__( ) def _sync_state(self, value): - """Sync state""" + """Sync state.""" _LOGGER.debug("EconetNumber _sync_state: %s", value) self._attr_native_value = value diff --git a/custom_components/econet300/sensor.py b/custom_components/econet300/sensor.py index 94e3793..08170ec 100644 --- a/custom_components/econet300/sensor.py +++ b/custom_components/econet300/sensor.py @@ -5,7 +5,6 @@ from typing import Any from homeassistant.components.sensor import ( - SensorEntityDescription, SensorEntity, SensorEntityDescription, SensorStateClass, @@ -14,23 +13,22 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback +from .common import Econet300Api, EconetDataCoordinator from .common_functions import camel_to_snake -from .common import EconetDataCoordinator, Econet300Api from .const import ( AVAILABLE_NUMBER_OF_MIXERS, DOMAIN, + ENTITY_CATEGORY, ENTITY_DEVICE_CLASS_MAP, - STATE_CLASS_MAP, - SERVICE_COORDINATOR, - SERVICE_API, - SENSOR_MAP, + ENTITY_ICON, ENTITY_PRECISION, ENTITY_UNIT_MAP, ENTITY_VALUE_PROCESSOR, - ENTITY_CATEGORY, - ENTITY_ICON, + SENSOR_MAP, + SERVICE_API, + SERVICE_COORDINATOR, + STATE_CLASS_MAP, ) - from .entity import EconetEntity, MixerEntity _LOGGER = logging.getLogger(__name__) @@ -44,7 +42,7 @@ class EconetSensorEntityDescription(SensorEntityDescription): class EconetSensor(EconetEntity, SensorEntity): - """Econet Sensor""" + """Econet Sensor.""" entity_description: EconetSensorEntityDescription @@ -87,7 +85,7 @@ def __init__( def create_entity_description(key: str) -> EconetSensorEntityDescription: - """Creates Econect300 sensor entity based on supplied key""" + """Create Econect300 sensor entity based on supplied key.""" map_key = SENSOR_MAP.get(key, key) _LOGGER.debug("SENSOR_MAP: %s", SENSOR_MAP) _LOGGER.debug("Creating entity description for key: %s, map_key: %s", key, map_key) @@ -107,7 +105,7 @@ def create_entity_description(key: str) -> EconetSensorEntityDescription: def create_controller_sensors(coordinator: EconetDataCoordinator, api: Econet300Api): - """Creating controller sensor entities""" + """Create controller sensor entities.""" entities: list[EconetSensor] = [] coordinator_data = coordinator.data for data_key in SENSOR_MAP: