mirror of
https://github.com/home-assistant/core.git
synced 2025-12-20 02:48:57 +00:00
Remove gstreamer integration (#155455)
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
"""The gstreamer component."""
|
|
||||||
|
|
||||||
DOMAIN = "gstreamer"
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"domain": "gstreamer",
|
|
||||||
"name": "GStreamer",
|
|
||||||
"codeowners": [],
|
|
||||||
"documentation": "https://www.home-assistant.io/integrations/gstreamer",
|
|
||||||
"iot_class": "local_push",
|
|
||||||
"loggers": ["gsp"],
|
|
||||||
"quality_scale": "legacy",
|
|
||||||
"requirements": ["gstreamer-player==1.1.2"]
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
"""Play media via gstreamer."""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import logging
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from gsp import STATE_IDLE, STATE_PAUSED, STATE_PLAYING, GstreamerPlayer
|
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components import media_source
|
|
||||||
from homeassistant.components.media_player import (
|
|
||||||
PLATFORM_SCHEMA as MEDIA_PLAYER_PLATFORM_SCHEMA,
|
|
||||||
BrowseMedia,
|
|
||||||
MediaPlayerEntity,
|
|
||||||
MediaPlayerEntityFeature,
|
|
||||||
MediaPlayerState,
|
|
||||||
MediaType,
|
|
||||||
async_process_play_media_url,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP
|
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
|
||||||
from homeassistant.helpers import config_validation as cv
|
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
|
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
|
||||||
|
|
||||||
from . import DOMAIN
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
CONF_PIPELINE = "pipeline"
|
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = MEDIA_PLAYER_PLATFORM_SCHEMA.extend(
|
|
||||||
{vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_PIPELINE): cv.string}
|
|
||||||
)
|
|
||||||
|
|
||||||
GSP_STATE_MAPPING = {
|
|
||||||
STATE_IDLE: MediaPlayerState.IDLE,
|
|
||||||
STATE_PAUSED: MediaPlayerState.PAUSED,
|
|
||||||
STATE_PLAYING: MediaPlayerState.PLAYING,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config: ConfigType,
|
|
||||||
add_entities: AddEntitiesCallback,
|
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""Set up the Gstreamer platform."""
|
|
||||||
create_issue(
|
|
||||||
hass,
|
|
||||||
HOMEASSISTANT_DOMAIN,
|
|
||||||
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
|
|
||||||
breaks_in_ha_version="2025.12.0",
|
|
||||||
is_fixable=False,
|
|
||||||
issue_domain=DOMAIN,
|
|
||||||
severity=IssueSeverity.WARNING,
|
|
||||||
translation_key="deprecated_system_packages_yaml_integration",
|
|
||||||
translation_placeholders={
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"integration_title": "GStreamer",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
|
||||||
pipeline = config.get(CONF_PIPELINE)
|
|
||||||
player = GstreamerPlayer(pipeline)
|
|
||||||
|
|
||||||
def _shutdown(call):
|
|
||||||
"""Quit the player on shutdown."""
|
|
||||||
player.quit()
|
|
||||||
|
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
|
|
||||||
add_entities([GstreamerDevice(player, name)])
|
|
||||||
|
|
||||||
|
|
||||||
class GstreamerDevice(MediaPlayerEntity):
|
|
||||||
"""Representation of a Gstreamer device."""
|
|
||||||
|
|
||||||
_attr_media_content_type = MediaType.MUSIC
|
|
||||||
_attr_supported_features = (
|
|
||||||
MediaPlayerEntityFeature.VOLUME_SET
|
|
||||||
| MediaPlayerEntityFeature.PLAY
|
|
||||||
| MediaPlayerEntityFeature.PAUSE
|
|
||||||
| MediaPlayerEntityFeature.PLAY_MEDIA
|
|
||||||
| MediaPlayerEntityFeature.NEXT_TRACK
|
|
||||||
| MediaPlayerEntityFeature.BROWSE_MEDIA
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, player: GstreamerPlayer, name: str | None) -> None:
|
|
||||||
"""Initialize the Gstreamer device."""
|
|
||||||
self._player = player
|
|
||||||
self._name = name or DOMAIN
|
|
||||||
self._attr_state = MediaPlayerState.IDLE
|
|
||||||
self._volume = None
|
|
||||||
self._duration = None
|
|
||||||
self._uri = None
|
|
||||||
self._title = None
|
|
||||||
self._artist = None
|
|
||||||
self._album = None
|
|
||||||
|
|
||||||
def update(self) -> None:
|
|
||||||
"""Update properties."""
|
|
||||||
self._attr_state = GSP_STATE_MAPPING.get(self._player.state)
|
|
||||||
self._volume = self._player.volume
|
|
||||||
self._duration = self._player.duration
|
|
||||||
self._uri = self._player.uri
|
|
||||||
self._title = self._player.title
|
|
||||||
self._album = self._player.album
|
|
||||||
self._artist = self._player.artist
|
|
||||||
|
|
||||||
def set_volume_level(self, volume: float) -> None:
|
|
||||||
"""Set the volume level."""
|
|
||||||
self._player.volume = volume
|
|
||||||
|
|
||||||
async def async_play_media(
|
|
||||||
self, media_type: MediaType | str, media_id: str, **kwargs: Any
|
|
||||||
) -> None:
|
|
||||||
"""Play media."""
|
|
||||||
# Handle media_source
|
|
||||||
if media_source.is_media_source_id(media_id):
|
|
||||||
sourced_media = await media_source.async_resolve_media(
|
|
||||||
self.hass, media_id, self.entity_id
|
|
||||||
)
|
|
||||||
media_id = sourced_media.url
|
|
||||||
|
|
||||||
elif media_type != MediaType.MUSIC:
|
|
||||||
_LOGGER.error("Invalid media type")
|
|
||||||
return
|
|
||||||
|
|
||||||
media_id = async_process_play_media_url(self.hass, media_id)
|
|
||||||
|
|
||||||
await self.hass.async_add_executor_job(self._player.queue, media_id)
|
|
||||||
|
|
||||||
def media_play(self) -> None:
|
|
||||||
"""Play."""
|
|
||||||
self._player.play()
|
|
||||||
|
|
||||||
def media_pause(self) -> None:
|
|
||||||
"""Pause."""
|
|
||||||
self._player.pause()
|
|
||||||
|
|
||||||
def media_next_track(self) -> None:
|
|
||||||
"""Next track."""
|
|
||||||
self._player.next()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def media_content_id(self):
|
|
||||||
"""Content ID of currently playing media."""
|
|
||||||
return self._uri
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def volume_level(self):
|
|
||||||
"""Return the volume level."""
|
|
||||||
return self._volume
|
|
||||||
|
|
||||||
@property
|
|
||||||
def media_duration(self):
|
|
||||||
"""Duration of current playing media in seconds."""
|
|
||||||
return self._duration
|
|
||||||
|
|
||||||
@property
|
|
||||||
def media_title(self):
|
|
||||||
"""Media title."""
|
|
||||||
return self._title
|
|
||||||
|
|
||||||
@property
|
|
||||||
def media_artist(self):
|
|
||||||
"""Media artist."""
|
|
||||||
return self._artist
|
|
||||||
|
|
||||||
@property
|
|
||||||
def media_album_name(self):
|
|
||||||
"""Media album."""
|
|
||||||
return self._album
|
|
||||||
|
|
||||||
async def async_browse_media(
|
|
||||||
self,
|
|
||||||
media_content_type: MediaType | str | None = None,
|
|
||||||
media_content_id: str | None = None,
|
|
||||||
) -> BrowseMedia:
|
|
||||||
"""Implement the websocket media browsing helper."""
|
|
||||||
return await media_source.async_browse_media(
|
|
||||||
self.hass,
|
|
||||||
media_content_id,
|
|
||||||
content_filter=lambda item: item.media_content_type.startswith("audio/"),
|
|
||||||
)
|
|
||||||
@@ -2563,12 +2563,6 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"iot_class": "cloud_polling"
|
"iot_class": "cloud_polling"
|
||||||
},
|
},
|
||||||
"gstreamer": {
|
|
||||||
"name": "GStreamer",
|
|
||||||
"integration_type": "hub",
|
|
||||||
"config_flow": false,
|
|
||||||
"iot_class": "local_push"
|
|
||||||
},
|
|
||||||
"gtfs": {
|
"gtfs": {
|
||||||
"name": "General Transit Feed Specification (GTFS)",
|
"name": "General Transit Feed Specification (GTFS)",
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
|
|||||||
3
requirements_all.txt
generated
3
requirements_all.txt
generated
@@ -1118,9 +1118,6 @@ growattServer==1.7.1
|
|||||||
# homeassistant.components.google_sheets
|
# homeassistant.components.google_sheets
|
||||||
gspread==5.5.0
|
gspread==5.5.0
|
||||||
|
|
||||||
# homeassistant.components.gstreamer
|
|
||||||
gstreamer-player==1.1.2
|
|
||||||
|
|
||||||
# homeassistant.components.profiler
|
# homeassistant.components.profiler
|
||||||
guppy3==3.1.5;python_version<'3.14'
|
guppy3==3.1.5;python_version<'3.14'
|
||||||
|
|
||||||
|
|||||||
3
requirements_test_all.txt
generated
3
requirements_test_all.txt
generated
@@ -979,9 +979,6 @@ growattServer==1.7.1
|
|||||||
# homeassistant.components.google_sheets
|
# homeassistant.components.google_sheets
|
||||||
gspread==5.5.0
|
gspread==5.5.0
|
||||||
|
|
||||||
# homeassistant.components.gstreamer
|
|
||||||
gstreamer-player==1.1.2
|
|
||||||
|
|
||||||
# homeassistant.components.profiler
|
# homeassistant.components.profiler
|
||||||
guppy3==3.1.5;python_version<'3.14'
|
guppy3==3.1.5;python_version<'3.14'
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,6 @@ INTEGRATIONS_WITHOUT_QUALITY_SCALE_FILE = [
|
|||||||
"greenwave",
|
"greenwave",
|
||||||
"group",
|
"group",
|
||||||
"growatt_server",
|
"growatt_server",
|
||||||
"gstreamer",
|
|
||||||
"gtfs",
|
"gtfs",
|
||||||
"guardian",
|
"guardian",
|
||||||
"harman_kardon_avr",
|
"harman_kardon_avr",
|
||||||
@@ -1473,7 +1472,6 @@ INTEGRATIONS_WITHOUT_SCALE = [
|
|||||||
"greenwave",
|
"greenwave",
|
||||||
"group",
|
"group",
|
||||||
"growatt_server",
|
"growatt_server",
|
||||||
"gstreamer",
|
|
||||||
"gtfs",
|
"gtfs",
|
||||||
"guardian",
|
"guardian",
|
||||||
"harman_kardon_avr",
|
"harman_kardon_avr",
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"""Gstreamer tests."""
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
"""Tests for the Gstreamer platform."""
|
|
||||||
|
|
||||||
from unittest.mock import Mock, patch
|
|
||||||
|
|
||||||
from homeassistant.components.gstreamer import DOMAIN
|
|
||||||
from homeassistant.components.media_player import DOMAIN as PLATFORM_DOMAIN
|
|
||||||
from homeassistant.const import CONF_PLATFORM
|
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
|
||||||
from homeassistant.helpers import issue_registry as ir
|
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
|
|
||||||
@patch.dict("sys.modules", gsp=Mock())
|
|
||||||
async def test_repair_issue_is_created(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
issue_registry: ir.IssueRegistry,
|
|
||||||
) -> None:
|
|
||||||
"""Test repair issue is created."""
|
|
||||||
assert await async_setup_component(
|
|
||||||
hass,
|
|
||||||
PLATFORM_DOMAIN,
|
|
||||||
{
|
|
||||||
PLATFORM_DOMAIN: [
|
|
||||||
{
|
|
||||||
CONF_PLATFORM: DOMAIN,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
assert (
|
|
||||||
HOMEASSISTANT_DOMAIN,
|
|
||||||
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
|
|
||||||
) in issue_registry.issues
|
|
||||||
Reference in New Issue
Block a user