1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 00:20:30 +01:00

Fix logging of unavailable entities in entity call (#165370)

This commit is contained in:
Artur Pragacz
2026-03-12 09:53:30 +01:00
committed by GitHub
parent 443ff7efe1
commit 0f2dbdf4f4
2 changed files with 24 additions and 3 deletions

View File

@@ -782,6 +782,8 @@ async def entity_service_call(
all_referenced,
)
entity_candidates = [e for e in entity_candidates if e.available]
if not target_all_entities:
assert referenced is not None
# Only report on explicit referenced entities
@@ -792,9 +794,6 @@ async def entity_service_call(
entities: list[Entity] = []
for entity in entity_candidates:
if not entity.available:
continue
# Skip entities that don't have the required device class.
if (
entity_device_classes is not None

View File

@@ -2411,6 +2411,28 @@ async def test_entity_service_call_warn_referenced(
) in caplog.text
async def test_entity_service_call_warn_unavailable(
hass: HomeAssistant,
mock_entities: dict[str, MockEntity],
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test that explicitly referenced unavailable entities are logged."""
mock_entities["light.kitchen"] = MockEntity(
entity_id="light.kitchen", available=False
)
call = ServiceCall(
hass,
"test_domain",
"test_service",
{"entity_id": ["light.kitchen"]},
)
await service.entity_service_call(hass, mock_entities, "", call)
assert (
"Referenced entities light.kitchen are missing or not currently available"
) in caplog.text
async def test_async_extract_entities_warn_referenced(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None: