Skip to content

Commit

Permalink
fixed linter problems
Browse files Browse the repository at this point in the history
  • Loading branch information
toggm committed Nov 22, 2024
1 parent 17abb9e commit b84c576
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 38 deletions.
3 changes: 1 addition & 2 deletions custom_components/askoheat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from homeassistant.const import CONF_HOST, CONF_PORT, Platform
from homeassistant.loader import async_get_loaded_integration

from .api import AskoHeatModbusApiClient
from .coordinator import (
AskoheatConfigDataUpdateCoordinator,
AskoheatEMADataUpdateCoordinator,
Expand All @@ -20,8 +21,6 @@
)
from .data import AskoheatData

from .api import AskoHeatModbusApiClient

if TYPE_CHECKING:
from homeassistant.core import HomeAssistant

Expand Down
14 changes: 6 additions & 8 deletions custom_components/askoheat/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

from __future__ import annotations

import struct
from datetime import time
from enum import ReprEnum
from struct import unpack
import struct
from tracemalloc import start
from typing import TYPE_CHECKING, Any, TypeVar, cast

import numpy as np
from numpy import byte, number
from numpy import number
from pymodbus.client import AsyncModbusTcpClient as ModbusClient

from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
Expand All @@ -31,7 +29,7 @@
)
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_op_desc import DATA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.const import (
LOGGER,
)
Expand Down Expand Up @@ -103,11 +101,11 @@ async def async_write_ema_data(
async def async_read_par_data(self) -> AskoheatDataBlock:
"""Read PAR states."""
data = await self.__async_read_input_registers_data(
PARAMETER_REGISTER_BLOCK_DESCRIPTOR.starting_register,
PARAMETER_REGISTER_BLOCK_DESCRIPTOR.number_of_registers,
PARAM_REGISTER_BLOCK_DESCRIPTOR.starting_register,
PARAM_REGISTER_BLOCK_DESCRIPTOR.number_of_registers,
)
LOGGER.debug("async_read_par_data %s", data)
return self.__map_data(PARAMETER_REGISTER_BLOCK_DESCRIPTOR, data)
return self.__map_data(PARAM_REGISTER_BLOCK_DESCRIPTOR, data)

async def async_read_config_data(self) -> AskoheatDataBlock:
"""Read EMA states."""
Expand Down
2 changes: 0 additions & 2 deletions custom_components/askoheat/api_desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import ctypes
from struct import pack
import typing
from abc import ABC
from dataclasses import dataclass, field
Expand Down
2 changes: 1 addition & 1 deletion custom_components/askoheat/api_par_desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
AskoheatSensorEntityDescription,
)

PARAMETER_REGISTER_BLOCK_DESCRIPTOR = RegisterBlockDescriptor(
PARAM_REGISTER_BLOCK_DESCRIPTOR = RegisterBlockDescriptor(
starting_register=400,
number_of_registers=56,
sensors=[
Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_op_desc import DATA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.model import AskoheatBinarySensorEntityDescription

from .entity import AskoheatEntity
Expand Down Expand Up @@ -41,7 +41,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.binary_sensors # noqa: E501
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.binary_sensors
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
AskoheatModbusApiClientError,
)
from .const import (
CONF_DEVICE_UNIQUE_ID,
DEFAULT_HOST,
DEFAULT_PORT,
DOMAIN,
Expand Down Expand Up @@ -71,7 +70,8 @@ async def async_step_user(
_errors["base"] = "unknown"
else:
LOGGER.debug(
"Successfully connected to askoheat instance, received parameters: %s",
"Successfully connected to askoheat instance, "
"received parameters: %s",
parameters,
)
article_name = parameters[f"sensor.{SensorAttrKey.PAR_ARTICLE_NAME}"]
Expand Down
8 changes: 5 additions & 3 deletions custom_components/askoheat/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
DOMAIN,
LOGGER,
SCAN_INTERVAL_CONFIG,
SCAN_INTERVAL_OP_DATA,
SCAN_INTERVAL_EMA,
SCAN_INTERVAL_OP_DATA,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -156,7 +156,8 @@ async def load_parameters(self, client: AskoHeatModbusApiClient) -> dict[str, An

async def async_write(self, _: RegisterInputDescriptor, __: object) -> None:
"""Write parameter par block of Askoheat."""
raise UpdateFailed("Writing values to parameters not allowed")
msg = "Writing values to parameters not allowed"
raise UpdateFailed(msg)


class AskoheatOperationDataUpdateCoordinator(AskoheatDataUpdateCoordinator):
Expand All @@ -177,7 +178,8 @@ async def _async_update_data(self) -> dict[str, Any]:

async def async_write(self, _: RegisterInputDescriptor, __: object) -> None:
"""Write parameter data block of Askoheat."""
raise UpdateFailed("Writing values to data block not allowed")
msg = "Writing values to data block not allowed"
raise UpdateFailed(msg)


def _map_data_block_to_dict(data: AskoheatDataBlock) -> dict[str, Any]:
Expand Down
8 changes: 5 additions & 3 deletions custom_components/askoheat/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

from __future__ import annotations

from typing import TypeVar
from typing import TYPE_CHECKING, TypeVar

from homeassistant.core import callback
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from custom_components.askoheat.model import AskoheatEntityDescription

from .const import ATTRIBUTION, CONF_DEVICE_UNIQUE_ID, LOGGER, DeviceKey
from .const import ATTRIBUTION, DeviceKey
from .coordinator import AskoheatDataUpdateCoordinator
from .data import AskoheatConfigEntry

if TYPE_CHECKING:
from .data import AskoheatConfigEntry

E = TypeVar("E", bound=AskoheatEntityDescription)

Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.const import LOGGER
from custom_components.askoheat.model import (
AskoheatNumberEntityDescription,
Expand Down Expand Up @@ -40,7 +40,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.number_inputs
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.number_inputs
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.const import LOGGER
from custom_components.askoheat.coordinator import AskoheatDataUpdateCoordinator
from custom_components.askoheat.model import (
Expand All @@ -34,7 +34,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.select_inputs
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.select_inputs
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down
10 changes: 5 additions & 5 deletions custom_components/askoheat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

from datetime import date, datetime
from decimal import Decimal
from typing import TYPE_CHECKING, Any

import numpy as np
Expand All @@ -14,16 +12,18 @@
from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_op_desc import DATA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.model import (
AskoheatDurationSensorEntityDescription,
AskoheatSensorEntityDescription,
)

from .entity import AskoheatEntity
from custom_components.askoheat import entity

if TYPE_CHECKING:
from datetime import date, datetime
from decimal import Decimal

from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
Expand Down Expand Up @@ -67,7 +67,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.sensors
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.sensors
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.const import LOGGER
from custom_components.askoheat.model import AskoheatSwitchEntityDescription

Expand Down Expand Up @@ -38,7 +38,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.switches
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.switches
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.const import LOGGER
from custom_components.askoheat.coordinator import AskoheatDataUpdateCoordinator
from custom_components.askoheat.model import (
Expand All @@ -32,7 +32,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.text_inputs
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.text_inputs
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down
4 changes: 2 additions & 2 deletions custom_components/askoheat/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from custom_components.askoheat.api_conf_desc import CONF_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_ema_desc import EMA_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAMETER_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.api_par_desc import PARAM_REGISTER_BLOCK_DESCRIPTOR
from custom_components.askoheat.const import LOGGER
from custom_components.askoheat.coordinator import AskoheatDataUpdateCoordinator
from custom_components.askoheat.model import AskoheatTimeEntityDescription
Expand All @@ -32,7 +32,7 @@ async def async_setup_entry(
for entity_description, coordinator in {
**{
entity_description: entry.runtime_data.par_coordinator
for entity_description in PARAMETER_REGISTER_BLOCK_DESCRIPTOR.time_inputs
for entity_description in PARAM_REGISTER_BLOCK_DESCRIPTOR.time_inputs
},
**{
entity_description: entry.runtime_data.ema_coordinator
Expand Down

0 comments on commit b84c576

Please sign in to comment.