Fixing the api_streams sensor (#22200)
* Fire events with websocket messages. * Added tests to validate * Fixed api_streams sensor to use new sensor * Delete from coverageac as now works. * Removed websocket request event. * Use dispatcher instead of events. * Moved sensor to under websocket_api * Changes as per code review * Fixed tests. * Modified test * Patch
This commit is contained in:
parent
2b6e197deb
commit
1ddc65a0ce
8 changed files with 142 additions and 168 deletions
|
@ -13,7 +13,9 @@ from homeassistant.core import callback
|
|||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
|
||||
from .const import MAX_PENDING_MSG, CANCELLATION_ERRORS, URL, ERR_UNKNOWN_ERROR
|
||||
from .const import (
|
||||
MAX_PENDING_MSG, CANCELLATION_ERRORS, URL, ERR_UNKNOWN_ERROR,
|
||||
SIGNAL_WEBSOCKET_CONNECTED, SIGNAL_WEBSOCKET_DISCONNECTED)
|
||||
from .auth import AuthPhase, auth_required_message
|
||||
from .error import Disconnect
|
||||
from .messages import error_message
|
||||
|
@ -142,6 +144,8 @@ class WebSocketHandler:
|
|||
|
||||
self._logger.debug("Received %s", msg)
|
||||
connection = await auth.async_handle(msg)
|
||||
self.hass.helpers.dispatcher.async_dispatcher_send(
|
||||
SIGNAL_WEBSOCKET_CONNECTED)
|
||||
|
||||
# Command phase
|
||||
while not wsock.closed:
|
||||
|
@ -192,4 +196,7 @@ class WebSocketHandler:
|
|||
else:
|
||||
self._logger.warning("Disconnected: %s", disconnect_warn)
|
||||
|
||||
self.hass.helpers.dispatcher.async_dispatcher_send(
|
||||
SIGNAL_WEBSOCKET_DISCONNECTED)
|
||||
|
||||
return wsock
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue