Skip to content

Commit e0ea3e7

Browse files
committed
Fix setup assist entity lookup failure status
1 parent f9658c4 commit e0ea3e7

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

helpers/setup_assist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def setup_assist_suggestion(
106106
clean_entity_id,
107107
err,
108108
)
109-
entity_entry = None
109+
return unsupported_setup_assist_suggestion("entity_lookup_failed", clean_entity_id)
110110
if entity_entry is None:
111111
return SetupAssistSuggestion(entity_id=clean_entity_id, status="not_found")
112112

tests 2/test_setup_assist.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,28 @@ def test_setup_assist_logs_registry_failures_without_changing_fallback():
182182
debug.assert_called()
183183

184184

185+
def test_setup_assist_entity_lookup_failure_is_not_reported_as_missing():
186+
setup_assist = _load_setup_assist_module()
187+
188+
class BrokenEntityRegistry:
189+
def async_get(self, _entity_id):
190+
raise RuntimeError("entity lookup exploded")
191+
192+
hass = SimpleNamespace(entities={}, devices={}, areas={}, labels={})
193+
with (
194+
mock.patch.object(setup_assist.er, "async_get", return_value=BrokenEntityRegistry()),
195+
mock.patch.object(setup_assist._LOGGER, "debug") as debug,
196+
):
197+
suggestion = setup_assist.setup_assist_suggestion(
198+
hass,
199+
"sensor.example_humidity",
200+
)
201+
202+
assert suggestion.status == "unsupported"
203+
assert suggestion.warnings == ("entity_lookup_failed",)
204+
debug.assert_called()
205+
206+
185207
if __name__ == "__main__":
186208
tests = [
187209
(name, value)

0 commit comments

Comments
 (0)