Cast Python Async Await Syntax (#12816)

pull/12825/head
Otto Winter 2018-03-01 23:25:52 +01:00 committed by Martin Hjelmare
parent b186b27600
commit b9d8789771
1 changed files with 4 additions and 7 deletions

View File

@ -5,7 +5,6 @@ For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.cast/
"""
# pylint: disable=import-error
import asyncio
import logging
import threading
import functools
@ -135,9 +134,8 @@ def _async_create_cast_device(hass, chromecast):
return None
@asyncio.coroutine
def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
async_add_devices, discovery_info=None):
async def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
async_add_devices, discovery_info=None):
"""Set up the cast platform."""
import pychromecast
@ -187,7 +185,7 @@ def async_setup_platform(hass: HomeAssistantType, config: ConfigType,
try:
func = functools.partial(pychromecast.Chromecast, *want_host,
tries=SOCKET_CLIENT_RETRIES)
chromecast = yield from hass.async_add_job(func)
chromecast = await hass.async_add_job(func)
except pychromecast.ChromecastConnectionError as err:
_LOGGER.warning("Can't set up chromecast on %s: %s",
want_host[0], err)
@ -439,8 +437,7 @@ class CastDevice(MediaPlayerDevice):
self.cast_status = self.cast.status
self.media_status = self.cast.media_controller.status
@asyncio.coroutine
def async_will_remove_from_hass(self):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect Chromecast object when removed."""
self._async_disconnect()