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

"all" entity_id not working #65587

Closed
pascalmtts opened this issue Feb 3, 2022 · 8 comments · Fixed by #68513
Closed

"all" entity_id not working #65587

pascalmtts opened this issue Feb 3, 2022 · 8 comments · Fixed by #68513

Comments

@pascalmtts
Copy link

pascalmtts commented Feb 3, 2022

The problem

Calling Services like „light.turn_off“ or „cover.close_cover“ with target entity_id set to „all“ is not working anymore.

What version of Home Assistant Core has the issue?

core-2022.2.1

What was the last working version of Home Assistant Core?

core-2021.12.10

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

Link to integration documentation on our website

No response

Example YAML snippet

service: light.turn_off
target:
  entity_id: all

Anything in the logs that might be useful for us?

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:1375 
First occurred: 22:18:09 (1 occurrences) 
Last logged: 22:18:09

websocket_api script: Error executing script. Error for call_service at pos 1: Template rendered invalid entity IDs: all

Additional information

No response

@travipross
Copy link

Also experiencing this today after upgrading to the docker version of 2022.2.0:

Logger: homeassistant.components.websocket_api.http.connection
Source: helpers/service.py:229
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 10:39:05 PM (3 occurrences)
Last logged: 10:41:00 PM

[139758536491360] Template rendered invalid entity IDs: all
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 221, in async_prepare_call_from_config
    target[CONF_ENTITY_ID] = entity_registry.async_resolve_entity_ids(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 921, in async_resolve_entity_ids
    tmp = [
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 924, in <listcomp>
    if (resolved_item := resolve_entity(item)) is not None
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 918, in resolve_entity
    raise vol.Invalid(f"Unknown entity registry entry {entity_id_or_uuid}")
voluptuous.error.Invalid: Unknown entity registry entry a

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 190, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1667, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 282, in service_handler
    await script_entity.async_turn_on(
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 386, in async_turn_on
    await coro
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 412, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1253, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 354, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 372, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 548, in _async_call_service_step
    params = service.async_prepare_call_from_config(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 229, in async_prepare_call_from_config
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Template rendered invalid entity IDs: all

@AeroNib
Copy link

AeroNib commented Feb 4, 2022

It seems the entity_id: all target can run or fail as invalid depending on how the YAML is formatted.

Editing an automation using the visual editor to call a service with target all generates a valid YAML configuration according to documentation:

service: light.turn_off
data: {}
target:
  entity_id: all

When triggered, the automation fails with the error (trace for manual trigger):

Error: Template rendered invalid entity IDs: all

Removing the target: key to raise the entity_id: key up a level, the service call works. Removing the data: key has no affect either way. Here's my YAML for the service call that works (trace for manual trigger):

service: light.turn_off
data: {}
entity_id: all

I've verified this affects light.toggle, light.turn_on, and light.turn_off services as well as non-light. services. For example:

service: switch.toggle
data: {}
target:
  entity_id: all

also fails, but the following works:

service: switch.toggle
data: {}
entity_id: all

Software Versions

Core Version: core-2022.2.1
Supervisor Version: supervisor-2022.01.1
OS: Home Assistant OS 7.2

@junior013
Copy link

junior013 commented Feb 5, 2022

@AeroNib

service: switch.toggle
data:
  entity_id: all

also works.

@antonio1475
Copy link

antonio1475 commented Feb 7, 2022

Media Player service with entity all doesn't work either, same as lights. It used to work until 2022.2. Example:

service: media_player.media_stop
data: {}
target:
  entity_id: all

@pascalmtts
Copy link
Author

It seems the entity_id: all target can run or fail as invalid depending on how the YAML is formatted.

Editing an automation using the visual editor to call a service with target all generates a valid YAML configuration according to documentation:


service: light.turn_off

data: {}

target:

  entity_id: all

When triggered, the automation fails with the error (trace for manual trigger):

Error: Template rendered invalid entity IDs: all

Removing the target: key to raise the entity_id: key up a level, the service call works. Removing the data: key has no affect either way. Here's my YAML for the service call that works (trace for manual trigger):


service: light.turn_off

data: {}

entity_id: all

I've verified this affects light.toggle, light.turn_on, and light.turn_off services as well as non-light. services. For example:


service: switch.toggle

data: {}

target:

  entity_id: all

also fails, but the following works:


service: switch.toggle

data: {}

entity_id: all

Software Versions

Core Version: core-2022.2.1

Supervisor Version: supervisor-2022.01.1

OS: Home Assistant OS 7.2

Can confirm that this workaround works.

@cybergrimes
Copy link

cybergrimes commented Feb 8, 2022

@pascalmtts

Following your example I left 'target' in place for 'data' and it worked, in this case it was the services sonos.snapshot, sonos.join, sonos.restore. This is core 2022.2.2, supervisor 2022.01.1, Home Assistant OS 7.2

target: {}
entity_id: all

@pascalmtts
Copy link
Author

@pascalmtts

Following your example I left 'target' in place for 'data' and it worked, in this case it was the services sonos.snapshot, sonos.join, sonos.restore. This is core 2022.2.2, supervisor 2022.01.1, Home Assistant OS 7.2

target: {}
entity_id: all

Yeah as long as the entity_id is not located inside the target object it should work. But this should be fixed anyway.

@alexyao2015
Copy link
Contributor

This pr seems to be a direct cause of this issue. #61172

@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants