Skip to content
Merged
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
5 changes: 3 additions & 2 deletions homeassistant/components/matter/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ def _current_segments(self) -> dict[str, Segment]:
segments: dict[str, Segment] = {}
for area in supported_areas:
area_name = None
if area.areaInfo and area.areaInfo.locationInfo:
area_name = area.areaInfo.locationInfo.locationName
location_info = area.areaInfo.locationInfo
if location_info not in (None, clusters.NullValue):
area_name = location_info.locationName

if area_name:
segment_id = str(area.areaID)
Expand Down
21 changes: 18 additions & 3 deletions homeassistant/components/powerfox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

import asyncio

from powerfox import DeviceType, Powerfox, PowerfoxConnectionError
from powerfox import (
DeviceType,
Powerfox,
PowerfoxAuthenticationError,
PowerfoxConnectionError,
)

from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .const import DOMAIN
from .coordinator import (
PowerfoxConfigEntry,
PowerfoxDataUpdateCoordinator,
Expand All @@ -30,9 +36,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: PowerfoxConfigEntry) ->

try:
devices = await client.all_devices()
except PowerfoxAuthenticationError as err:
await client.close()
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="auth_failed",
) from err
except PowerfoxConnectionError as err:
await client.close()
raise ConfigEntryNotReady from err
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="connection_error",
) from err

coordinators: list[
PowerfoxDataUpdateCoordinator | PowerfoxReportDataUpdateCoordinator
Expand Down
24 changes: 15 additions & 9 deletions homeassistant/components/powerfox/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,24 @@ async def _async_update_data(self) -> T:
except PowerfoxAuthenticationError as err:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
translation_key="invalid_auth",
translation_placeholders={"error": str(err)},
translation_key="auth_failed",
) from err
except (
PowerfoxConnectionError,
PowerfoxNoDataError,
PowerfoxPrivacyError,
) as err:
except PowerfoxConnectionError as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="update_failed",
translation_placeholders={"error": str(err)},
translation_key="connection_error",
) from err
except PowerfoxNoDataError as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="no_data_error",
translation_placeholders={"device_name": self.device.name},
) from err
except PowerfoxPrivacyError as err:
raise UpdateFailed(
translation_domain=DOMAIN,
translation_key="privacy_error",
translation_placeholders={"device_name": self.device.name},
) from err

async def _async_fetch_data(self) -> T:
Expand Down
14 changes: 10 additions & 4 deletions homeassistant/components/powerfox/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@
}
},
"exceptions": {
"invalid_auth": {
"message": "Error while authenticating with the Powerfox service: {error}"
"auth_failed": {
"message": "Authentication with the Powerfox service failed. Please re-authenticate your account."
},
"update_failed": {
"message": "Error while updating the Powerfox service: {error}"
"connection_error": {
"message": "Could not connect to the Powerfox service. Please check your network connection."
},
"no_data_error": {
"message": "No data available for device \"{device_name}\". The device may not have reported data yet."
},
"privacy_error": {
"message": "Data for device \"{device_name}\" is restricted due to privacy settings in the Powerfox app."
}
}
}
11 changes: 11 additions & 0 deletions homeassistant/components/sftp_storage/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ async def async_step_user(
}
)

if not user_input[CONF_BACKUP_LOCATION].startswith("/"):
errors[CONF_BACKUP_LOCATION] = "backup_location_relative"
return self.async_show_form(
step_id=step_id,
data_schema=self.add_suggested_values_to_schema(
DATA_SCHEMA, user_input
),
description_placeholders=placeholders,
errors=errors,
)

try:
# Validate auth input and save uploaded key file if provided
user_input = await self._validate_auth_and_save_keyfile(user_input)
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/sftp_storage/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"already_configured": "Integration already configured. Host with same address, port and backup location already exists."
},
"error": {
"backup_location_relative": "The remote path must be an absolute path (starting with `/`).",
"invalid_key": "Invalid key uploaded. Please make sure key corresponds to valid SSH key algorithm.",
"key_or_password_needed": "Please configure password or private key file location for SFTP Storage.",
"os_error": "{error_message}. Please check if host and/or port are correct.",
Expand Down
2 changes: 1 addition & 1 deletion tests/components/default_config/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def recorder_url_mock():
yield


@pytest.mark.usefixtures("mock_bluetooth", "mock_zeroconf")
@pytest.mark.usefixtures("mock_bluetooth", "mock_zeroconf", "socket_enabled")
async def test_setup(hass: HomeAssistant) -> None:
"""Test setup."""
recorder_helper.async_initialize_recorder(hass)
Expand Down
9 changes: 7 additions & 2 deletions tests/components/esphome/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
from tests.common import MockConfigEntry


@pytest.mark.usefixtures("init_integration", "mock_dashboard")
@pytest.mark.usefixtures("mock_dashboard")
async def test_dashboard_storage(
hass: HomeAssistant,
mock_client: APIClient,
init_integration: MockConfigEntry,
hass_storage: dict[str, Any],
) -> None:
"""Test dashboard storage."""
Expand Down Expand Up @@ -129,6 +131,7 @@ async def test_setup_dashboard_fails(

async def test_setup_dashboard_fails_when_already_setup(
hass: HomeAssistant,
mock_client: APIClient,
mock_config_entry: MockConfigEntry,
hass_storage: dict[str, Any],
) -> None:
Expand Down Expand Up @@ -168,7 +171,9 @@ async def test_setup_dashboard_fails_when_already_setup(

@pytest.mark.usefixtures("mock_dashboard")
async def test_new_info_reload_config_entries(
hass: HomeAssistant, init_integration: MockConfigEntry
hass: HomeAssistant,
mock_client: APIClient,
init_integration: MockConfigEntry,
) -> None:
"""Test config entries are reloaded when new info is set."""
assert init_integration.state is ConfigEntryState.LOADED
Expand Down
1 change: 1 addition & 0 deletions tests/components/matter/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"mock_window_covering_tilt",
"onoff_light_with_levelcontrol_present",
"resideo_x2s_thermostat",
"roborock_saros_10",
"secuyou_smart_lock",
"silabs_dishwasher",
"silabs_evse_charging",
Expand Down
Loading
Loading