Convert more files to async/await syntax (#14142)
* Move more files to async/await syntax * Attempt Work around pylint bug Using lazytox :P
This commit is contained in:
1 parent
a0b14c2913
commit
a4bf421044
27 files changed
+229
-327
No files matched your search
@@ -4,7 +4,6 @@ Combination of multiple media players into one for a universal controller.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/media_player.universal/
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
# pylint: disable=import-error
|
||||
from copy import copy
|
||||
@@ -63,8 +62,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
}, extra=vol.REMOVE_EXTRA)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up the universal media players."""
|
||||
player = UniversalMediaPlayer(
|
||||
hass,
|
||||
@@ -99,8 +98,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
if state_template is not None:
|
||||
self._state_template.hass = hass
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe to children and template state changes.
|
||||
|
||||
This method must be run in the event loop and returns a coroutine.
|
||||
@@ -144,15 +142,14 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
active_child = self._child_state
|
||||
return active_child.attributes.get(attr_name) if active_child else None
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_call_service(self, service_name, service_data=None,
|
||||
allow_override=False):
|
||||
async def _async_call_service(self, service_name, service_data=None,
|
||||
allow_override=False):
|
||||
"""Call either a specified or active child's service."""
|
||||
if service_data is None:
|
||||
service_data = {}
|
||||
|
||||
if allow_override and service_name in self._cmds:
|
||||
yield from async_call_from_config(
|
||||
await async_call_from_config(
|
||||
self.hass, self._cmds[service_name],
|
||||
variables=service_data, blocking=True,
|
||||
validate_config=False)
|
||||
@@ -165,7 +162,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
|
||||
service_data[ATTR_ENTITY_ID] = active_child.entity_id
|
||||
|
||||
yield from self.hass.services.async_call(
|
||||
await self.hass.services.async_call(
|
||||
DOMAIN, service_name, service_data, blocking=True)
|
||||
|
||||
@property
|
||||
@@ -506,8 +503,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||
return self._async_call_service(
|
||||
SERVICE_SHUFFLE_SET, data, allow_override=True)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
async def async_update(self):
|
||||
"""Update state in HA."""
|
||||
for child_name in self._children:
|
||||
child_state = self.hass.states.get(child_name)
|
||||
|
||||
Reference in new issue
Block a user