Merge branch 'dev' into esphome_bronze

This commit is contained in:
J. Nick Koston 2025-04-18 03:11:07 -10:00 committed by GitHub
commit 9b9c10b0c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 121 additions and 55 deletions

View File

@ -68,6 +68,9 @@
"repeat_set": {
"service": "mdi:repeat"
},
"search_media": {
"service": "mdi:text-search"
},
"select_sound_mode": {
"service": "mdi:surround-sound"
},

View File

@ -181,6 +181,35 @@ browse_media:
selector:
text:
search_media:
target:
entity:
domain: media_player
supported_features:
- media_player.MediaPlayerEntityFeature.SEARCH_MEDIA
fields:
search_query:
required: true
example: "Beatles"
selector:
text:
media_content_type:
required: false
example: "music"
selector:
text:
media_content_id:
required: false
example: "A:ALBUMARTIST/Beatles"
selector:
text:
media_filter_classes:
required: false
example: ["album", "artist"]
selector:
text:
multiple: true
select_source:
target:
entity:

View File

@ -274,6 +274,28 @@
}
}
},
"search_media": {
"name": "Search media",
"description": "Searches the available media.",
"fields": {
"media_content_id": {
"name": "[%key:component::media_player::services::browse_media::fields::media_content_id::name%]",
"description": "[%key:component::media_player::services::browse_media::fields::media_content_id::description%]"
},
"media_content_type": {
"name": "[%key:component::media_player::services::browse_media::fields::media_content_type::name%]",
"description": "[%key:component::media_player::services::browse_media::fields::media_content_type::description%]"
},
"search_query": {
"name": "Search query",
"description": "The term to search for."
},
"media_filter_classes": {
"name": "Media filter classes",
"description": "List of media classes to filter the search results by."
}
}
},
"select_source": {
"name": "Select source",
"description": "Sends the media player the command to change input source.",

View File

@ -81,6 +81,7 @@ async def test_restore_dashboard_storage_end_to_end(
assert mock_dashboard_api.mock_calls[0][1][0] == "http://new-host:6052"
@pytest.mark.usefixtures("hassio_stubs")
async def test_restore_dashboard_storage_skipped_if_addon_uninstalled(
hass: HomeAssistant,
hass_storage: dict[str, Any],
@ -105,9 +106,7 @@ async def test_restore_dashboard_storage_skipped_if_addon_uninstalled(
return_value={},
),
):
await async_setup_component(hass, "hassio", {})
await hass.async_block_till_done()
await async_setup_component(hass, DOMAIN, {})
assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
assert "test-slug is no longer installed" in caplog.text
assert not mock_dashboard_api.called

View File

@ -3,17 +3,16 @@
from collections.abc import Generator
import os
import re
from unittest.mock import AsyncMock, Mock, patch
from unittest.mock import AsyncMock, patch
from aiohasupervisor.models import AddonsStats, AddonState
from aiohttp.test_utils import TestClient
import pytest
from homeassistant.auth.models import RefreshToken
from homeassistant.components.hassio.handler import HassIO, HassioAPIError
from homeassistant.components.hassio.handler import HassIO
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.setup import async_setup_component
from . import SUPERVISOR_TOKEN
@ -31,55 +30,6 @@ def disable_security_filter() -> Generator[None]:
yield
@pytest.fixture
def hassio_env(supervisor_is_connected: AsyncMock) -> Generator[None]:
"""Fixture to inject hassio env."""
with (
patch.dict(os.environ, {"SUPERVISOR": "127.0.0.1"}),
patch.dict(os.environ, {"SUPERVISOR_TOKEN": SUPERVISOR_TOKEN}),
patch(
"homeassistant.components.hassio.HassIO.get_info",
Mock(side_effect=HassioAPIError()),
),
):
yield
@pytest.fixture
async def hassio_stubs(
hassio_env: None,
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
supervisor_client: AsyncMock,
) -> RefreshToken:
"""Create mock hassio http client."""
with (
patch(
"homeassistant.components.hassio.HassIO.update_hass_api",
return_value={"result": "ok"},
) as hass_api,
patch(
"homeassistant.components.hassio.HassIO.update_hass_timezone",
return_value={"result": "ok"},
),
patch(
"homeassistant.components.hassio.HassIO.get_info",
side_effect=HassioAPIError(),
),
patch(
"homeassistant.components.hassio.HassIO.get_ingress_panels",
return_value={"panels": []},
),
patch(
"homeassistant.components.hassio.issues.SupervisorIssues.setup",
),
):
await async_setup_component(hass, "hassio", {})
return hass_api.call_args[0][1]
@pytest.fixture
async def hassio_client(
hassio_stubs: RefreshToken, hass: HomeAssistant, hass_client: ClientSessionGenerator

View File

@ -119,8 +119,10 @@ from .typing import (
if TYPE_CHECKING:
# Local import to avoid processing recorder and SQLite modules when running a
# testcase which does not use the recorder.
from homeassistant.auth.models import RefreshToken
from homeassistant.components import recorder
pytest.register_assert_rewrite("tests.common")
from .common import ( # noqa: E402, isort:skip
@ -1894,6 +1896,67 @@ def mock_bleak_scanner_start() -> Generator[MagicMock]:
yield mock_bleak_scanner_start
@pytest.fixture
def hassio_env(supervisor_is_connected: AsyncMock) -> Generator[None]:
"""Fixture to inject hassio env."""
from homeassistant.components.hassio import ( # pylint: disable=import-outside-toplevel
HassioAPIError,
)
from .components.hassio import ( # pylint: disable=import-outside-toplevel
SUPERVISOR_TOKEN,
)
with (
patch.dict(os.environ, {"SUPERVISOR": "127.0.0.1"}),
patch.dict(os.environ, {"SUPERVISOR_TOKEN": SUPERVISOR_TOKEN}),
patch(
"homeassistant.components.hassio.HassIO.get_info",
Mock(side_effect=HassioAPIError()),
),
):
yield
@pytest.fixture
async def hassio_stubs(
hassio_env: None,
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
supervisor_client: AsyncMock,
) -> RefreshToken:
"""Create mock hassio http client."""
from homeassistant.components.hassio import ( # pylint: disable=import-outside-toplevel
HassioAPIError,
)
with (
patch(
"homeassistant.components.hassio.HassIO.update_hass_api",
return_value={"result": "ok"},
) as hass_api,
patch(
"homeassistant.components.hassio.HassIO.update_hass_timezone",
return_value={"result": "ok"},
),
patch(
"homeassistant.components.hassio.HassIO.get_info",
side_effect=HassioAPIError(),
),
patch(
"homeassistant.components.hassio.HassIO.get_ingress_panels",
return_value={"panels": []},
),
patch(
"homeassistant.components.hassio.issues.SupervisorIssues.setup",
),
):
await async_setup_component(hass, "hassio", {})
return hass_api.call_args[0][1]
@pytest.fixture
def integration_frame_path() -> str:
"""Return the path to the integration frame.