Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mypy findings #184

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading