Don't inline methods

This commit is contained in:
Aaron Bach
2020-02-03 18:01:55 -07:00
parent 27cd418e16
commit 5ccf2aee07

View File

@@ -372,10 +372,7 @@ class SimpliSafeWebsocket:
await self.async_websocket_disconnect()
await self._async_attempt_websocket_connect()
async def async_websocket_connect(self):
"""Register handlers and connect to the websocket."""
def on_connect():
def _on_connect(self):
"""Define a handler to fire when the websocket is connected."""
_LOGGER.info("Connected to websocket")
_LOGGER.debug("Websocket watchdog starting")
@@ -385,11 +382,11 @@ class SimpliSafeWebsocket:
self._hass, DEFAULT_WATCHDOG_SECONDS, self._async_websocket_reconnect
)
def on_disconnect():
def _on_disconnect(self):
"""Define a handler to fire when the websocket is disconnected."""
_LOGGER.info("Disconnected from websocket")
def on_event(data):
def _on_event(self, data):
"""Define a handler to fire when a new SimpliSafe event arrives."""
event = SimpliSafeWebsocketEvent(data)
_LOGGER.debug("New websocket event: %s", event)
@@ -403,9 +400,11 @@ class SimpliSafeWebsocket:
)
self._websocket_reconnect_delay = DEFAULT_SOCKET_MIN_RETRY
self._websocket.on_connect(on_connect)
self._websocket.on_disconnect(on_disconnect)
self._websocket.on_event(on_event)
async def async_websocket_connect(self):
"""Register handlers and connect to the websocket."""
self._websocket.on_connect(self._on_connect)
self._websocket.on_disconnect(self._on_disconnect)
self._websocket.on_event(self._on_event)
await self._async_attempt_websocket_connect()