Rename environment_canada entities (#136817)

This commit is contained in:
epenet 2025-01-29 10:23:37 +01:00 committed by GitHub
parent 7b1b229718
commit 417003ad35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 11 deletions

View File

@ -30,7 +30,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Add a weather entity from a config_entry.""" """Add a weather entity from a config_entry."""
coordinator = config_entry.runtime_data.radar_coordinator coordinator = config_entry.runtime_data.radar_coordinator
async_add_entities([ECCamera(coordinator)]) async_add_entities([ECCameraEntity(coordinator)])
platform = async_get_current_platform() platform = async_get_current_platform()
platform.async_register_entity_service( platform.async_register_entity_service(
@ -40,7 +40,7 @@ async def async_setup_entry(
) )
class ECCamera(CoordinatorEntity, Camera): class ECCameraEntity(CoordinatorEntity, Camera):
"""Implementation of an Environment Canada radar camera.""" """Implementation of an Environment Canada radar camera."""
_attr_has_entity_name = True _attr_has_entity_name = True

View File

@ -256,16 +256,20 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Add a weather entity from a config_entry.""" """Add a weather entity from a config_entry."""
weather_coordinator = config_entry.runtime_data.weather_coordinator weather_coordinator = config_entry.runtime_data.weather_coordinator
sensors: list[ECBaseSensor] = [ sensors: list[ECBaseSensorEntity] = [
ECSensor(weather_coordinator, desc) for desc in SENSOR_TYPES ECSensorEntity(weather_coordinator, desc) for desc in SENSOR_TYPES
] ]
sensors.extend([ECAlertSensor(weather_coordinator, desc) for desc in ALERT_TYPES]) sensors.extend(
[ECAlertSensorEntity(weather_coordinator, desc) for desc in ALERT_TYPES]
)
sensors.append(ECSensor(config_entry.runtime_data.aqhi_coordinator, AQHI_SENSOR)) sensors.append(
ECSensorEntity(config_entry.runtime_data.aqhi_coordinator, AQHI_SENSOR)
)
async_add_entities(sensors) async_add_entities(sensors)
class ECBaseSensor(CoordinatorEntity, SensorEntity): class ECBaseSensorEntity(CoordinatorEntity, SensorEntity):
"""Environment Canada sensor base.""" """Environment Canada sensor base."""
entity_description: ECSensorEntityDescription entity_description: ECSensorEntityDescription
@ -289,7 +293,7 @@ class ECBaseSensor(CoordinatorEntity, SensorEntity):
return value return value
class ECSensor(ECBaseSensor): class ECSensorEntity(ECBaseSensorEntity):
"""Environment Canada sensor for conditions.""" """Environment Canada sensor for conditions."""
def __init__(self, coordinator, description): def __init__(self, coordinator, description):
@ -301,7 +305,7 @@ class ECSensor(ECBaseSensor):
} }
class ECAlertSensor(ECBaseSensor): class ECAlertSensorEntity(ECBaseSensorEntity):
"""Environment Canada sensor for alerts.""" """Environment Canada sensor for alerts."""
@property @property

View File

@ -75,7 +75,7 @@ async def async_setup_entry(
): ):
entity_registry.async_remove(hourly_entity_id) entity_registry.async_remove(hourly_entity_id)
async_add_entities([ECWeather(config_entry.runtime_data.weather_coordinator)]) async_add_entities([ECWeatherEntity(config_entry.runtime_data.weather_coordinator)])
def _calculate_unique_id(config_entry_unique_id: str | None, hourly: bool) -> str: def _calculate_unique_id(config_entry_unique_id: str | None, hourly: bool) -> str:
@ -83,7 +83,7 @@ def _calculate_unique_id(config_entry_unique_id: str | None, hourly: bool) -> st
return f"{config_entry_unique_id}{'-hourly' if hourly else '-daily'}" return f"{config_entry_unique_id}{'-hourly' if hourly else '-daily'}"
class ECWeather(SingleCoordinatorWeatherEntity): class ECWeatherEntity(SingleCoordinatorWeatherEntity):
"""Representation of a weather condition.""" """Representation of a weather condition."""
_attr_has_entity_name = True _attr_has_entity_name = True