Skip to content

Commit

Permalink
Static typing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp committed Oct 26, 2024
1 parent d828e49 commit 19cd9ce
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 23 deletions.
4 changes: 1 addition & 3 deletions custom_components/hive_local_thermostat/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from .entity import HiveEntity, HiveEntityDescription


@dataclass
@dataclass(frozen=True, kw_only=True)
class HiveButtonEntityDescription(
HiveEntityDescription,
ButtonEntityDescription,
Expand Down Expand Up @@ -66,8 +66,6 @@ async def async_setup_entry(
)
)

_entities = {}

_entities = [
HiveButton(
entity_description=entity_description,
Expand Down
4 changes: 1 addition & 3 deletions custom_components/hive_local_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}


@dataclass
@dataclass(frozen=True, kw_only=True)
class HiveClimateEntityDescription(
HiveEntityDescription,
ClimateEntityDescription,
Expand All @@ -58,8 +58,6 @@ async def async_setup_entry(
):
"""Set up the sensor platform."""

_entities = {}

hive_climate_entity_description = HiveClimateEntityDescription(
key="climate",
translation_key="climate",
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hive_local_thermostat/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from .const import DOMAIN


@dataclass
@dataclass(frozen=True, kw_only=True)
class HiveEntityDescription(EntityDescription):
"""Defines a base Hive entity description."""

entity_id: str | None = None
topic: str | None = None
topic: str
entry_id: str | None = None
icons_by_state: dict | None = None
icons_by_state: dict[str, str] | None = None
model: str | None = None

class HiveEntity(Entity):
Expand Down
15 changes: 7 additions & 8 deletions custom_components/hive_local_thermostat/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from .const import (
CONF_MODEL,
CONF_MQTT_TOPIC,
DEFAULT_FROST_TEMPERATURE,
DEFAULT_HEATING_BOOST_MINUTES,
DEFAULT_HEATING_BOOST_TEMPERATURE,
Expand All @@ -35,7 +36,7 @@
from .entity import HiveEntity, HiveEntityDescription


@dataclass
@dataclass(frozen=True, kw_only=True)
class HiveNumberEntityDescription(
HiveEntityDescription,
NumberEntityDescription,
Expand All @@ -58,7 +59,7 @@ async def async_setup_entry(
translation_key="heating_boost_duration",
name=config_entry.title,
icon="mdi:timer",
topic=None,
topic=config_entry.options[CONF_MQTT_TOPIC],
entity_category=EntityCategory.CONFIG,
native_min_value=30,
native_max_value=180,
Expand All @@ -72,7 +73,7 @@ async def async_setup_entry(
translation_key="heating_frost_prevention",
name=config_entry.title,
icon="mdi:snowflake-thermometer",
topic=None,
topic=config_entry.options[CONF_MQTT_TOPIC],
entity_category=EntityCategory.CONFIG,
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
Expand All @@ -88,7 +89,7 @@ async def async_setup_entry(
translation_key="heating_default_temperature",
name=config_entry.title,
icon="mdi:thermometer",
topic=None,
topic=config_entry.options[CONF_MQTT_TOPIC],
entity_category=EntityCategory.CONFIG,
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
Expand All @@ -104,7 +105,7 @@ async def async_setup_entry(
translation_key="heating_boost_temperature",
name=config_entry.title,
icon="mdi:thermometer",
topic=None,
topic=config_entry.options[CONF_MQTT_TOPIC],
entity_category=EntityCategory.CONFIG,
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
Expand All @@ -124,7 +125,7 @@ async def async_setup_entry(
translation_key="water_boost_duration",
name=config_entry.title,
icon="mdi:timer",
topic=None,
topic=config_entry.options[CONF_MQTT_TOPIC],
entity_category=EntityCategory.CONFIG,
native_min_value=30,
native_max_value=180,
Expand All @@ -135,8 +136,6 @@ async def async_setup_entry(
)
)

_entities = {}

_entities = [
HiveNumber(
entity_description=entity_description,
Expand Down
4 changes: 1 addition & 3 deletions custom_components/hive_local_thermostat/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from .entity import HiveEntity, HiveEntityDescription


@dataclass
@dataclass(frozen=True, kw_only=True)
class HiveSelectEntityDescription(
HiveEntityDescription,
SelectEntityDescription,
Expand Down Expand Up @@ -57,8 +57,6 @@ async def async_setup_entry(
),
)

_entities = {}

_entities = [HiveSelect(entity_description=entity_description,) for entity_description in ENTITY_DESCRIPTIONS]

async_add_entities(
Expand Down
4 changes: 1 addition & 3 deletions custom_components/hive_local_thermostat/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .entity import HiveEntity, HiveEntityDescription


@dataclass
@dataclass(frozen=True, kw_only=True)
class HiveSensorEntityDescription(
HiveEntityDescription,
SensorEntityDescription,
Expand Down Expand Up @@ -130,8 +130,6 @@ async def async_setup_entry(
),
]

_entities = {}

_entities = [
HiveSensor(
entity_description=entity_description,
Expand Down

0 comments on commit 19cd9ce

Please sign in to comment.