Skip to content

Commit

Permalink
Fix mypy findings (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shutgun authored Oct 31, 2024
1 parent 42e001f commit 1614de0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion devolo_home_control_api/backend/mprm_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def set_binary_switch(self, uid: str, state: bool) -> bool:
:param state: True if switching on, False if switching off
:return: True if successfully switched, false otherwise
"""
data = {"method": "FIM/invokeOperation", "params": [uid, "turnOn" if state else "turnOff", []]}
data: dict[str, str | list] = {"method": "FIM/invokeOperation", "params": [uid, "turnOn" if state else "turnOff", []]}
response = self._post(data)
return self._evaluate_response(uid=uid, value=state, response=response)

Expand Down
6 changes: 5 additions & 1 deletion devolo_home_control_api/backend/mprm_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MprmWebsocket(MprmRest, ABC):
def __init__(self) -> None:
"""Initialize websocket communication."""
super().__init__()
self._ws: websocket.WebSocketApp = None
self._ws: websocket.WebSocketApp | None = None
self._connected = False # This attribute saves, if the websocket is fully established
self._reachable = True # This attribute saves, if the a new session can be established
self._event_sequence = 0
Expand Down Expand Up @@ -110,6 +110,10 @@ def websocket_connect(self) -> None:

def websocket_disconnect(self, event: str = "") -> None:
"""Close the websocket connection."""
if not self._ws:
self._logger.info("Not connected to the web socket.")
return

self._logger.info("Closing web socket connection.")
if event:
self._logger.info("Reason: %s", event)
Expand Down

0 comments on commit 1614de0

Please sign in to comment.