Skip to content

Commit

Permalink
OpenAI: Ignore devices without a name (home-assistant#87558)
Browse files Browse the repository at this point in the history
Ignore devices without a name
  • Loading branch information
balloob authored Feb 7, 2023
1 parent ea4e2ab commit 400c88a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/components/openai_conversation/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{%- for area in areas %}
{%- set area_info = namespace(printed=false) %}
{%- for device in area_devices(area.name) -%}
{%- if not device_attr(device, "disabled_by") and not device_attr(device, "entry_type") %}
{%- if not device_attr(device, "disabled_by") and not device_attr(device, "entry_type") and device_attr(device, "name") %}
{%- if not area_info.printed %}
{{ area.name }}:
Expand Down
7 changes: 7 additions & 0 deletions tests/components/openai_conversation/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ async def test_default_prompt(hass, mock_init_component):
device_reg.async_update_device(
device.id, disabled_by=device_registry.DeviceEntryDisabler.USER
)
device = device_reg.async_get_or_create(
config_entry_id="1234",
connections={("test", "9876-no-name")},
manufacturer="Test Manufacturer NoName",
model="Test Model NoName",
suggested_area="Test Area 2",
)

with patch("openai.Completion.acreate") as mock_create:
result = await conversation.async_converse(hass, "hello", None, Context())
Expand Down

0 comments on commit 400c88a

Please sign in to comment.