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
38 changes: 16 additions & 22 deletions homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,10 @@ async def async_mount_local_lib_path(config_dir: str) -> str:

def _get_domains(hass: core.HomeAssistant, config: dict[str, Any]) -> set[str]:
"""Get domains of components to set up."""
# Filter out the repeating and common config section [homeassistant]
domains = {
domain for key in config if (domain := cv.domain_key(key)) != core.DOMAIN
}
# The common config section [homeassistant] could be filtered here,
# but that is not necessary, since it corresponds to the core integration,
# that is always unconditionally loaded.
domains = {cv.domain_key(key) for key in config}

# Add config entry and default domains
if not hass.config.recovery_mode:
Expand Down Expand Up @@ -726,34 +726,28 @@ async def _async_resolve_domains_and_preload(
together with all their dependencies.
"""
domains_to_setup = _get_domains(hass, config)
platform_integrations = conf_util.extract_platform_integrations(
config, BASE_PLATFORMS
)
# Ensure base platforms that have platform integrations are added to `domains`,
# so they can be setup first instead of discovering them later when a config
# entry setup task notices that it's needed and there is already a long line
# to use the import executor.

# Also process all base platforms since we do not require the manifest
# to list them as dependencies.
# We want to later avoid lock contention when multiple integrations try to load
# their manifests at once.
#
# Additionally process integrations that are defined under base platforms
# to speed things up.
# For example if we have
# sensor:
# - platform: template
#
# `template` has to be loaded to validate the config for sensor
# so we want to start loading `sensor` as soon as we know
# it will be needed. The more platforms under `sensor:`, the longer
# `template` has to be loaded to validate the config for sensor.
# The more platforms under `sensor:`, the longer
# it will take to finish setup for `sensor` because each of these
# platforms has to be imported before we can validate the config.
#
# Thankfully we are migrating away from the platform pattern
# so this will be less of a problem in the future.
domains_to_setup.update(platform_integrations)

# Additionally process base platforms since we do not require the manifest
# to list them as dependencies.
# We want to later avoid lock contention when multiple integrations try to load
# their manifests at once.
# Also process integrations that are defined under base platforms
# to speed things up.
platform_integrations = conf_util.extract_platform_integrations(
config, BASE_PLATFORMS
)
additional_domains_to_process = {
*BASE_PLATFORMS,
*chain.from_iterable(platform_integrations.values()),
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/nzbget/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"name": "Disk free"
},
"post_processing_jobs": {
"name": "Post processing jobs"
"name": "Post-processing jobs"
},
"post_processing_paused": {
"name": "Post processing paused"
"name": "Post-processing paused"
},
"queue_size": {
"name": "Queue size"
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/onkyo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class OnkyoMediaPlayer(MediaPlayerEntity):
"""Onkyo Receiver Media Player (one per each zone)."""

_attr_should_poll = False
_attr_has_entity_name = True

_supports_volume: bool = False
# None means no technical possibility of support
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/onkyo/quality_scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rules:
comment: |
Currently we store created entities in hass.data. That should be removed in the future.
entity-unique-id: done
has-entity-name: todo
has-entity-name: done
runtime-data: done
test-before-configure: done
test-before-setup: done
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sleepiq/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"documentation": "https://www.home-assistant.io/integrations/sleepiq",
"iot_class": "cloud_polling",
"loggers": ["asyncsleepiq"],
"requirements": ["asyncsleepiq==1.5.2"]
"requirements": ["asyncsleepiq==1.5.3"]
}
14 changes: 10 additions & 4 deletions homeassistant/components/telegram_bot/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
self.base_url = config.data.get(CONF_URL) or get_url(
hass, require_ssl=True, allow_internal=False
)
self.webhook_url = f"{self.base_url}{TELEGRAM_WEBHOOK_URL}"
self.webhook_url = self.base_url + _get_webhook_url(bot)

async def shutdown(self) -> None:
"""Shutdown the app."""
Expand All @@ -98,9 +98,11 @@ async def _try_to_set_webhook(self) -> bool:
api_kwargs={"secret_token": self.secret_token},
connect_timeout=5,
)
except TelegramError:
except TelegramError as err:
retry_num += 1
_LOGGER.warning("Error trying to set webhook (retry #%d)", retry_num)
_LOGGER.warning(
"Error trying to set webhook (retry #%d)", retry_num, exc_info=err
)

return False

Expand Down Expand Up @@ -143,7 +145,6 @@ class PushBotView(HomeAssistantView):
"""View for handling webhook calls from Telegram."""

requires_auth = False
url = TELEGRAM_WEBHOOK_URL
name = "telegram_webhooks"

def __init__(
Expand All @@ -160,6 +161,7 @@ def __init__(
self.application = application
self.trusted_networks = trusted_networks
self.secret_token = secret_token
self.url = _get_webhook_url(bot)

async def post(self, request: HomeAssistantRequest) -> Response | None:
"""Accept the POST from telegram."""
Expand All @@ -183,3 +185,7 @@ async def post(self, request: HomeAssistantRequest) -> Response | None:
await self.application.process_update(update)

return None


def _get_webhook_url(bot: Bot) -> str:
return f"{TELEGRAM_WEBHOOK_URL}_{bot.id}"
2 changes: 1 addition & 1 deletion homeassistant/components/unifiprotect/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"integration_type": "hub",
"iot_class": "local_push",
"loggers": ["uiprotect", "unifi_discovery"],
"requirements": ["uiprotect==7.16.0", "unifi-discovery==1.2.0"],
"requirements": ["uiprotect==7.18.1", "unifi-discovery==1.2.0"],
"ssdp": [
{
"manufacturer": "Ubiquiti Networks",
Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions requirements_test_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/components/onkyo/snapshots/test_media_player.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'domain': 'media_player',
'entity_category': None,
'entity_id': 'media_player.tx_nr7100',
'has_entity_name': False,
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
Expand Down Expand Up @@ -98,7 +98,7 @@
'domain': 'media_player',
'entity_category': None,
'entity_id': 'media_player.tx_nr7100_zone_2',
'has_entity_name': False,
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
Expand Down Expand Up @@ -162,7 +162,7 @@
'domain': 'media_player',
'entity_category': None,
'entity_id': 'media_player.tx_nr7100_zone_3',
'has_entity_name': False,
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
Expand Down
12 changes: 6 additions & 6 deletions tests/components/telegram_bot/test_telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ async def test_webhook_endpoint_generates_telegram_text_event(
events = async_capture_events(hass, "telegram_text")

response = await client.post(
TELEGRAM_WEBHOOK_URL,
f"{TELEGRAM_WEBHOOK_URL}_123456",
json=update_message_text,
headers={"X-Telegram-Bot-Api-Secret-Token": mock_generate_secret_token},
)
Expand All @@ -391,7 +391,7 @@ async def test_webhook_endpoint_generates_telegram_command_event(
events = async_capture_events(hass, "telegram_command")

response = await client.post(
TELEGRAM_WEBHOOK_URL,
f"{TELEGRAM_WEBHOOK_URL}_123456",
json=update_message_command,
headers={"X-Telegram-Bot-Api-Secret-Token": mock_generate_secret_token},
)
Expand All @@ -418,7 +418,7 @@ async def test_webhook_endpoint_generates_telegram_callback_event(
events = async_capture_events(hass, "telegram_callback")

response = await client.post(
TELEGRAM_WEBHOOK_URL,
f"{TELEGRAM_WEBHOOK_URL}_123456",
json=update_callback_query,
headers={"X-Telegram-Bot-Api-Secret-Token": mock_generate_secret_token},
)
Expand Down Expand Up @@ -594,7 +594,7 @@ async def test_webhook_endpoint_unauthorized_update_doesnt_generate_telegram_tex
events = async_capture_events(hass, "telegram_text")

response = await client.post(
TELEGRAM_WEBHOOK_URL,
f"{TELEGRAM_WEBHOOK_URL}_123456",
json=unauthorized_update_message_text,
headers={"X-Telegram-Bot-Api-Secret-Token": mock_generate_secret_token},
)
Expand All @@ -618,7 +618,7 @@ async def test_webhook_endpoint_without_secret_token_is_denied(
async_capture_events(hass, "telegram_text")

response = await client.post(
TELEGRAM_WEBHOOK_URL,
f"{TELEGRAM_WEBHOOK_URL}_123456",
json=update_message_text,
)
assert response.status == 401
Expand All @@ -636,7 +636,7 @@ async def test_webhook_endpoint_invalid_secret_token_is_denied(
async_capture_events(hass, "telegram_text")

response = await client.post(
TELEGRAM_WEBHOOK_URL,
f"{TELEGRAM_WEBHOOK_URL}_123456",
json=update_message_text,
headers={"X-Telegram-Bot-Api-Secret-Token": incorrect_secret_token},
)
Expand Down
5 changes: 3 additions & 2 deletions tests/components/telegram_bot/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from telegram import WebhookInfo
from telegram.error import TimedOut

from homeassistant.components.telegram_bot.webhooks import TELEGRAM_WEBHOOK_URL
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant

Expand Down Expand Up @@ -115,7 +116,7 @@ async def test_webhooks_update_invalid_json(
client = await hass_client()

response = await client.post(
"/api/telegram_webhooks",
f"{TELEGRAM_WEBHOOK_URL}_123456",
headers={"X-Telegram-Bot-Api-Secret-Token": mock_generate_secret_token},
)
assert response.status == 400
Expand All @@ -139,7 +140,7 @@ async def test_webhooks_unauthorized_network(
return_value=IPv4Network("1.2.3.4"),
) as mock_remote:
response = await client.post(
"/api/telegram_webhooks",
f"{TELEGRAM_WEBHOOK_URL}_123456",
json="mock json",
headers={"X-Telegram-Bot-Api-Secret-Token": mock_generate_secret_token},
)
Expand Down
Loading