Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged

2022.4.5 #70155

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion homeassistant/components/hassio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,6 @@ async def force_info_update_supervisor(self) -> None:

async def force_data_refresh(self) -> None:
"""Force update of the addon info."""
await self.hassio.refresh_updates()
(
self.hass.data[DATA_INFO],
self.hass.data[DATA_CORE_INFO],
Expand Down Expand Up @@ -976,3 +975,18 @@ async def _update_addon_info(self, slug):
except HassioAPIError as err:
_LOGGER.warning("Could not fetch info for %s: %s", slug, err)
return (slug, None)

async def _async_refresh(
self,
log_failures: bool = True,
raise_on_auth_failed: bool = False,
scheduled: bool = False,
) -> None:
"""Refresh data."""
if not scheduled:
# Force refreshing updates for non-scheduled updates
try:
await self.hassio.refresh_updates()
except HassioAPIError as err:
_LOGGER.warning("Error on Supervisor API: %s", err)
await super()._async_refresh(log_failures, raise_on_auth_failed, scheduled)
2 changes: 1 addition & 1 deletion homeassistant/components/knx/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "KNX",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/knx",
"requirements": ["xknx==0.20.2"],
"requirements": ["xknx==0.20.3"],
"codeowners": ["@Julius2342", "@farmio", "@marvin-w"],
"quality_scale": "silver",
"iot_class": "local_push",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mazda/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Mazda Connected Services",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/mazda",
"requirements": ["pymazda==0.3.2"],
"requirements": ["pymazda==0.3.3"],
"codeowners": ["@bdr99"],
"quality_scale": "platinum",
"iot_class": "cloud_polling",
Expand Down
25 changes: 13 additions & 12 deletions homeassistant/components/media_player/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,7 @@ async def call_service(service: str, keys: Iterable) -> None:
cur_state = hass.states.get(state.entity_id)
features = cur_state.attributes[ATTR_SUPPORTED_FEATURES] if cur_state else 0

if (
ATTR_MEDIA_VOLUME_LEVEL in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_SET
):
await call_service(SERVICE_VOLUME_SET, [ATTR_MEDIA_VOLUME_LEVEL])

if (
ATTR_MEDIA_VOLUME_MUTED in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_MUTE
):
await call_service(SERVICE_VOLUME_MUTE, [ATTR_MEDIA_VOLUME_MUTED])

# First set source & sound mode to match the saved supported features
if (
ATTR_INPUT_SOURCE in state.attributes
and features & MediaPlayerEntityFeature.SELECT_SOURCE
Expand All @@ -107,6 +96,18 @@ async def call_service(service: str, keys: Iterable) -> None:
):
await call_service(SERVICE_SELECT_SOUND_MODE, [ATTR_SOUND_MODE])

if (
ATTR_MEDIA_VOLUME_LEVEL in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_SET
):
await call_service(SERVICE_VOLUME_SET, [ATTR_MEDIA_VOLUME_LEVEL])

if (
ATTR_MEDIA_VOLUME_MUTED in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_MUTE
):
await call_service(SERVICE_VOLUME_MUTE, [ATTR_MEDIA_VOLUME_MUTED])

already_playing = False

if (ATTR_MEDIA_CONTENT_TYPE in state.attributes) and (
Expand Down
10 changes: 9 additions & 1 deletion homeassistant/components/met/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Platform,
)
from homeassistant.core import Event, HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.distance import convert as convert_distance
Expand All @@ -33,6 +34,7 @@
DOMAIN,
)

# Dedicated Home Assistant endpoint - do not change!
URL = "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/2.0/complete"

PLATFORMS = [Platform.WEATHER]
Expand Down Expand Up @@ -82,6 +84,10 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
return unload_ok


class CannotConnect(HomeAssistantError):
"""Unable to connect to the web site."""


class MetDataUpdateCoordinator(DataUpdateCoordinator["MetWeatherData"]):
"""Class to manage fetching Met data."""

Expand Down Expand Up @@ -173,7 +179,9 @@ def set_coordinates(self) -> bool:

async def fetch_data(self) -> MetWeatherData:
"""Fetch data from API - (current weather and forecast)."""
await self._weather_data.fetching_data()
resp = await self._weather_data.fetching_data()
if not resp:
raise CannotConnect()
self.current_weather_data = self._weather_data.get_current_weather()
time_zone = dt_util.DEFAULT_TIME_ZONE
self.daily_forecast = self._weather_data.get_forecast(time_zone, False)
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/powerwall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_LOGGER.debug("Authentication failed", exc_info=err)
http_session.close()
raise ConfigEntryAuthFailed from err
except APIError as err:
http_session.close()
raise ConfigEntryNotReady from err

gateway_din = base_info.gateway_din
if gateway_din and entry.unique_id is not None and is_ip_address(entry.unique_id):
Expand Down
20 changes: 10 additions & 10 deletions homeassistant/components/tomorrowio/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_NAME,
LENGTH_INCHES,
LENGTH_MILES,
PRESSURE_INHG,
SPEED_MILES_PER_HOUR,
TEMP_FAHRENHEIT,
LENGTH_KILOMETERS,
LENGTH_MILLIMETERS,
PRESSURE_HPA,
SPEED_METERS_PER_SECOND,
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand Down Expand Up @@ -73,11 +73,11 @@ async def async_setup_entry(
class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
"""Entity that talks to Tomorrow.io v4 API to retrieve weather data."""

_attr_temperature_unit = TEMP_FAHRENHEIT
_attr_pressure_unit = PRESSURE_INHG
_attr_wind_speed_unit = SPEED_MILES_PER_HOUR
_attr_visibility_unit = LENGTH_MILES
_attr_precipitation_unit = LENGTH_INCHES
_attr_temperature_unit = TEMP_CELSIUS
_attr_pressure_unit = PRESSURE_HPA
_attr_wind_speed_unit = SPEED_METERS_PER_SECOND
_attr_visibility_unit = LENGTH_KILOMETERS
_attr_precipitation_unit = LENGTH_MILLIMETERS

def __init__(
self,
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/trafikverket_train/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any

from pytrafikverket import TrafikverketTrain
from pytrafikverket.trafikverket_train import TrainStop
from pytrafikverket.trafikverket_train import StationInfo, TrainStop
import voluptuous as vol

from homeassistant.components.sensor import (
Expand Down Expand Up @@ -166,8 +166,8 @@ def __init__(
self,
train_api: TrafikverketTrain,
name: str,
from_station: str,
to_station: str,
from_station: StationInfo,
to_station: StationInfo,
weekday: list,
departuretime: time | None,
entry_id: str,
Expand All @@ -188,7 +188,7 @@ def __init__(
configuration_url="https://api.trafikinfo.trafikverket.se/",
)
self._attr_unique_id = create_unique_id(
from_station, to_station, departuretime, weekday
from_station.name, to_station.name, departuretime, weekday
)

async def async_update(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

MAJOR_VERSION: Final = 2022
MINOR_VERSION: Final = 4
PATCH_VERSION: Final = "4"
PATCH_VERSION: Final = "5"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 9, 0)
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ pymailgunner==1.4
pymata-express==1.19

# homeassistant.components.mazda
pymazda==0.3.2
pymazda==0.3.3

# homeassistant.components.mediaroom
pymediaroom==0.6.5.4
Expand Down Expand Up @@ -2435,7 +2435,7 @@ xbox-webapi==2.0.11
xboxapi==2.0.1

# homeassistant.components.knx
xknx==0.20.2
xknx==0.20.3

# homeassistant.components.bluesound
# homeassistant.components.fritz
Expand Down
4 changes: 2 additions & 2 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ pymailgunner==1.4
pymata-express==1.19

# homeassistant.components.mazda
pymazda==0.3.2
pymazda==0.3.3

# homeassistant.components.melcloud
pymelcloud==2.5.6
Expand Down Expand Up @@ -1575,7 +1575,7 @@ wolf_smartset==0.1.11
xbox-webapi==2.0.11

# homeassistant.components.knx
xknx==0.20.2
xknx==0.20.3

# homeassistant.components.bluesound
# homeassistant.components.fritz
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = homeassistant
version = 2022.4.4
version = 2022.4.5
author = The Home Assistant Authors
author_email = [email protected]
license = Apache-2.0
Expand Down
46 changes: 40 additions & 6 deletions tests/components/hassio/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ async def test_device_registry_calls(hass):


async def test_coordinator_updates(hass, caplog):
"""Test coordinator."""
"""Test coordinator updates."""
await async_setup_component(hass, "homeassistant", {})
with patch.dict(os.environ, MOCK_ENVIRON), patch(
"homeassistant.components.hassio.HassIO.refresh_updates"
) as refresh_updates_mock:
Expand All @@ -658,12 +659,45 @@ async def test_coordinator_updates(hass, caplog):

with patch(
"homeassistant.components.hassio.HassIO.refresh_updates",
side_effect=HassioAPIError("Unknown"),
) as refresh_updates_mock:
async_fire_time_changed(hass, dt_util.now() + timedelta(minutes=5))
async_fire_time_changed(hass, dt_util.now() + timedelta(minutes=20))
await hass.async_block_till_done()
assert refresh_updates_mock.call_count == 0

with patch(
"homeassistant.components.hassio.HassIO.refresh_updates",
) as refresh_updates_mock:
await hass.services.async_call(
"homeassistant",
"update_entity",
{
"entity_id": [
"update.home_assistant_core_update",
"update.home_assistant_supervisor_update",
]
},
blocking=True,
)
assert refresh_updates_mock.call_count == 1
assert (
"Error fetching hassio data: Error on Supervisor API: Unknown"
in caplog.text

# There is a 10s cooldown on the debouncer
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=10))
await hass.async_block_till_done()

with patch(
"homeassistant.components.hassio.HassIO.refresh_updates",
side_effect=HassioAPIError("Unknown"),
) as refresh_updates_mock:
await hass.services.async_call(
"homeassistant",
"update_entity",
{
"entity_id": [
"update.home_assistant_core_update",
"update.home_assistant_supervisor_update",
]
},
blocking=True,
)
assert refresh_updates_mock.call_count == 1
assert "Error on Supervisor API: Unknown" in caplog.text
Loading