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 is_alive #142

Merged
merged 1 commit into from
Nov 28, 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
3 changes: 2 additions & 1 deletion samsungtvws/async_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from websockets.asyncio.client import ClientConnection, connect
from websockets.exceptions import ConnectionClosed
from websockets.protocol import State

from . import connection, exceptions, helper
from .command import SamsungTVCommand, SamsungTVSleepCommand
Expand Down Expand Up @@ -174,4 +175,4 @@ async def _send_command(
await asyncio.sleep(delay)

def is_alive(self) -> bool:
return self.connection is not None and not self.connection.closed
return self.connection is not None and self.connection.state is not State.CLOSED
6 changes: 5 additions & 1 deletion samsungtvws/encrypted/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import aiohttp
from websockets.asyncio.client import ClientConnection, connect
from websockets.exceptions import ConnectionClosed
from websockets.protocol import State

from ..exceptions import ConnectionFailure
from .command import SamsungTVEncryptedCommand
Expand Down Expand Up @@ -183,4 +184,7 @@ async def close(self) -> None:
LOGGER.debug("Connection closed")

def is_alive(self) -> bool:
return self._connection is not None and not self._connection.closed
return (
self._connection is not None
and not self._connection.state is not State.CLOSED
)