Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lifx light async error #22031

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions homeassistant/components/lifx/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.device_registry as dr
from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.service import extract_entity_ids
from homeassistant.helpers.service import async_extract_entity_ids
import homeassistant.util.color as color_util

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -250,7 +250,7 @@ def register_set_state(self):
async def service_handler(service):
"""Apply a service."""
tasks = []
for light in self.service_to_entities(service):
for light in await self.async_service_to_entities(service):
if service.service == SERVICE_LIFX_SET_STATE:
task = light.set_state(**service.data)
tasks.append(self.hass.async_create_task(task))
Expand All @@ -265,7 +265,7 @@ def register_effects(self):
"""Register the LIFX effects as hass service calls."""
async def service_handler(service):
"""Apply a service, i.e. start an effect."""
entities = self.service_to_entities(service)
entities = await self.async_service_to_entities(service)
if entities:
await self.start_effect(
entities, service.service, **service.data)
Expand Down Expand Up @@ -314,9 +314,9 @@ async def start_effect(self, entities, service, **kwargs):
elif service == SERVICE_EFFECT_STOP:
await self.effects_conductor.stop(bulbs)

def service_to_entities(self, service):
async def async_service_to_entities(self, service):
"""Return the known entities that a service call mentions."""
entity_ids = extract_entity_ids(self.hass, service)
entity_ids = await async_extract_entity_ids(self.hass, service)
if entity_ids:
entities = [entity for entity in self.entities.values()
if entity.entity_id in entity_ids]
Expand Down