diff --git a/homeassistant/components/songpal/media_player.py b/homeassistant/components/songpal/media_player.py index 9f5ae9d1ac6..0567cd0ea6a 100644 --- a/homeassistant/components/songpal/media_player.py +++ b/homeassistant/components/songpal/media_player.py @@ -4,6 +4,14 @@ import logging from collections import OrderedDict import voluptuous as vol +from songpal import ( + Device, + SongpalException, + VolumeChange, + ContentChange, + PowerChange, + ConnectChange, +) from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA from homeassistant.components.media_player.const import ( @@ -60,8 +68,6 @@ SET_SOUND_SCHEMA = vol.Schema( async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Songpal platform.""" - from songpal import SongpalException - if PLATFORM not in hass.data: hass.data[PLATFORM] = {} @@ -117,8 +123,6 @@ class SongpalDevice(MediaPlayerDevice): def __init__(self, name, endpoint, poll=False): """Init.""" - from songpal import Device - self._name = name self._endpoint = endpoint self._poll = poll @@ -151,7 +155,6 @@ class SongpalDevice(MediaPlayerDevice): async def async_activate_websocket(self): """Activate websocket for listening if wanted.""" _LOGGER.info("Activating websocket connection..") - from songpal import VolumeChange, ContentChange, PowerChange, ConnectChange async def _volume_changed(volume: VolumeChange): _LOGGER.debug("Volume changed: %s", volume) @@ -230,8 +233,6 @@ class SongpalDevice(MediaPlayerDevice): async def async_update(self): """Fetch updates from the device.""" - from songpal import SongpalException - try: volumes = await self.dev.get_volume_information() if not volumes: