File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,11 @@ async def test_and_get(self) -> dict:
231231
232232 def ws_start (self ) -> None :
233233 """Start the websocket listener."""
234- if self ._ws_listening :
235- raise AlreadyListening
234+ if self .websocket :
235+ if self ._ws_listening and self .websocket .state == "connected" :
236+ raise AlreadyListening
237+ if self ._ws_listening and self .websocket .state != "connected" :
238+ self ._ws_listening = False
236239 self ._start_listening ()
237240
238241 def _start_listening (self ):
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def __init__(
3838 self ._user = user
3939 self ._password = password
4040 self .callback = callback
41- self ._state = None
41+ self ._state = STATE_DISCONNECTED
4242 self .failed_attempts = 0
4343 self ._error_reason = None
4444 self ._client = None
Original file line number Diff line number Diff line change 1919 UnsupportedFeature ,
2020)
2121from tests .common import load_fixture
22- from openevsehttp .websocket import SIGNAL_CONNECTION_STATE , STATE_CONNECTED
22+ from openevsehttp .websocket import (
23+ SIGNAL_CONNECTION_STATE ,
24+ STATE_CONNECTED ,
25+ STATE_DISCONNECTED ,
26+ )
2327
2428pytestmark = pytest .mark .asyncio
2529
@@ -53,7 +57,7 @@ async def test_ws_state(test_charger):
5357 """Test v4 Status reply."""
5458 await test_charger .update ()
5559 value = test_charger .ws_state
56- assert value == None
60+ assert value == STATE_DISCONNECTED
5761 await test_charger .ws_disconnect ()
5862
5963
You can’t perform that action at this time.
0 commit comments