Migrate Met.no to new entity naming style (#74908)

This commit is contained in:
Franck Nijhof 2022-07-10 22:13:22 +02:00 committed by GitHub
parent c81d63e070
commit d6ceebbb68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -71,6 +71,7 @@ def format_condition(condition: str) -> str:
class MetWeather(CoordinatorEntity[MetDataUpdateCoordinator], WeatherEntity):
"""Implementation of a Met.no weather condition."""
_attr_has_entity_name = True
_attr_native_temperature_unit = TEMP_CELSIUS
_attr_native_precipitation_unit = LENGTH_MILLIMETERS
_attr_native_pressure_unit = PRESSURE_HPA
@ -111,7 +112,7 @@ class MetWeather(CoordinatorEntity[MetDataUpdateCoordinator], WeatherEntity):
name = self._config.get(CONF_NAME)
name_appendix = ""
if self._hourly:
name_appendix = " Hourly"
name_appendix = " hourly"
if name is not None:
return f"{name}{name_appendix}"

View File

@ -16,10 +16,10 @@ async def test_tracking_home(hass, mock_weather):
# Test the hourly sensor is disabled by default
registry = er.async_get(hass)
state = hass.states.get("weather.test_home_hourly")
state = hass.states.get("weather.forecast_test_home_hourly")
assert state is None
entry = registry.async_get("weather.test_home_hourly")
entry = registry.async_get("weather.forecast_test_home_hourly")
assert entry
assert entry.disabled
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
@ -50,7 +50,7 @@ async def test_not_tracking_home(hass, mock_weather):
WEATHER_DOMAIN,
DOMAIN,
"10-20-hourly",
suggested_object_id="somewhere_hourly",
suggested_object_id="forecast_somewhere_hourly",
disabled_by=None,
)