diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index e2e25bcfbd3..2576970065f 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -289,11 +289,9 @@ class EntityPlatform(object): This method must be run in the event loop. """ - for entity in new_entities: - ret = yield from self.component.async_add_entity(entity, self) - if ret: - self.platform_entities.append(entity) + tasks = [self._async_process_entity(entity) for entity in new_entities] + yield from asyncio.gather(*tasks, loop=self.component.hass.loop) yield from self.component.async_update_group() if self._async_unsub_polling is not None or \ @@ -305,6 +303,13 @@ class EntityPlatform(object): self.component.hass, self._update_entity_states, second=range(0, 60, self.scan_interval)) + @asyncio.coroutine + def _async_process_entity(self, new_entity): + """Add entities to StateMachine.""" + ret = yield from self.component.async_add_entity(new_entity, self) + if ret: + self.platform_entities.append(new_entity) + @asyncio.coroutine def async_reset(self): """Remove all entities and reset data.