Cast Python Async Await Syntax (#12816)
This commit is contained in:
parent
b186b27600
commit
b9d8789771
1 changed files with 4 additions and 7 deletions
|
@ -5,7 +5,6 @@ For more details about this platform, please refer to the documentation at
|
||||||
https://home-assistant.io/components/media_player.cast/
|
https://home-assistant.io/components/media_player.cast/
|
||||||
"""
|
"""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import functools
|
import functools
|
||||||
|
@ -135,8 +134,7 @@ def _async_create_cast_device(hass, chromecast):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
|
||||||
def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
|
|
||||||
async_add_devices, discovery_info=None):
|
async_add_devices, discovery_info=None):
|
||||||
"""Set up the cast platform."""
|
"""Set up the cast platform."""
|
||||||
import pychromecast
|
import pychromecast
|
||||||
|
@ -187,7 +185,7 @@ def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
|
||||||
try:
|
try:
|
||||||
func = functools.partial(pychromecast.Chromecast, *want_host,
|
func = functools.partial(pychromecast.Chromecast, *want_host,
|
||||||
tries=SOCKET_CLIENT_RETRIES)
|
tries=SOCKET_CLIENT_RETRIES)
|
||||||
chromecast = yield from hass.async_add_job(func)
|
chromecast = await hass.async_add_job(func)
|
||||||
except pychromecast.ChromecastConnectionError as err:
|
except pychromecast.ChromecastConnectionError as err:
|
||||||
_LOGGER.warning("Can't set up chromecast on %s: %s",
|
_LOGGER.warning("Can't set up chromecast on %s: %s",
|
||||||
want_host[0], err)
|
want_host[0], err)
|
||||||
|
@ -439,8 +437,7 @@ class CastDevice(MediaPlayerDevice):
|
||||||
self.cast_status = self.cast.status
|
self.cast_status = self.cast.status
|
||||||
self.media_status = self.cast.media_controller.status
|
self.media_status = self.cast.media_controller.status
|
||||||
|
|
||||||
@asyncio.coroutine
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
def async_will_remove_from_hass(self):
|
|
||||||
"""Disconnect Chromecast object when removed."""
|
"""Disconnect Chromecast object when removed."""
|
||||||
self._async_disconnect()
|
self._async_disconnect()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue