diff --git a/homeassistant/components/__init__.py b/homeassistant/components/__init__.py index bdb89dd60fa..8715f0baa96 100644 --- a/homeassistant/components/__init__.py +++ b/homeassistant/components/__init__.py @@ -31,7 +31,7 @@ SERVICE_RELOAD_CORE_CONFIG = 'reload_core_config' SERVICE_CHECK_CONFIG = 'check_config' SERVICE_UPDATE_ENTITY = 'update_entity' SCHEMA_UPDATE_ENTITY = vol.Schema({ - ATTR_ENTITY_ID: cv.entity_id + ATTR_ENTITY_ID: cv.entity_ids }) @@ -142,8 +142,11 @@ async def async_setup(hass: ha.HomeAssistant, config: dict) -> Awaitable[bool]: async def async_handle_update_service(call): """Service handler for updating an entity.""" - await hass.helpers.entity_component.async_update_entity( - call.data[ATTR_ENTITY_ID]) + tasks = [hass.helpers.entity_component.async_update_entity(entity) + for entity in call.data[ATTR_ENTITY_ID]] + + if tasks: + await asyncio.wait(tasks) hass.services.async_register( ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP, async_handle_core_service) diff --git a/homeassistant/components/services.yaml b/homeassistant/components/services.yaml index 62da489aab4..e8512d67fc4 100644 --- a/homeassistant/components/services.yaml +++ b/homeassistant/components/services.yaml @@ -527,6 +527,12 @@ homeassistant: entity_id: description: The entity_id of the device to turn off. example: light.living_room + update_entity: + description: Force one or more entities to update its data + fields: + entity_id: + description: One or multiple entity_ids to update. Can be a list. + example: light.living_room xiaomi_aqara: play_ringtone: diff --git a/tests/components/test_init.py b/tests/components/test_init.py index b9152bbdd6a..139a97463ea 100644 --- a/tests/components/test_init.py +++ b/tests/components/test_init.py @@ -364,7 +364,7 @@ async def test_entity_update(hass): with patch('homeassistant.helpers.entity_component.async_update_entity', return_value=mock_coro()) as mock_update: await hass.services.async_call('homeassistant', 'update_entity', { - 'entity_id': 'light.kitchen' + 'entity_id': ['light.kitchen'] }, blocking=True) assert len(mock_update.mock_calls) == 1