mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 18:08:37 -04:00
Implement Cloud coverage in Weather entity component (#95068)
This commit is contained in:
@@ -31,7 +31,10 @@ from homeassistant.components.weather import (
|
||||
WeatherEntity,
|
||||
round_temperature,
|
||||
)
|
||||
from homeassistant.components.weather.const import ATTR_WEATHER_DEW_POINT
|
||||
from homeassistant.components.weather.const import (
|
||||
ATTR_WEATHER_CLOUD_COVERAGE,
|
||||
ATTR_WEATHER_DEW_POINT,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME,
|
||||
PRECISION_HALVES,
|
||||
@@ -522,21 +525,26 @@ async def test_precipitation_no_unit(
|
||||
)
|
||||
|
||||
|
||||
async def test_wind_bearing_and_ozone(
|
||||
async def test_wind_bearing_ozone_and_cloud_coverage(
|
||||
hass: HomeAssistant,
|
||||
enable_custom_integrations: None,
|
||||
) -> None:
|
||||
"""Test wind bearing."""
|
||||
"""Test wind bearing, ozone and cloud coverage."""
|
||||
wind_bearing_value = 180
|
||||
ozone_value = 10
|
||||
cloud_coverage = 75
|
||||
|
||||
entity0 = await create_entity(
|
||||
hass, wind_bearing=wind_bearing_value, ozone=ozone_value
|
||||
hass,
|
||||
wind_bearing=wind_bearing_value,
|
||||
ozone=ozone_value,
|
||||
cloud_coverage=cloud_coverage,
|
||||
)
|
||||
|
||||
state = hass.states.get(entity0.entity_id)
|
||||
assert float(state.attributes[ATTR_WEATHER_WIND_BEARING]) == 180
|
||||
assert float(state.attributes[ATTR_WEATHER_OZONE]) == 10
|
||||
assert float(state.attributes[ATTR_WEATHER_CLOUD_COVERAGE]) == 75
|
||||
|
||||
|
||||
async def test_none_forecast(
|
||||
|
||||
@@ -5,6 +5,7 @@ Call init before using it in your tests to ensure clean test data.
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.weather import (
|
||||
ATTR_FORECAST_CLOUD_COVERAGE,
|
||||
ATTR_FORECAST_NATIVE_APPARENT_TEMP,
|
||||
ATTR_FORECAST_NATIVE_DEW_POINT,
|
||||
ATTR_FORECAST_NATIVE_PRECIPITATION,
|
||||
@@ -98,6 +99,11 @@ class MockWeather(MockEntity, WeatherEntity):
|
||||
"""Return the ozone level."""
|
||||
return self._handle("ozone")
|
||||
|
||||
@property
|
||||
def cloud_coverage(self) -> float | None:
|
||||
"""Return the cloud coverage in %."""
|
||||
return self._handle("cloud_coverage")
|
||||
|
||||
@property
|
||||
def native_visibility(self) -> float | None:
|
||||
"""Return the visibility."""
|
||||
@@ -210,6 +216,7 @@ class MockWeatherMockForecast(MockWeather):
|
||||
ATTR_FORECAST_NATIVE_APPARENT_TEMP: self.native_apparent_temperature,
|
||||
ATTR_FORECAST_NATIVE_TEMP_LOW: self.native_temperature,
|
||||
ATTR_FORECAST_NATIVE_DEW_POINT: self.native_dew_point,
|
||||
ATTR_FORECAST_CLOUD_COVERAGE: self.cloud_coverage,
|
||||
ATTR_FORECAST_NATIVE_PRESSURE: self.native_pressure,
|
||||
ATTR_FORECAST_NATIVE_WIND_SPEED: self.native_wind_speed,
|
||||
ATTR_FORECAST_WIND_BEARING: self.wind_bearing,
|
||||
|
||||
Reference in New Issue
Block a user