mirror of
https://github.com/home-assistant/core
synced 2024-09-03 08:14:07 +02:00
Move imports to top for gpmdp (#29413)
This commit is contained in:
parent
95bc97fb6a
commit
88c1a630d8
@ -5,8 +5,9 @@ import socket
|
||||
import time
|
||||
|
||||
import voluptuous as vol
|
||||
from websocket import _exceptions, create_connection
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA
|
||||
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerDevice
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SUPPORT_NEXT_TRACK,
|
||||
@ -65,8 +66,6 @@ def request_configuration(hass, config, url, add_entities_callback):
|
||||
)
|
||||
|
||||
return
|
||||
from websocket import create_connection
|
||||
|
||||
websocket = create_connection((url), timeout=1)
|
||||
websocket.send(
|
||||
json.dumps(
|
||||
@ -81,7 +80,6 @@ def request_configuration(hass, config, url, add_entities_callback):
|
||||
def gpmdp_configuration_callback(callback_data):
|
||||
"""Handle configuration changes."""
|
||||
while True:
|
||||
from websocket import _exceptions
|
||||
|
||||
try:
|
||||
msg = json.loads(websocket.recv())
|
||||
@ -174,7 +172,6 @@ class GPMDP(MediaPlayerDevice):
|
||||
|
||||
def __init__(self, name, url, code):
|
||||
"""Initialize the media player."""
|
||||
from websocket import create_connection
|
||||
|
||||
self._connection = create_connection
|
||||
self._url = url
|
||||
@ -210,7 +207,6 @@ class GPMDP(MediaPlayerDevice):
|
||||
|
||||
def send_gpmdp_msg(self, namespace, method, with_id=True):
|
||||
"""Send ws messages to GPMDP and verify request id in response."""
|
||||
from websocket import _exceptions
|
||||
|
||||
try:
|
||||
websocket = self.get_ws()
|
||||
|
Loading…
Reference in New Issue
Block a user