mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix capitalization of OwnTone integration (#88219)
This commit is contained in:
parent
c83ea297b5
commit
0748e12341
@ -43,7 +43,7 @@ CAN_EXPAND_TYPE = {
|
|||||||
MEDIA_TYPE_DIRECTORY,
|
MEDIA_TYPE_DIRECTORY,
|
||||||
}
|
}
|
||||||
# The keys and values in the below dict are identical only because the
|
# The keys and values in the below dict are identical only because the
|
||||||
# HA constants happen to align with the Owntone constants.
|
# HA constants happen to align with the OwnTone constants.
|
||||||
OWNTONE_TYPE_TO_MEDIA_TYPE = {
|
OWNTONE_TYPE_TO_MEDIA_TYPE = {
|
||||||
"track": MediaType.TRACK,
|
"track": MediaType.TRACK,
|
||||||
"playlist": MediaType.PLAYLIST,
|
"playlist": MediaType.PLAYLIST,
|
||||||
@ -58,13 +58,13 @@ MEDIA_TYPE_TO_OWNTONE_TYPE = {v: k for k, v in OWNTONE_TYPE_TO_MEDIA_TYPE.items(
|
|||||||
# media_content_id is a uri in the form of SCHEMA:Title:OwnToneURI:Subtype (Subtype only used for Genre)
|
# media_content_id is a uri in the form of SCHEMA:Title:OwnToneURI:Subtype (Subtype only used for Genre)
|
||||||
# OwnToneURI is in format library:type:id (for directories, id is path)
|
# OwnToneURI is in format library:type:id (for directories, id is path)
|
||||||
# media_content_type - type of item (mostly used to check if playable or can expand)
|
# media_content_type - type of item (mostly used to check if playable or can expand)
|
||||||
# Owntone type may differ from media_content_type when media_content_type is a directory
|
# OwnTone type may differ from media_content_type when media_content_type is a directory
|
||||||
# Owntone type is used in our own branching, but media_content_type is used for determining playability
|
# OwnTone type is used in our own branching, but media_content_type is used for determining playability
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MediaContent:
|
class MediaContent:
|
||||||
"""Class for representing Owntone media content."""
|
"""Class for representing OwnTone media content."""
|
||||||
|
|
||||||
title: str
|
title: str
|
||||||
type: str
|
type: str
|
||||||
@ -87,7 +87,7 @@ class MediaContent:
|
|||||||
|
|
||||||
|
|
||||||
def create_owntone_uri(media_type: str, id_or_path: str) -> str:
|
def create_owntone_uri(media_type: str, id_or_path: str) -> str:
|
||||||
"""Create an Owntone uri."""
|
"""Create an OwnTone uri."""
|
||||||
return f"library:{MEDIA_TYPE_TO_OWNTONE_TYPE[media_type]}:{quote(id_or_path)}"
|
return f"library:{MEDIA_TYPE_TO_OWNTONE_TYPE[media_type]}:{quote(id_or_path)}"
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ def is_owntone_media_content_id(media_content_id: str) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def convert_to_owntone_uri(media_content_id: str) -> str:
|
def convert_to_owntone_uri(media_content_id: str) -> str:
|
||||||
"""Convert media_content_id to Owntone URI."""
|
"""Convert media_content_id to OwnTone URI."""
|
||||||
return ":".join(media_content_id.split(":")[2:-1])
|
return ":".join(media_content_id.split(":")[2:-1])
|
||||||
|
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ def create_browse_media_response(
|
|||||||
for item in result:
|
for item in result:
|
||||||
if item.get("data_kind") == "spotify" or (
|
if item.get("data_kind") == "spotify" or (
|
||||||
"path" in item and cast(str, item["path"]).startswith("spotify")
|
"path" in item and cast(str, item["path"]).startswith("spotify")
|
||||||
): # Exclude spotify data from Owntone library
|
): # Exclude spotify data from OwnTone library
|
||||||
continue
|
continue
|
||||||
assert isinstance(item["uri"], str)
|
assert isinstance(item["uri"], str)
|
||||||
media_type = OWNTONE_TYPE_TO_MEDIA_TYPE[item["uri"].split(":")[1]]
|
media_type = OWNTONE_TYPE_TO_MEDIA_TYPE[item["uri"].split(":")[1]]
|
||||||
@ -275,7 +275,7 @@ def create_browse_media_response(
|
|||||||
|
|
||||||
|
|
||||||
def base_owntone_library() -> BrowseMedia:
|
def base_owntone_library() -> BrowseMedia:
|
||||||
"""Return the base of our Owntone library."""
|
"""Return the base of our OwnTone library."""
|
||||||
children = [
|
children = [
|
||||||
BrowseMedia(
|
BrowseMedia(
|
||||||
title=name,
|
title=name,
|
||||||
@ -290,10 +290,10 @@ def base_owntone_library() -> BrowseMedia:
|
|||||||
for name, (media_class, media_type, media_subtype) in TOP_LEVEL_LIBRARY.items()
|
for name, (media_class, media_type, media_subtype) in TOP_LEVEL_LIBRARY.items()
|
||||||
]
|
]
|
||||||
return BrowseMedia(
|
return BrowseMedia(
|
||||||
title="Owntone Library",
|
title="OwnTone Library",
|
||||||
media_class=MediaClass.APP,
|
media_class=MediaClass.APP,
|
||||||
media_content_id=create_media_content_id(
|
media_content_id=create_media_content_id(
|
||||||
title="Owntone Library", media_type=MediaType.APP
|
title="OwnTone Library", media_type=MediaType.APP
|
||||||
),
|
),
|
||||||
media_content_type=MediaType.APP,
|
media_content_type=MediaType.APP,
|
||||||
can_play=False,
|
can_play=False,
|
||||||
@ -308,10 +308,10 @@ def library(other: Sequence[BrowseMedia] | None) -> BrowseMedia:
|
|||||||
|
|
||||||
top_level_items = [
|
top_level_items = [
|
||||||
BrowseMedia(
|
BrowseMedia(
|
||||||
title="Owntone Library",
|
title="OwnTone Library",
|
||||||
media_class=MediaClass.APP,
|
media_class=MediaClass.APP,
|
||||||
media_content_id=create_media_content_id(
|
media_content_id=create_media_content_id(
|
||||||
title="Owntone Library", media_type=MediaType.APP
|
title="OwnTone Library", media_type=MediaType.APP
|
||||||
),
|
),
|
||||||
media_content_type=MediaType.APP,
|
media_content_type=MediaType.APP,
|
||||||
can_play=False,
|
can_play=False,
|
||||||
@ -323,7 +323,7 @@ def library(other: Sequence[BrowseMedia] | None) -> BrowseMedia:
|
|||||||
top_level_items.extend(other)
|
top_level_items.extend(other)
|
||||||
|
|
||||||
return BrowseMedia(
|
return BrowseMedia(
|
||||||
title="Owntone",
|
title="OwnTone",
|
||||||
media_class=MediaClass.DIRECTORY,
|
media_class=MediaClass.DIRECTORY,
|
||||||
media_content_id="",
|
media_content_id="",
|
||||||
media_content_type=MEDIA_TYPE_DIRECTORY,
|
media_content_type=MEDIA_TYPE_DIRECTORY,
|
||||||
|
@ -30,7 +30,7 @@ DEFAULT_TTS_PAUSE_TIME = 1.2
|
|||||||
DEFAULT_TTS_VOLUME = 0.8
|
DEFAULT_TTS_VOLUME = 0.8
|
||||||
DEFAULT_UNMUTE_VOLUME = 0.6
|
DEFAULT_UNMUTE_VOLUME = 0.6
|
||||||
DOMAIN = "forked_daapd" # key for hass.data
|
DOMAIN = "forked_daapd" # key for hass.data
|
||||||
FD_NAME = "Owntone"
|
FD_NAME = "OwnTone"
|
||||||
HASS_DATA_REMOVE_LISTENERS_KEY = "REMOVE_LISTENERS"
|
HASS_DATA_REMOVE_LISTENERS_KEY = "REMOVE_LISTENERS"
|
||||||
HASS_DATA_UPDATER_KEY = "UPDATER"
|
HASS_DATA_UPDATER_KEY = "UPDATER"
|
||||||
KNOWN_PIPES = {"librespot-java"}
|
KNOWN_PIPES = {"librespot-java"}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"domain": "forked_daapd",
|
"domain": "forked_daapd",
|
||||||
"name": "Owntone",
|
"name": "OwnTone",
|
||||||
"after_dependencies": ["spotify"],
|
"after_dependencies": ["spotify"],
|
||||||
"codeowners": ["@uvjustin"],
|
"codeowners": ["@uvjustin"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"flow_title": "{name} ({host})",
|
"flow_title": "{name} ({host})",
|
||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"title": "Set up Owntone device",
|
"title": "Set up OwnTone device",
|
||||||
"data": {
|
"data": {
|
||||||
"name": "Friendly name",
|
"name": "Friendly name",
|
||||||
"host": "[%key:common::config_flow::data::host%]",
|
"host": "[%key:common::config_flow::data::host%]",
|
||||||
@ -13,23 +13,23 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"forbidden": "Unable to connect. Please check your Owntone network permissions.",
|
"forbidden": "Unable to connect. Please check your OwnTone network permissions.",
|
||||||
"websocket_not_enabled": "Owntone server websocket not enabled.",
|
"websocket_not_enabled": "OwnTone server websocket not enabled.",
|
||||||
"wrong_host_or_port": "Unable to connect. Please check host and port.",
|
"wrong_host_or_port": "Unable to connect. Please check host and port.",
|
||||||
"wrong_password": "Incorrect password.",
|
"wrong_password": "Incorrect password.",
|
||||||
"wrong_server_type": "The Owntone integration requires an Owntone server with version >= 27.0.",
|
"wrong_server_type": "The OwnTone integration requires an OwnTone server with version >= 27.0.",
|
||||||
"unknown_error": "[%key:common::config_flow::error::unknown%]"
|
"unknown_error": "[%key:common::config_flow::error::unknown%]"
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||||
"not_forked_daapd": "Device is not an Owntone server."
|
"not_forked_daapd": "Device is not an OwnTone server."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
"title": "Configure Owntone options",
|
"title": "Configure OwnTone options",
|
||||||
"description": "Set various options for the Owntone integration.",
|
"description": "Set various options for the OwnTone integration.",
|
||||||
"data": {
|
"data": {
|
||||||
"librespot_java_port": "Port for librespot-java pipe control (if used)",
|
"librespot_java_port": "Port for librespot-java pipe control (if used)",
|
||||||
"max_playlists": "Max number of playlists used as sources",
|
"max_playlists": "Max number of playlists used as sources",
|
||||||
|
@ -1739,7 +1739,7 @@
|
|||||||
"iot_class": "cloud_polling"
|
"iot_class": "cloud_polling"
|
||||||
},
|
},
|
||||||
"forked_daapd": {
|
"forked_daapd": {
|
||||||
"name": "Owntone",
|
"name": "OwnTone",
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"iot_class": "local_push"
|
"iot_class": "local_push"
|
||||||
|
@ -177,7 +177,7 @@ async def test_async_browse_media(
|
|||||||
"""Browse the children of this BrowseMedia."""
|
"""Browse the children of this BrowseMedia."""
|
||||||
nonlocal msg_id
|
nonlocal msg_id
|
||||||
for child in children:
|
for child in children:
|
||||||
# Assert Spotify content is not passed through as Owntone media
|
# Assert Spotify content is not passed through as OwnTone media
|
||||||
assert not (
|
assert not (
|
||||||
is_owntone_media_content_id(child["media_content_id"])
|
is_owntone_media_content_id(child["media_content_id"])
|
||||||
and "Spotify" in MediaContent(child["media_content_id"]).title
|
and "Spotify" in MediaContent(child["media_content_id"]).title
|
||||||
|
@ -355,7 +355,7 @@ def test_master_state(hass: HomeAssistant, mock_api_object) -> None:
|
|||||||
"""Test master state attributes."""
|
"""Test master state attributes."""
|
||||||
state = hass.states.get(TEST_MASTER_ENTITY_NAME)
|
state = hass.states.get(TEST_MASTER_ENTITY_NAME)
|
||||||
assert state.state == STATE_PAUSED
|
assert state.state == STATE_PAUSED
|
||||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "Owntone server"
|
assert state.attributes[ATTR_FRIENDLY_NAME] == "OwnTone server"
|
||||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORTED_FEATURES
|
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORTED_FEATURES
|
||||||
assert not state.attributes[ATTR_MEDIA_VOLUME_MUTED]
|
assert not state.attributes[ATTR_MEDIA_VOLUME_MUTED]
|
||||||
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.2
|
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.2
|
||||||
@ -414,7 +414,7 @@ async def test_zone(hass: HomeAssistant, mock_api_object) -> None:
|
|||||||
"""Test zone attributes and methods."""
|
"""Test zone attributes and methods."""
|
||||||
zone_entity_name = TEST_ZONE_ENTITY_NAMES[0]
|
zone_entity_name = TEST_ZONE_ENTITY_NAMES[0]
|
||||||
state = hass.states.get(zone_entity_name)
|
state = hass.states.get(zone_entity_name)
|
||||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "Owntone output (kitchen)"
|
assert state.attributes[ATTR_FRIENDLY_NAME] == "OwnTone output (kitchen)"
|
||||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORTED_FEATURES_ZONE
|
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORTED_FEATURES_ZONE
|
||||||
assert state.state == STATE_ON
|
assert state.state == STATE_ON
|
||||||
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.5
|
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user