Add get_states faster (#23315)
This commit is contained in:
parent
00d26b3049
commit
5b0ee473b6
4 changed files with 56 additions and 5 deletions
|
@ -142,11 +142,14 @@ def handle_get_states(hass, connection, msg):
|
|||
|
||||
Async friendly.
|
||||
"""
|
||||
entity_perm = connection.user.permissions.check_entity
|
||||
states = [
|
||||
state for state in hass.states.async_all()
|
||||
if entity_perm(state.entity_id, 'read')
|
||||
]
|
||||
if connection.user.permissions.access_all_entities('read'):
|
||||
states = hass.states.async_all()
|
||||
else:
|
||||
entity_perm = connection.user.permissions.check_entity
|
||||
states = [
|
||||
state for state in hass.states.async_all()
|
||||
if entity_perm(state.entity_id, 'read')
|
||||
]
|
||||
|
||||
connection.send_message(messages.result_message(
|
||||
msg['id'], states))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue