mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Restrict data from stream API
This commit is contained in:
parent
62f016e7d2
commit
4b6878f91c
@ -103,6 +103,10 @@ def _handle_get_api_stream(handler, path_match, data):
|
|||||||
write_lock = threading.Lock()
|
write_lock = threading.Lock()
|
||||||
block = threading.Event()
|
block = threading.Event()
|
||||||
|
|
||||||
|
restrict = data.get('restrict')
|
||||||
|
if restrict:
|
||||||
|
restrict = restrict.split(',')
|
||||||
|
|
||||||
def write_message(payload):
|
def write_message(payload):
|
||||||
""" Writes a message to the output. """
|
""" Writes a message to the output. """
|
||||||
with write_lock:
|
with write_lock:
|
||||||
@ -118,7 +122,8 @@ def _handle_get_api_stream(handler, path_match, data):
|
|||||||
""" Forwards events to the open request. """
|
""" Forwards events to the open request. """
|
||||||
nonlocal gracefully_closed
|
nonlocal gracefully_closed
|
||||||
|
|
||||||
if block.is_set() or event.event_type == EVENT_TIME_CHANGED:
|
if block.is_set() or event.event_type == EVENT_TIME_CHANGED or \
|
||||||
|
restrict and event.event_type not in restrict:
|
||||||
return
|
return
|
||||||
elif event.event_type == EVENT_HOMEASSISTANT_STOP:
|
elif event.event_type == EVENT_HOMEASSISTANT_STOP:
|
||||||
gracefully_closed = True
|
gracefully_closed = True
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 6989009b2d59e39fd39b3025ff5899877f618bd3
|
Subproject commit 1ba7060719bc7662e8c3728f394115ccb3c54c21
|
Loading…
x
Reference in New Issue
Block a user