Skip to content

Commit

Permalink
Small fix code stykle ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
jontofront committed Jan 11, 2024
1 parent cac9834 commit 46065f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions custom_components/econet300/common_functions.py
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 4 additions & 4 deletions custom_components/econet300/const.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion custom_components/econet300/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions custom_components/econet300/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Any

from homeassistant.components.sensor import (
SensorEntityDescription,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
Expand All @@ -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__)
Expand All @@ -44,7 +42,7 @@ class EconetSensorEntityDescription(SensorEntityDescription):


class EconetSensor(EconetEntity, SensorEntity):
"""Econet Sensor"""
"""Econet Sensor."""

entity_description: EconetSensorEntityDescription

Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 46065f5

Please sign in to comment.