diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index d3f4144a293..ea80591a989 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -291,7 +291,7 @@ def _async_dispatch_entity_id_event( """Dispatch to listeners.""" if not (callbacks_list := callbacks.get(event.data["entity_id"])): return - for job in callbacks_list[:]: + for job in callbacks_list.copy(): try: hass.async_run_hass_job(job, event) except Exception: # pylint: disable=broad-except @@ -428,7 +428,7 @@ def _async_dispatch_old_entity_id_or_entity_id_event( ) ): return - for job in callbacks_list[:]: + for job in callbacks_list.copy(): try: hass.async_run_hass_job(job, event) except Exception: # pylint: disable=broad-except @@ -499,7 +499,7 @@ def _async_dispatch_device_id_event( """Dispatch to listeners.""" if not (callbacks_list := callbacks.get(event.data["device_id"])): return - for job in callbacks_list[:]: + for job in callbacks_list.copy(): try: hass.async_run_hass_job(job, event) except Exception: # pylint: disable=broad-except