mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00: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 time
|
||||||
|
|
||||||
import voluptuous as vol
|
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 (
|
from homeassistant.components.media_player.const import (
|
||||||
MEDIA_TYPE_MUSIC,
|
MEDIA_TYPE_MUSIC,
|
||||||
SUPPORT_NEXT_TRACK,
|
SUPPORT_NEXT_TRACK,
|
||||||
@ -65,8 +66,6 @@ def request_configuration(hass, config, url, add_entities_callback):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
from websocket import create_connection
|
|
||||||
|
|
||||||
websocket = create_connection((url), timeout=1)
|
websocket = create_connection((url), timeout=1)
|
||||||
websocket.send(
|
websocket.send(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
@ -81,7 +80,6 @@ def request_configuration(hass, config, url, add_entities_callback):
|
|||||||
def gpmdp_configuration_callback(callback_data):
|
def gpmdp_configuration_callback(callback_data):
|
||||||
"""Handle configuration changes."""
|
"""Handle configuration changes."""
|
||||||
while True:
|
while True:
|
||||||
from websocket import _exceptions
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
msg = json.loads(websocket.recv())
|
msg = json.loads(websocket.recv())
|
||||||
@ -174,7 +172,6 @@ class GPMDP(MediaPlayerDevice):
|
|||||||
|
|
||||||
def __init__(self, name, url, code):
|
def __init__(self, name, url, code):
|
||||||
"""Initialize the media player."""
|
"""Initialize the media player."""
|
||||||
from websocket import create_connection
|
|
||||||
|
|
||||||
self._connection = create_connection
|
self._connection = create_connection
|
||||||
self._url = url
|
self._url = url
|
||||||
@ -210,7 +207,6 @@ class GPMDP(MediaPlayerDevice):
|
|||||||
|
|
||||||
def send_gpmdp_msg(self, namespace, method, with_id=True):
|
def send_gpmdp_msg(self, namespace, method, with_id=True):
|
||||||
"""Send ws messages to GPMDP and verify request id in response."""
|
"""Send ws messages to GPMDP and verify request id in response."""
|
||||||
from websocket import _exceptions
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
websocket = self.get_ws()
|
websocket = self.get_ws()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user