Remove service helper (6) (#16920)

* Update automation

* Update group

* Async_create_task
This commit is contained in:
cdce8p 2018-09-27 23:14:09 +02:00 committed by Paulus Schoutsen
parent 70b901017f
commit f879ac0993
7 changed files with 95 additions and 97 deletions

View file

@ -190,10 +190,13 @@ class EntityComponent:
sorted(self.entities,
key=lambda entity: entity.name or entity.entity_id)]
self.hass.components.group.async_set_group(
slugify(self.group_name), name=self.group_name,
visible=False, entity_ids=ids
)
self.hass.async_create_task(
self.hass.services.async_call(
'group', 'set', dict(
object_id=slugify(self.group_name),
name=self.group_name,
visible=False,
entities=ids)))
async def _async_reset(self):
"""Remove entities and reset the entity component to initial values.
@ -212,7 +215,9 @@ class EntityComponent:
self.config = None
if self.group_name is not None:
self.hass.components.group.async_remove(slugify(self.group_name))
await self.hass.services.async_call(
'group', 'remove', dict(
object_id=slugify(self.group_name)))
async def async_remove_entity(self, entity_id):
"""Remove an entity managed by one of the platforms."""