mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Add async_has_entity_registry_updated_listeners (#142772)
This commit is contained in:
parent
198a6b2e8f
commit
870350b961
@ -551,6 +551,12 @@ def async_track_entity_registry_updated_event(
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def async_has_entity_registry_updated_listeners(hass: HomeAssistant) -> bool:
|
||||
"""Check if async_track_entity_registry_updated_event has been called yet."""
|
||||
return _KEYED_TRACK_ENTITY_REGISTRY_UPDATED.key in hass.data
|
||||
|
||||
|
||||
@callback
|
||||
def _async_device_registry_updated_filter(
|
||||
hass: HomeAssistant,
|
||||
|
@ -30,6 +30,7 @@ from homeassistant.helpers.event import (
|
||||
TrackTemplate,
|
||||
TrackTemplateResult,
|
||||
async_call_later,
|
||||
async_has_entity_registry_updated_listeners,
|
||||
async_track_device_registry_updated_event,
|
||||
async_track_entity_registry_updated_event,
|
||||
async_track_point_in_time,
|
||||
@ -4682,12 +4683,17 @@ async def test_async_track_entity_registry_updated_event(hass: HomeAssistant) ->
|
||||
def run_callback(event):
|
||||
event_data.append(event.data)
|
||||
|
||||
assert async_has_entity_registry_updated_listeners(hass) is False
|
||||
|
||||
unsub1 = async_track_entity_registry_updated_event(
|
||||
hass, entity_id, run_callback, job_type=ha.HassJobType.Callback
|
||||
)
|
||||
unsub2 = async_track_entity_registry_updated_event(
|
||||
hass, new_entity_id, run_callback
|
||||
)
|
||||
|
||||
assert async_has_entity_registry_updated_listeners(hass) is True
|
||||
|
||||
hass.bus.async_fire(
|
||||
EVENT_ENTITY_REGISTRY_UPDATED, {"action": "create", "entity_id": entity_id}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user