mirror of
https://github.com/elisspace/core.git
synced 2026-10-01 06:49:55 +00:00
Move Sonos to upstream SoCo (#53351)
This commit is contained in:
@@ -9,10 +9,10 @@ import logging
|
||||
import socket
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pysonos
|
||||
from pysonos import events_asyncio
|
||||
from pysonos.core import SoCo
|
||||
from pysonos.exceptions import SoCoException
|
||||
from soco import events_asyncio
|
||||
import soco.config as soco_config
|
||||
from soco.core import SoCo
|
||||
from soco.exceptions import SoCoException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
@@ -109,7 +109,7 @@ async def async_setup(hass, config):
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Sonos from a config entry."""
|
||||
pysonos.config.EVENTS_MODULE = events_asyncio
|
||||
soco_config.EVENTS_MODULE = events_asyncio
|
||||
|
||||
if DATA_SONOS not in hass.data:
|
||||
hass.data[DATA_SONOS] = SonosData()
|
||||
@@ -121,7 +121,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
advertise_addr = config.get(CONF_ADVERTISE_ADDR)
|
||||
if advertise_addr:
|
||||
pysonos.config.EVENT_ADVERTISE_IP = advertise_addr
|
||||
soco_config.EVENT_ADVERTISE_IP = advertise_addr
|
||||
|
||||
if deprecated_address := config.get(CONF_INTERFACE_ADDR):
|
||||
_LOGGER.warning(
|
||||
@@ -140,7 +140,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
def _create_soco(ip_address: str, source: SoCoCreationSource) -> SoCo | None:
|
||||
"""Create a soco instance and return if successful."""
|
||||
try:
|
||||
soco = pysonos.SoCo(ip_address)
|
||||
soco = SoCo(ip_address)
|
||||
# Ensure that the player is available and UID is cached
|
||||
_ = soco.uid
|
||||
_ = soco.volume
|
||||
|
||||
@@ -5,9 +5,9 @@ from collections.abc import Iterator
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pysonos import SoCo
|
||||
from pysonos.alarms import Alarm, get_alarms
|
||||
from pysonos.exceptions import SoCoException
|
||||
from soco import SoCo
|
||||
from soco.alarms import Alarm, get_alarms
|
||||
from soco.exceptions import SoCoException
|
||||
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Config flow for SONOS."""
|
||||
import logging
|
||||
|
||||
import pysonos
|
||||
import soco
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_HOST
|
||||
@@ -18,7 +18,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||
"""Return if there are devices that can be discovered."""
|
||||
result = await hass.async_add_executor_job(pysonos.discover)
|
||||
result = await hass.async_add_executor_job(soco.discover)
|
||||
return bool(result)
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ from __future__ import annotations
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from pysonos.core import SoCo
|
||||
from pysonos.exceptions import SoCoException
|
||||
from soco.core import SoCo
|
||||
from soco.exceptions import SoCoException
|
||||
|
||||
import homeassistant.helpers.device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
|
||||
@@ -5,9 +5,9 @@ from collections.abc import Iterator
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pysonos import SoCo
|
||||
from pysonos.data_structures import DidlFavorite
|
||||
from pysonos.exceptions import SoCoException
|
||||
from soco import SoCo
|
||||
from soco.data_structures import DidlFavorite
|
||||
from soco.exceptions import SoCoException
|
||||
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import functools as ft
|
||||
import logging
|
||||
from typing import Any, Callable
|
||||
|
||||
from pysonos.exceptions import SoCoException, SoCoUPnPException
|
||||
from soco.exceptions import SoCoException, SoCoUPnPException
|
||||
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from collections.abc import Callable, Coroutine
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pysonos import SoCo
|
||||
from soco import SoCo
|
||||
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "Sonos",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/sonos",
|
||||
"requirements": ["pysonos==0.0.53"],
|
||||
"requirements": ["soco==0.23.1"],
|
||||
"dependencies": ["ssdp"],
|
||||
"after_dependencies": ["plex", "zeroconf"],
|
||||
"zeroconf": ["_sonos._tcp.local."],
|
||||
|
||||
@@ -6,8 +6,8 @@ import logging
|
||||
from typing import Any
|
||||
import urllib.parse
|
||||
|
||||
from pysonos import alarms
|
||||
from pysonos.core import (
|
||||
from soco import alarms
|
||||
from soco.core import (
|
||||
MUSIC_SRC_LINE_IN,
|
||||
MUSIC_SRC_RADIO,
|
||||
PLAY_MODE_BY_MEANING,
|
||||
|
||||
@@ -11,13 +11,13 @@ from typing import Any, Callable
|
||||
import urllib.parse
|
||||
|
||||
import async_timeout
|
||||
from pysonos.core import MUSIC_SRC_LINE_IN, MUSIC_SRC_RADIO, MUSIC_SRC_TV, SoCo
|
||||
from pysonos.data_structures import DidlAudioBroadcast, DidlPlaylistContainer
|
||||
from pysonos.events_base import Event as SonosEvent, SubscriptionBase
|
||||
from pysonos.exceptions import SoCoException, SoCoUPnPException
|
||||
from pysonos.music_library import MusicLibrary
|
||||
from pysonos.plugins.sharelink import ShareLinkPlugin
|
||||
from pysonos.snapshot import Snapshot
|
||||
from soco.core import MUSIC_SRC_LINE_IN, MUSIC_SRC_RADIO, MUSIC_SRC_TV, SoCo
|
||||
from soco.data_structures import DidlAudioBroadcast, DidlPlaylistContainer
|
||||
from soco.events_base import Event as SonosEvent, SubscriptionBase
|
||||
from soco.exceptions import SoCoException, SoCoUPnPException
|
||||
from soco.music_library import MusicLibrary
|
||||
from soco.plugins.sharelink import ShareLinkPlugin
|
||||
from soco.snapshot import Snapshot
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
|
||||
@@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from pysonos.exceptions import SoCoException, SoCoUPnPException
|
||||
from soco.exceptions import SoCoException, SoCoUPnPException
|
||||
|
||||
from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity
|
||||
from homeassistant.const import ATTR_TIME
|
||||
|
||||
Reference in New Issue
Block a user