diff --git a/custom_components/hive_local_thermostat/button.py b/custom_components/hive_local_thermostat/button.py index c365404..28d2854 100644 --- a/custom_components/hive_local_thermostat/button.py +++ b/custom_components/hive_local_thermostat/button.py @@ -26,7 +26,7 @@ from .entity import HiveEntity, HiveEntityDescription -@dataclass +@dataclass(frozen=True, kw_only=True) class HiveButtonEntityDescription( HiveEntityDescription, ButtonEntityDescription, @@ -66,8 +66,6 @@ async def async_setup_entry( ) ) - _entities = {} - _entities = [ HiveButton( entity_description=entity_description, diff --git a/custom_components/hive_local_thermostat/climate.py b/custom_components/hive_local_thermostat/climate.py index 330897a..d374020 100644 --- a/custom_components/hive_local_thermostat/climate.py +++ b/custom_components/hive_local_thermostat/climate.py @@ -43,7 +43,7 @@ } -@dataclass +@dataclass(frozen=True, kw_only=True) class HiveClimateEntityDescription( HiveEntityDescription, ClimateEntityDescription, @@ -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", diff --git a/custom_components/hive_local_thermostat/entity.py b/custom_components/hive_local_thermostat/entity.py index 758bcdb..7f12532 100644 --- a/custom_components/hive_local_thermostat/entity.py +++ b/custom_components/hive_local_thermostat/entity.py @@ -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): diff --git a/custom_components/hive_local_thermostat/number.py b/custom_components/hive_local_thermostat/number.py index 59b4afc..3e53b8e 100644 --- a/custom_components/hive_local_thermostat/number.py +++ b/custom_components/hive_local_thermostat/number.py @@ -23,6 +23,7 @@ from .const import ( CONF_MODEL, + CONF_MQTT_TOPIC, DEFAULT_FROST_TEMPERATURE, DEFAULT_HEATING_BOOST_MINUTES, DEFAULT_HEATING_BOOST_TEMPERATURE, @@ -35,7 +36,7 @@ from .entity import HiveEntity, HiveEntityDescription -@dataclass +@dataclass(frozen=True, kw_only=True) class HiveNumberEntityDescription( HiveEntityDescription, NumberEntityDescription, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -135,8 +136,6 @@ async def async_setup_entry( ) ) - _entities = {} - _entities = [ HiveNumber( entity_description=entity_description, diff --git a/custom_components/hive_local_thermostat/select.py b/custom_components/hive_local_thermostat/select.py index 730d409..5149095 100644 --- a/custom_components/hive_local_thermostat/select.py +++ b/custom_components/hive_local_thermostat/select.py @@ -26,7 +26,7 @@ from .entity import HiveEntity, HiveEntityDescription -@dataclass +@dataclass(frozen=True, kw_only=True) class HiveSelectEntityDescription( HiveEntityDescription, SelectEntityDescription, @@ -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( diff --git a/custom_components/hive_local_thermostat/sensor.py b/custom_components/hive_local_thermostat/sensor.py index 58f0894..65bf60f 100644 --- a/custom_components/hive_local_thermostat/sensor.py +++ b/custom_components/hive_local_thermostat/sensor.py @@ -29,7 +29,7 @@ from .entity import HiveEntity, HiveEntityDescription -@dataclass +@dataclass(frozen=True, kw_only=True) class HiveSensorEntityDescription( HiveEntityDescription, SensorEntityDescription, @@ -130,8 +130,6 @@ async def async_setup_entry( ), ] - _entities = {} - _entities = [ HiveSensor( entity_description=entity_description,