Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
cab6ec03
Unverified
Commit
cab6ec03
authored
2 months ago
by
Erik Montnemery
Committed by
GitHub
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix homeassistant/expose_entity/list (#138872)
Co-authored-by:
Paulus Schoutsen
<
balloob@gmail.com
>
parent
eb26a212
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/homeassistant/exposed_entities.py
+7
-4
7 additions, 4 deletions
homeassistant/components/homeassistant/exposed_entities.py
tests/components/homeassistant/test_exposed_entities.py
+26
-8
26 additions, 8 deletions
tests/components/homeassistant/test_exposed_entities.py
with
33 additions
and
12 deletions
homeassistant/components/homeassistant/exposed_entities.py
+
7
−
4
View file @
cab6ec03
...
...
@@ -437,18 +437,21 @@ def ws_expose_entity(
def
ws_list_exposed_entities
(
hass
:
HomeAssistant
,
connection
:
websocket_api
.
ActiveConnection
,
msg
:
dict
[
str
,
Any
]
)
->
None
:
"""
Expose an entity to an
assistant.
"""
"""
List entities which are exposed to
assistant
s
.
"""
result
:
dict
[
str
,
Any
]
=
{}
exposed_entities
=
hass
.
data
[
DATA_EXPOSED_ENTITIES
]
entity_registry
=
er
.
async_get
(
hass
)
for
entity_id
in
chain
(
exposed_entities
.
entities
,
entity_registry
.
entities
):
result
[
entity_id
]
=
{}
exposed_to
=
{}
entity_settings
=
async_get_entity_settings
(
hass
,
entity_id
)
for
assistant
,
settings
in
entity_settings
.
items
():
if
"
should_expose
"
not
in
settings
:
if
"
should_expose
"
not
in
settings
or
not
settings
[
"
should_expose
"
]
:
continue
result
[
entity_id
][
assistant
]
=
settings
[
"
should_expose
"
]
exposed_to
[
assistant
]
=
True
if
not
exposed_to
:
continue
result
[
entity_id
]
=
exposed_to
connection
.
send_result
(
msg
[
"
id
"
],
{
"
exposed_entities
"
:
result
})
...
...
This diff is collapsed.
Click to expand it.
tests/components/homeassistant/test_exposed_entities.py
+
26
−
8
View file @
cab6ec03
...
...
@@ -497,28 +497,48 @@ async def test_list_exposed_entities(
entry1
=
entity_registry
.
async_get_or_create
(
"
test
"
,
"
test
"
,
"
unique1
"
)
entry2
=
entity_registry
.
async_get_or_create
(
"
test
"
,
"
test
"
,
"
unique2
"
)
entity_registry
.
async_get_or_create
(
"
test
"
,
"
test
"
,
"
unique3
"
)
# Set options for registered entities
await
ws_client
.
send_json_auto_id
(
{
"
type
"
:
"
homeassistant/expose_entity
"
,
"
assistants
"
:
[
"
cloud.alexa
"
,
"
cloud.google_assistant
"
],
"
entity_ids
"
:
[
entry1
.
entity_id
,
entry2
.
entity_id
],
"
entity_ids
"
:
[
entry1
.
entity_id
],
"
should_expose
"
:
True
,
}
)
response
=
await
ws_client
.
receive_json
()
assert
response
[
"
success
"
]
await
ws_client
.
send_json_auto_id
(
{
"
type
"
:
"
homeassistant/expose_entity
"
,
"
assistants
"
:
[
"
cloud.alexa
"
,
"
cloud.google_assistant
"
],
"
entity_ids
"
:
[
entry2
.
entity_id
],
"
should_expose
"
:
False
,
}
)
response
=
await
ws_client
.
receive_json
()
assert
response
[
"
success
"
]
# Set options for entities not in the entity registry
await
ws_client
.
send_json_auto_id
(
{
"
type
"
:
"
homeassistant/expose_entity
"
,
"
assistants
"
:
[
"
cloud.alexa
"
,
"
cloud.google_assistant
"
],
"
entity_ids
"
:
[
"
test.test
"
,
"
test.test2
"
,
],
"
entity_ids
"
:
[
"
test.test
"
],
"
should_expose
"
:
True
,
}
)
response
=
await
ws_client
.
receive_json
()
assert
response
[
"
success
"
]
await
ws_client
.
send_json_auto_id
(
{
"
type
"
:
"
homeassistant/expose_entity
"
,
"
assistants
"
:
[
"
cloud.alexa
"
,
"
cloud.google_assistant
"
],
"
entity_ids
"
:
[
"
test.test2
"
],
"
should_expose
"
:
False
,
}
)
...
...
@@ -531,10 +551,8 @@ async def test_list_exposed_entities(
assert
response
[
"
success
"
]
assert
response
[
"
result
"
]
==
{
"
exposed_entities
"
:
{
"
test.test
"
:
{
"
cloud.alexa
"
:
False
,
"
cloud.google_assistant
"
:
False
},
"
test.test2
"
:
{
"
cloud.alexa
"
:
False
,
"
cloud.google_assistant
"
:
False
},
"
test.test
"
:
{
"
cloud.alexa
"
:
True
,
"
cloud.google_assistant
"
:
True
},
"
test.test_unique1
"
:
{
"
cloud.alexa
"
:
True
,
"
cloud.google_assistant
"
:
True
},
"
test.test_unique2
"
:
{
"
cloud.alexa
"
:
True
,
"
cloud.google_assistant
"
:
True
},
},
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment