Skip to content

Commit

Permalink
2024.11.1 (#130156)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Nov 8, 2024
2 parents 18e1274 + c16fb9c commit ab05562
Show file tree
Hide file tree
Showing 42 changed files with 580 additions and 121 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/agent_dvr/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/agent_dvr",
"iot_class": "local_polling",
"loggers": ["agent"],
"requirements": ["agent-py==0.0.23"]
"requirements": ["agent-py==0.0.24"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/bluesound/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ async def async_volume_down(self) -> None:

async def async_set_volume_level(self, volume: float) -> None:
"""Send volume_up command to media player."""
volume = int(volume * 100)
volume = int(round(volume * 100))
volume = min(100, volume)
volume = max(0, volume)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/conversation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/conversation",
"integration_type": "system",
"quality_scale": "internal",
"requirements": ["hassil==1.7.4", "home-assistant-intents==2024.11.4"]
"requirements": ["hassil==1.7.4", "home-assistant-intents==2024.11.6"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/emulated_kasa/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"iot_class": "local_push",
"loggers": ["sense_energy"],
"quality_scale": "internal",
"requirements": ["sense-energy==0.13.2"]
"requirements": ["sense-energy==0.13.3"]
}
2 changes: 1 addition & 1 deletion homeassistant/components/ffmpeg/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"codeowners": [],
"documentation": "https://www.home-assistant.io/integrations/ffmpeg",
"integration_type": "system",
"requirements": ["ha-ffmpeg==3.2.1"]
"requirements": ["ha-ffmpeg==3.2.2"]
}
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": ["home-assistant-frontend==20241106.0"]
"requirements": ["home-assistant-frontend==20241106.2"]
}
75 changes: 60 additions & 15 deletions homeassistant/components/go2rtc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""The go2rtc component."""

from __future__ import annotations

from dataclasses import dataclass
import logging
import shutil

Expand Down Expand Up @@ -38,7 +41,13 @@
from homeassistant.util.hass_dict import HassKey
from homeassistant.util.package import is_docker_env

from .const import CONF_DEBUG_UI, DEBUG_UI_URL_MESSAGE, DOMAIN, HA_MANAGED_URL
from .const import (
CONF_DEBUG_UI,
DEBUG_UI_URL_MESSAGE,
DOMAIN,
HA_MANAGED_RTSP_PORT,
HA_MANAGED_URL,
)
from .server import Server

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -85,13 +94,22 @@
extra=vol.ALLOW_EXTRA,
)

_DATA_GO2RTC: HassKey[str] = HassKey(DOMAIN)
_DATA_GO2RTC: HassKey[Go2RtcData] = HassKey(DOMAIN)
_RETRYABLE_ERRORS = (ClientConnectionError, ServerConnectionError)


@dataclass(frozen=True)
class Go2RtcData:
"""Data for go2rtc."""

url: str
managed: bool


async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up WebRTC."""
url: str | None = None
managed = False
if DOMAIN not in config and DEFAULT_CONFIG_DOMAIN not in config:
await _remove_go2rtc_entries(hass)
return True
Expand Down Expand Up @@ -126,8 +144,9 @@ async def on_stop(event: Event) -> None:
hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, on_stop)

url = HA_MANAGED_URL
managed = True

hass.data[_DATA_GO2RTC] = url
hass.data[_DATA_GO2RTC] = Go2RtcData(url, managed)
discovery_flow.async_create_flow(
hass, DOMAIN, context={"source": SOURCE_SYSTEM}, data={}
)
Expand All @@ -142,28 +161,32 @@ async def _remove_go2rtc_entries(hass: HomeAssistant) -> None:

async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up go2rtc from a config entry."""
url = hass.data[_DATA_GO2RTC]
data = hass.data[_DATA_GO2RTC]

# Validate the server URL
try:
client = Go2RtcRestClient(async_get_clientsession(hass), url)
client = Go2RtcRestClient(async_get_clientsession(hass), data.url)
await client.validate_server_version()
except Go2RtcClientError as err:
if isinstance(err.__cause__, _RETRYABLE_ERRORS):
raise ConfigEntryNotReady(
f"Could not connect to go2rtc instance on {url}"
f"Could not connect to go2rtc instance on {data.url}"
) from err
_LOGGER.warning("Could not connect to go2rtc instance on %s (%s)", url, err)
_LOGGER.warning(
"Could not connect to go2rtc instance on %s (%s)", data.url, err
)
return False
except Go2RtcVersionError as err:
raise ConfigEntryNotReady(
f"The go2rtc server version is not supported, {err}"
) from err
except Exception as err: # noqa: BLE001
_LOGGER.warning("Could not connect to go2rtc instance on %s (%s)", url, err)
_LOGGER.warning(
"Could not connect to go2rtc instance on %s (%s)", data.url, err
)
return False

provider = WebRTCProvider(hass, url)
provider = WebRTCProvider(hass, data)
async_register_webrtc_provider(hass, provider)
return True

Expand All @@ -181,12 +204,12 @@ async def _get_binary(hass: HomeAssistant) -> str | None:
class WebRTCProvider(CameraWebRTCProvider):
"""WebRTC provider."""

def __init__(self, hass: HomeAssistant, url: str) -> None:
def __init__(self, hass: HomeAssistant, data: Go2RtcData) -> None:
"""Initialize the WebRTC provider."""
self._hass = hass
self._url = url
self._data = data
self._session = async_get_clientsession(hass)
self._rest_client = Go2RtcRestClient(self._session, url)
self._rest_client = Go2RtcRestClient(self._session, data.url)
self._sessions: dict[str, Go2RtcWsClient] = {}

@property
Expand All @@ -208,7 +231,7 @@ async def async_handle_async_webrtc_offer(
) -> None:
"""Handle the WebRTC offer and return the answer via the provided callback."""
self._sessions[session_id] = ws_client = Go2RtcWsClient(
self._session, self._url, source=camera.entity_id
self._session, self._data.url, source=camera.entity_id
)

if not (stream_source := await camera.stream_source()):
Expand All @@ -219,8 +242,30 @@ async def async_handle_async_webrtc_offer(

streams = await self._rest_client.streams.list()

if (stream := streams.get(camera.entity_id)) is None or not any(
stream_source == producer.url for producer in stream.producers
if self._data.managed:
# HA manages the go2rtc instance
stream_org_name = camera.entity_id + "_orginal"
stream_redirect_sources = [
f"rtsp://127.0.0.1:{HA_MANAGED_RTSP_PORT}/{stream_org_name}",
f"ffmpeg:{stream_org_name}#audio=opus",
]

if (
(stream_org := streams.get(stream_org_name)) is None
or not any(
stream_source == producer.url for producer in stream_org.producers
)
or (stream_redirect := streams.get(camera.entity_id)) is None
or stream_redirect_sources != [p.url for p in stream_redirect.producers]
):
await self._rest_client.streams.add(stream_org_name, stream_source)
await self._rest_client.streams.add(
camera.entity_id, stream_redirect_sources
)

# go2rtc instance is managed outside HA
elif (stream_org := streams.get(camera.entity_id)) is None or not any(
stream_source == producer.url for producer in stream_org.producers
):
await self._rest_client.streams.add(
camera.entity_id,
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/go2rtc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
DEBUG_UI_URL_MESSAGE = "Url and debug_ui cannot be set at the same time."
HA_MANAGED_API_PORT = 11984
HA_MANAGED_URL = f"http://localhost:{HA_MANAGED_API_PORT}/"
HA_MANAGED_RTSP_PORT = 18554
15 changes: 9 additions & 6 deletions homeassistant/components/go2rtc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession

from .const import HA_MANAGED_API_PORT, HA_MANAGED_URL
from .const import HA_MANAGED_API_PORT, HA_MANAGED_RTSP_PORT, HA_MANAGED_URL

_LOGGER = logging.getLogger(__name__)
_TERMINATE_TIMEOUT = 5
Expand All @@ -24,15 +24,16 @@

# Default configuration for HA
# - Api is listening only on localhost
# - Disable rtsp listener
# - Enable rtsp for localhost only as ffmpeg needs it
# - Clear default ice servers
_GO2RTC_CONFIG_FORMAT = r"""
_GO2RTC_CONFIG_FORMAT = r"""# This file is managed by Home Assistant
# Do not edit it manually
api:
listen: "{api_ip}:{api_port}"
rtsp:
# ffmpeg needs rtsp for opus audio transcoding
listen: "127.0.0.1:18554"
listen: "127.0.0.1:{rtsp_port}"
webrtc:
listen: ":18555/tcp"
Expand Down Expand Up @@ -67,7 +68,9 @@ def _create_temp_file(api_ip: str) -> str:
with NamedTemporaryFile(prefix="go2rtc_", suffix=".yaml", delete=False) as file:
file.write(
_GO2RTC_CONFIG_FORMAT.format(
api_ip=api_ip, api_port=HA_MANAGED_API_PORT
api_ip=api_ip,
api_port=HA_MANAGED_API_PORT,
rtsp_port=HA_MANAGED_RTSP_PORT,
).encode()
)
return file.name
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/imap/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"services": {
"fetch": {
"name": "Fetch message",
"description": "Fetch the email message from the server.",
"description": "Fetch an email message from the server.",
"fields": {
"entry": {
"name": "Entry",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/insteon/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"services": {
"add_all_link": {
"name": "Add all link",
"description": "Tells the Insteom Modem (IM) start All-Linking mode. Once the IM is in All-Linking mode, press the link button on the device to complete All-Linking.",
"description": "Tells the Insteon Modem (IM) start All-Linking mode. Once the IM is in All-Linking mode, press the link button on the device to complete All-Linking.",
"fields": {
"group": {
"name": "Group",
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/nest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ async def new_subscriber(
implementation, config_entry_oauth2_flow.LocalOAuth2Implementation
):
raise TypeError(f"Unexpected auth implementation {implementation}")
subscription_name = entry.data.get(
CONF_SUBSCRIPTION_NAME, entry.data[CONF_SUBSCRIBER_ID]
)
if (subscription_name := entry.data.get(CONF_SUBSCRIPTION_NAME)) is None:
subscription_name = entry.data[CONF_SUBSCRIBER_ID]
auth = AsyncConfigEntryAuth(
aiohttp_client.async_get_clientsession(hass),
config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation),
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/nest/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ def _stream_expires_at(self) -> datetime.datetime | None:
async def _async_refresh_stream(self) -> None:
"""Refresh stream to extend expiration time."""
now = utcnow()
for webrtc_stream in list(self._webrtc_sessions.values()):
for session_id, webrtc_stream in list(self._webrtc_sessions.items()):
if session_id not in self._webrtc_sessions:
continue
if now < (webrtc_stream.expires_at - STREAM_EXPIRATION_BUFFER):
_LOGGER.debug(
"Stream does not yet expire: %s", webrtc_stream.expires_at
Expand All @@ -247,7 +249,8 @@ async def _async_refresh_stream(self) -> None:
except ApiException as err:
_LOGGER.debug("Failed to extend stream: %s", err)
else:
self._webrtc_sessions[webrtc_stream.media_session_id] = webrtc_stream
if session_id in self._webrtc_sessions:
self._webrtc_sessions[session_id] = webrtc_stream

async def async_camera_image(
self, width: int | None = None, height: int | None = None
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/nest/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"iot_class": "cloud_push",
"loggers": ["google_nest_sdm"],
"quality_scale": "platinum",
"requirements": ["google-nest-sdm==6.1.3"]
"requirements": ["google-nest-sdm==6.1.4"]
}
11 changes: 7 additions & 4 deletions homeassistant/components/p1_monitor/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ async def async_step_user(
data_schema=vol.Schema(
{
vol.Required(CONF_HOST): TextSelector(),
vol.Required(CONF_PORT, default=80): NumberSelector(
NumberSelectorConfig(
mode=NumberSelectorMode.BOX,
)
vol.Required(CONF_PORT, default=80): vol.All(
NumberSelector(
NumberSelectorConfig(
min=1, max=65535, mode=NumberSelectorMode.BOX
),
),
vol.Coerce(int),
),
}
),
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/roborock/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"iot_class": "local_polling",
"loggers": ["roborock"],
"requirements": [
"python-roborock==2.6.1",
"python-roborock==2.7.2",
"vacuum-map-parser-roborock==0.1.2"
]
}
2 changes: 1 addition & 1 deletion homeassistant/components/sense/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/sense",
"iot_class": "cloud_polling",
"loggers": ["sense_energy"],
"requirements": ["sense-energy==0.13.2"]
"requirements": ["sense-energy==0.13.3"]
}
33 changes: 19 additions & 14 deletions homeassistant/components/seventeentrack/services.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Services for the seventeentrack integration."""

from typing import Final
from typing import Any, Final

from pyseventeentrack.package import PACKAGE_STATUS_MAP
from pyseventeentrack.package import PACKAGE_STATUS_MAP, Package
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry, ConfigEntryState
Expand Down Expand Up @@ -81,18 +81,7 @@ async def get_packages(call: ServiceCall) -> ServiceResponse:

return {
"packages": [
{
ATTR_DESTINATION_COUNTRY: package.destination_country,
ATTR_ORIGIN_COUNTRY: package.origin_country,
ATTR_PACKAGE_TYPE: package.package_type,
ATTR_TRACKING_INFO_LANGUAGE: package.tracking_info_language,
ATTR_TRACKING_NUMBER: package.tracking_number,
ATTR_LOCATION: package.location,
ATTR_STATUS: package.status,
ATTR_TIMESTAMP: package.timestamp.isoformat(),
ATTR_INFO_TEXT: package.info_text,
ATTR_FRIENDLY_NAME: package.friendly_name,
}
package_to_dict(package)
for package in live_packages
if slugify(package.status) in package_states or package_states == []
]
Expand All @@ -110,6 +99,22 @@ async def archive_package(call: ServiceCall) -> None:

await seventeen_coordinator.client.profile.archive_package(tracking_number)

def package_to_dict(package: Package) -> dict[str, Any]:
result = {
ATTR_DESTINATION_COUNTRY: package.destination_country,
ATTR_ORIGIN_COUNTRY: package.origin_country,
ATTR_PACKAGE_TYPE: package.package_type,
ATTR_TRACKING_INFO_LANGUAGE: package.tracking_info_language,
ATTR_TRACKING_NUMBER: package.tracking_number,
ATTR_LOCATION: package.location,
ATTR_STATUS: package.status,
ATTR_INFO_TEXT: package.info_text,
ATTR_FRIENDLY_NAME: package.friendly_name,
}
if timestamp := package.timestamp:
result[ATTR_TIMESTAMP] = timestamp.isoformat()
return result

async def _validate_service(config_entry_id):
entry: ConfigEntry | None = hass.config_entries.async_get_entry(config_entry_id)
if not entry:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/spotify/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"iot_class": "cloud_polling",
"loggers": ["spotipy"],
"quality_scale": "silver",
"requirements": ["spotifyaio==0.8.5"],
"requirements": ["spotifyaio==0.8.7"],
"zeroconf": ["_spotify-connect._tcp.local."]
}
Loading

0 comments on commit ab05562

Please sign in to comment.