Skip to content

Commit

Permalink
Merge branch 'home-assistant-master' into alfa
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz75 committed Nov 2, 2023
2 parents d5d0eb0 + 1ef00c9 commit 3d05abd
Show file tree
Hide file tree
Showing 28 changed files with 247 additions and 94 deletions.
1 change: 1 addition & 0 deletions .core_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ base_platforms: &base_platforms
- homeassistant/components/switch/**
- homeassistant/components/text/**
- homeassistant/components/time/**
- homeassistant/components/todo/**
- homeassistant/components/tts/**
- homeassistant/components/update/**
- homeassistant/components/vacuum/**
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/auth/permissions/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from homeassistant.helpers.area_registry import EVENT_AREA_REGISTRY_UPDATED
from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
from homeassistant.helpers.issue_registry import EVENT_REPAIRS_ISSUE_REGISTRY_UPDATED

# These are events that do not contain any sensitive data
# Except for state_changed, which is handled accordingly.
Expand All @@ -29,6 +30,7 @@
EVENT_CORE_CONFIG_UPDATE,
EVENT_DEVICE_REGISTRY_UPDATED,
EVENT_ENTITY_REGISTRY_UPDATED,
EVENT_REPAIRS_ISSUE_REGISTRY_UPDATED,
EVENT_LOVELACE_UPDATED,
EVENT_PANELS_UPDATED,
EVENT_RECORDER_5MIN_STATISTICS_GENERATED,
Expand Down
13 changes: 8 additions & 5 deletions homeassistant/components/fitbit/application_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ async def _post(self, data: dict[str, Any]) -> dict[str, Any]:
resp = await session.post(self.token_url, data=data, headers=self._headers)
resp.raise_for_status()
except aiohttp.ClientResponseError as err:
error_body = await resp.text()
_LOGGER.debug("Client response error body: %s", error_body)
if _LOGGER.isEnabledFor(logging.DEBUG):
error_body = await resp.text() if not session.closed else ""
_LOGGER.debug(
"Client response error status=%s, body=%s", err.status, error_body
)
if err.status == HTTPStatus.UNAUTHORIZED:
raise FitbitAuthException from err
raise FitbitApiException from err
raise FitbitAuthException(f"Unauthorized error: {err}") from err
raise FitbitApiException(f"Server error response: {err}") from err
except aiohttp.ClientError as err:
raise FitbitApiException from err
raise FitbitApiException(f"Client connection error: {err}") from err
return cast(dict, await resp.json())

@property
Expand Down
15 changes: 15 additions & 0 deletions homeassistant/components/fitbit/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ async def async_step_reauth_confirm(
return self.async_show_form(step_id="reauth_confirm")
return await self.async_step_user()

async def async_step_creation(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Create config entry from external data with Fitbit specific error handling."""
try:
return await super().async_step_creation()
except FitbitAuthException as err:
_LOGGER.error(
"Failed to authenticate when creating Fitbit credentials: %s", err
)
return self.async_abort(reason="invalid_auth")
except FitbitApiException as err:
_LOGGER.error("Failed to create Fitbit credentials: %s", err)
return self.async_abort(reason="cannot_connect")

async def async_oauth_create_entry(self, data: dict[str, Any]) -> FlowResult:
"""Create an entry for the flow, or update existing entry."""

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/fitbit/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"oauth_error": "[%key:common::config_flow::abort::oauth2_error%]",
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
"invalid_access_token": "[%key:common::config_flow::error::invalid_access_token%]",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"missing_configuration": "[%key:common::config_flow::abort::oauth2_missing_configuration%]",
"oauth_error": "[%key:common::config_flow::abort::oauth2_error%]",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
"unknown": "[%key:common::config_flow::error::unknown%]",
"wrong_account": "The user credentials provided do not match this Fitbit account."
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/frontend/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"documentation": "https://www.home-assistant.io/integrations/frontend",
"integration_type": "system",
"quality_scale": "internal",
"requirements": ["ais-dom-frontend==20231030.0"]
"requirements": ["ais-dom-frontend==20231030.1"]
}
4 changes: 3 additions & 1 deletion homeassistant/components/homekit_controller/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,9 @@ def async_subscribe_config_changed(self, callback_: CALLBACK_TYPE) -> CALLBACK_T
self._config_changed_callbacks.add(callback_)
return partial(self._remove_config_changed_callback, callback_)

async def get_characteristics(self, *args: Any, **kwargs: Any) -> dict[str, Any]:
async def get_characteristics(
self, *args: Any, **kwargs: Any
) -> dict[tuple[int, int], dict[str, Any]]:
"""Read latest state from homekit accessory."""
return await self.pairing.get_characteristics(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit_controller/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"documentation": "https://www.home-assistant.io/integrations/homekit_controller",
"iot_class": "local_push",
"loggers": ["aiohomekit", "commentjson"],
"requirements": ["aiohomekit==3.0.8"],
"requirements": ["aiohomekit==3.0.9"],
"zeroconf": ["_hap._tcp.local.", "_hap._udp.local."]
}
1 change: 1 addition & 0 deletions homeassistant/components/lovelace/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async def websocket_lovelace_resources(

if hass.config.safe_mode:
connection.send_result(msg["id"], [])
return

if not resources.loaded:
await resources.async_load()
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async def async_check_config_schema(
) -> None:
"""Validate manually configured MQTT items."""
mqtt_data = get_mqtt_data(hass)
mqtt_config: list[dict[str, list[ConfigType]]] = config_yaml[DOMAIN]
mqtt_config: list[dict[str, list[ConfigType]]] = config_yaml.get(DOMAIN, {})
for mqtt_config_item in mqtt_config:
for domain, config_items in mqtt_config_item.items():
schema = mqtt_data.reload_schema[domain]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/reolink/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"documentation": "https://www.home-assistant.io/integrations/reolink",
"iot_class": "local_push",
"loggers": ["reolink_aio"],
"requirements": ["reolink-aio==0.7.11"]
"requirements": ["reolink-aio==0.7.12"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/tplink/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,5 @@
"iot_class": "local_polling",
"loggers": ["kasa"],
"quality_scale": "platinum",
"requirements": ["python-kasa[speedups]==0.5.3"]
"requirements": ["python-kasa[speedups]==0.5.4"]
}
7 changes: 5 additions & 2 deletions homeassistant/components/vicare/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import logging
from typing import Any

from PyViCare.PyViCareUtils import PyViCareInvalidCredentialsError
from PyViCare.PyViCareUtils import (
PyViCareInvalidConfigurationError,
PyViCareInvalidCredentialsError,
)
import voluptuous as vol

from homeassistant import config_entries
Expand Down Expand Up @@ -53,7 +56,7 @@ async def async_step_user(
await self.hass.async_add_executor_job(
vicare_login, self.hass, user_input
)
except PyViCareInvalidCredentialsError:
except (PyViCareInvalidConfigurationError, PyViCareInvalidCredentialsError):
errors["base"] = "invalid_auth"
else:
return self.async_create_entry(title=VICARE_NAME, data=user_input)
Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/websocket_api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@

ALL_SERVICE_DESCRIPTIONS_JSON_CACHE = "websocket_api_all_service_descriptions_json"

_LOGGER = logging.getLogger(__name__)


@callback
def async_register_commands(
Expand Down Expand Up @@ -132,7 +134,12 @@ def handle_subscribe_events(
event_type = msg["event_type"]

if event_type not in SUBSCRIBE_ALLOWLIST and not connection.user.is_admin:
raise Unauthorized
_LOGGER.error(
"Refusing to allow %s to subscribe to event %s",
connection.user.name,
event_type,
)
raise Unauthorized(user_id=connection.user.id)

if event_type == EVENT_STATE_CHANGED:
forward_events = callback(
Expand Down
31 changes: 25 additions & 6 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class ConfigEntry:
"_async_cancel_retry_setup",
"_on_unload",
"reload_lock",
"_reauth_lock",
"_tasks",
"_background_tasks",
"_integration_for_domain",
Expand Down Expand Up @@ -321,6 +322,8 @@ def __init__(

# Reload lock to prevent conflicting reloads
self.reload_lock = asyncio.Lock()
# Reauth lock to prevent concurrent reauth flows
self._reauth_lock = asyncio.Lock()

self._tasks: set[asyncio.Future[Any]] = set()
self._background_tasks: set[asyncio.Future[Any]] = set()
Expand Down Expand Up @@ -727,12 +730,28 @@ def async_start_reauth(
data: dict[str, Any] | None = None,
) -> None:
"""Start a reauth flow."""
# We will check this again in the task when we hold the lock,
# but we also check it now to try to avoid creating the task.
if any(self.async_get_active_flows(hass, {SOURCE_REAUTH})):
# Reauth flow already in progress for this entry
return

hass.async_create_task(
hass.config_entries.flow.async_init(
self._async_init_reauth(hass, context, data),
f"config entry reauth {self.title} {self.domain} {self.entry_id}",
)

async def _async_init_reauth(
self,
hass: HomeAssistant,
context: dict[str, Any] | None = None,
data: dict[str, Any] | None = None,
) -> None:
"""Start a reauth flow."""
async with self._reauth_lock:
if any(self.async_get_active_flows(hass, {SOURCE_REAUTH})):
# Reauth flow already in progress for this entry
return
await hass.config_entries.flow.async_init(
self.domain,
context={
"source": SOURCE_REAUTH,
Expand All @@ -742,9 +761,7 @@ def async_start_reauth(
}
| (context or {}),
data=self.data | (data or {}),
),
f"config entry reauth {self.title} {self.domain} {self.entry_id}",
)
)

@callback
def async_get_active_flows(
Expand All @@ -754,7 +771,9 @@ def async_get_active_flows(
return (
flow
for flow in hass.config_entries.flow.async_progress_by_handler(
self.domain, match_context={"entry_id": self.entry_id}
self.domain,
match_context={"entry_id": self.entry_id},
include_uninitialized=True,
)
if flow["context"].get("source") in sources
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
APPLICATION_NAME: Final = "HomeAssistant"
MAJOR_VERSION: Final = 2023
MINOR_VERSION: Final = 11
PATCH_VERSION: Final = "0b4"
PATCH_VERSION: Final = "0"
__short_version__: Final = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__: Final = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER: Final[tuple[int, int, int]] = (3, 11, 0)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ha-av==10.1.1
hass-nabucasa==0.74.0
hassil==1.2.5
home-assistant-bluetooth==1.10.4
ais-dom-frontend==20231030.0
ais-dom-frontend==20231030.1
home-assistant-intents==2023.10.16
httpx==0.25.0
ifaddr==0.2.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ais-dom"
version = "2023.11.0b4"
version = "2023.11.0"
license = {text = "Apache-2.0"}
description = "Open-source home automation platform running on Python 3."
readme = "README.rst"
Expand Down
8 changes: 4 additions & 4 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ aioguardian==2022.07.0
aioharmony==0.2.10

# homeassistant.components.homekit_controller
aiohomekit==3.0.8
aiohomekit==3.0.9

# homeassistant.components.emulated_hue
# homeassistant.components.http
Expand Down Expand Up @@ -1007,7 +1007,7 @@ hole==0.8.0
holidays==0.28

# homeassistant.components.frontend
ais-dom-frontend==20231030.0
ais-dom-frontend==20231030.1

# homeassistant.components.conversation
home-assistant-intents==2023.10.16
Expand Down Expand Up @@ -2144,7 +2144,7 @@ python-join-api==0.0.9
python-juicenet==1.1.0

# homeassistant.components.tplink
python-kasa[speedups]==0.5.3
python-kasa[speedups]==0.5.4

# homeassistant.components.lirc
# python-lirc==1.2.3
Expand Down Expand Up @@ -2322,7 +2322,7 @@ renault-api==0.2.0
renson-endura-delta==1.6.0

# homeassistant.components.reolink
reolink-aio==0.7.11
reolink-aio==0.7.12

# homeassistant.components.idteck_prox
rfk101py==0.0.1
Expand Down
8 changes: 4 additions & 4 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ aioguardian==2022.07.0
aioharmony==0.2.10

# homeassistant.components.homekit_controller
aiohomekit==3.0.8
aiohomekit==3.0.9

# homeassistant.components.emulated_hue
# homeassistant.components.http
Expand Down Expand Up @@ -796,7 +796,7 @@ hole==0.8.0
holidays==0.28

# homeassistant.components.frontend
ais-dom-frontend==20231030.0
ais-dom-frontend==20231030.1

# homeassistant.components.conversation
home-assistant-intents==2023.10.16
Expand Down Expand Up @@ -1600,7 +1600,7 @@ python-izone==1.2.9
python-juicenet==1.1.0

# homeassistant.components.tplink
python-kasa[speedups]==0.5.3
python-kasa[speedups]==0.5.4

# homeassistant.components.matter
python-matter-server==4.0.0
Expand Down Expand Up @@ -1733,7 +1733,7 @@ renault-api==0.2.0
renson-endura-delta==1.6.0

# homeassistant.components.reolink
reolink-aio==0.7.11
reolink-aio==0.7.12

# homeassistant.components.rflink
rflink==0.0.65
Expand Down
Loading

0 comments on commit 3d05abd

Please sign in to comment.