mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Remove hourly weather entity from Environment Canada (#112447)
* Remove hourly weather entity from Environment Canada * Remove from strings
This commit is contained in:
parent
457e27ecfd
commit
248f2ac2fb
@ -110,9 +110,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"weather": {
|
"weather": {
|
||||||
"hourly_forecast": {
|
|
||||||
"name": "Hourly forecast"
|
|
||||||
},
|
|
||||||
"forecast": {
|
"forecast": {
|
||||||
"name": "Forecast"
|
"name": "Forecast"
|
||||||
}
|
}
|
||||||
|
@ -68,17 +68,15 @@ async def async_setup_entry(
|
|||||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]["weather_coordinator"]
|
coordinator = hass.data[DOMAIN][config_entry.entry_id]["weather_coordinator"]
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
entities = [ECWeather(coordinator, False)]
|
# Remove hourly entity from legacy config entries
|
||||||
|
if hourly_entity_id := entity_registry.async_get_entity_id(
|
||||||
# Add hourly entity to legacy config entries
|
|
||||||
if entity_registry.async_get_entity_id(
|
|
||||||
WEATHER_DOMAIN,
|
WEATHER_DOMAIN,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
_calculate_unique_id(config_entry.unique_id, True),
|
_calculate_unique_id(config_entry.unique_id, True),
|
||||||
):
|
):
|
||||||
entities.append(ECWeather(coordinator, True))
|
entity_registry.async_remove(hourly_entity_id)
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities([ECWeather(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:
|
||||||
@ -98,17 +96,15 @@ class ECWeather(SingleCoordinatorWeatherEntity):
|
|||||||
WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY
|
WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, coordinator, hourly):
|
def __init__(self, coordinator):
|
||||||
"""Initialize Environment Canada weather."""
|
"""Initialize Environment Canada weather."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self.ec_data = coordinator.ec_data
|
self.ec_data = coordinator.ec_data
|
||||||
self._attr_attribution = self.ec_data.metadata["attribution"]
|
self._attr_attribution = self.ec_data.metadata["attribution"]
|
||||||
self._attr_translation_key = "hourly_forecast" if hourly else "forecast"
|
self._attr_translation_key = "forecast"
|
||||||
self._attr_unique_id = _calculate_unique_id(
|
self._attr_unique_id = _calculate_unique_id(
|
||||||
coordinator.config_entry.unique_id, hourly
|
coordinator.config_entry.unique_id, False
|
||||||
)
|
)
|
||||||
self._attr_entity_registry_enabled_default = not hourly
|
|
||||||
self._hourly = hourly
|
|
||||||
self._attr_device_info = device_info(coordinator.config_entry)
|
self._attr_device_info = device_info(coordinator.config_entry)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -180,7 +176,7 @@ class ECWeather(SingleCoordinatorWeatherEntity):
|
|||||||
@property
|
@property
|
||||||
def forecast(self) -> list[Forecast] | None:
|
def forecast(self) -> list[Forecast] | None:
|
||||||
"""Return the forecast array."""
|
"""Return the forecast array."""
|
||||||
return get_forecast(self.ec_data, self._hourly)
|
return get_forecast(self.ec_data, False)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_forecast_daily(self) -> list[Forecast] | None:
|
def _async_forecast_daily(self) -> list[Forecast] | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user