Skip to content

Commit

Permalink
Use base peripheral online status
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrisan committed Jan 17, 2020
1 parent 4989300 commit 6bc38e6
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions qtoggleserver/paradox/ports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,20 @@ async def disconnect(self) -> None:

self._panel_task = None

def is_connected(self) -> bool:
if not self._paradox:
return False

if not self._paradox.panel:
return False

if not self._panel_task:
return False

return bool(self._paradox.connection.connected)

async def _check_connection_loop(self) -> None:
connect_succeeded = False

try:
while True:
connected = (self._paradox and self._paradox.connection and
self._paradox.connection.connected and connect_succeeded)
connected = (
self._paradox and
self._paradox.connection and
self._paradox.connection.connected and
connect_succeeded
)

self.set_online(connected)

if self.is_enabled() and not connected:
try:
await self.connect()
Expand Down Expand Up @@ -245,9 +240,6 @@ class PAIPort(PeripheralPort, conf_utils.ConfigurableMixin, metaclass=abc.ABCMet
def __init__(self, address: str, peripheral_name: Optional[str] = None) -> None:
super().__init__(address, peripheral_name)

async def attr_is_online(self) -> bool:
return self.get_peripheral().is_connected()

def on_property_change(
self,
_type: str,
Expand Down

0 comments on commit 6bc38e6

Please sign in to comment.