move songpal imports to top (#27402)
* move songpal imports to top * Update media_player.pypull/27440/head
parent
ed3516186b
commit
4b8a35dffb
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue