mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Avoid creating tasks in homeassistant_alerts when the debouncer will not fire (#113580)
This commit is contained in:
parent
4174d88ad7
commit
bb12d2e865
@ -98,11 +98,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
function=coordinator.async_refresh,
|
function=coordinator.async_refresh,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _component_loaded(_: Event) -> None:
|
@callback
|
||||||
await refresh_debouncer.async_call()
|
def _component_loaded(_: Event) -> None:
|
||||||
|
refresh_debouncer.async_schedule_call()
|
||||||
|
|
||||||
await coordinator.async_refresh()
|
await coordinator.async_refresh()
|
||||||
hass.bus.async_listen(EVENT_COMPONENT_LOADED, _component_loaded)
|
hass.bus.async_listen(
|
||||||
|
EVENT_COMPONENT_LOADED, _component_loaded, run_immediately=True
|
||||||
|
)
|
||||||
|
|
||||||
async_at_start(hass, initial_refresh)
|
async_at_start(hass, initial_refresh)
|
||||||
|
|
||||||
|
@ -323,33 +323,33 @@ async def test_alerts_refreshed_on_component_load(
|
|||||||
):
|
):
|
||||||
assert await async_setup_component(hass, DOMAIN, {})
|
assert await async_setup_component(hass, DOMAIN, {})
|
||||||
|
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
await client.send_json({"id": 1, "type": "repairs/list_issues"})
|
await client.send_json({"id": 1, "type": "repairs/list_issues"})
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
assert msg["result"] == {
|
assert msg["result"] == {
|
||||||
"issues": [
|
"issues": [
|
||||||
{
|
{
|
||||||
"breaks_in_ha_version": None,
|
"breaks_in_ha_version": None,
|
||||||
"created": ANY,
|
"created": ANY,
|
||||||
"dismissed_version": None,
|
"dismissed_version": None,
|
||||||
"domain": "homeassistant_alerts",
|
"domain": "homeassistant_alerts",
|
||||||
"ignored": False,
|
"ignored": False,
|
||||||
"is_fixable": False,
|
"is_fixable": False,
|
||||||
"issue_id": f"{alert}.markdown_{integration}",
|
"issue_id": f"{alert}.markdown_{integration}",
|
||||||
"issue_domain": integration,
|
"issue_domain": integration,
|
||||||
"learn_more_url": None,
|
"learn_more_url": None,
|
||||||
"severity": "warning",
|
"severity": "warning",
|
||||||
"translation_key": "alert",
|
"translation_key": "alert",
|
||||||
"translation_placeholders": {
|
"translation_placeholders": {
|
||||||
"title": f"Title for {alert}",
|
"title": f"Title for {alert}",
|
||||||
"description": f"Content for {alert}",
|
"description": f"Content for {alert}",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for alert, integration in initial_alerts
|
for alert, integration in initial_alerts
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.homeassistant_alerts.__version__",
|
"homeassistant.components.homeassistant_alerts.__version__",
|
||||||
@ -368,33 +368,33 @@ async def test_alerts_refreshed_on_component_load(
|
|||||||
freezer.tick(COMPONENT_LOADED_COOLDOWN + 1)
|
freezer.tick(COMPONENT_LOADED_COOLDOWN + 1)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
await client.send_json({"id": 2, "type": "repairs/list_issues"})
|
await client.send_json({"id": 2, "type": "repairs/list_issues"})
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
assert msg["result"] == {
|
assert msg["result"] == {
|
||||||
"issues": [
|
"issues": [
|
||||||
{
|
{
|
||||||
"breaks_in_ha_version": None,
|
"breaks_in_ha_version": None,
|
||||||
"created": ANY,
|
"created": ANY,
|
||||||
"dismissed_version": None,
|
"dismissed_version": None,
|
||||||
"domain": "homeassistant_alerts",
|
"domain": "homeassistant_alerts",
|
||||||
"ignored": False,
|
"ignored": False,
|
||||||
"is_fixable": False,
|
"is_fixable": False,
|
||||||
"issue_id": f"{alert}.markdown_{integration}",
|
"issue_id": f"{alert}.markdown_{integration}",
|
||||||
"issue_domain": integration,
|
"issue_domain": integration,
|
||||||
"learn_more_url": None,
|
"learn_more_url": None,
|
||||||
"severity": "warning",
|
"severity": "warning",
|
||||||
"translation_key": "alert",
|
"translation_key": "alert",
|
||||||
"translation_placeholders": {
|
"translation_placeholders": {
|
||||||
"title": f"Title for {alert}",
|
"title": f"Title for {alert}",
|
||||||
"description": f"Content for {alert}",
|
"description": f"Content for {alert}",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for alert, integration in late_alerts
|
for alert, integration in late_alerts
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user