Skip to content

Commit

Permalink
Merge pull request #3 from iloveicedgreentea/fix_poweroff
Browse files Browse the repository at this point in the history
Fix poweroff for integration
  • Loading branch information
iloveicedgreentea authored Jun 19, 2023
2 parents 7e35eca + deca0a2 commit cfdb7c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions madvr/madvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ async def close_connection(self) -> None:
except AttributeError:
# means its already closed
pass

self.logger.debug("self.writer is closed")
self.reader = None
self.is_closed = True
self.logger.debug("clearing connection event")
self.connection_event.clear()

# Clear attr
self.logger.debug("clearing attr")
await self._clear_attr()
self.logger.debug("connection is closed")

async def open_connection(self) -> None:
"""Open a connection"""
Expand Down Expand Up @@ -399,10 +402,15 @@ async def power_off(self, standby=False) -> str:
# dont do anything if its off besides mark it off
# sending command will open connection
try:
# stop trying to reconnect
self.logger.debug("setting stop reconnect")
self.stop()
self.logger.debug("sending power off command")
res = await self.send_command(["Standby"] if standby else ["PowerOff"])
self.logger.debug("closing connection")
await self.close_connection()
self.is_on = False

self.logger.debug("finished power_off")
return res

except RetryExceededError:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="py_madvr",
version="1.4.1",
version="1.4.2",
author="iloveicedgreentea",
description="A package to control MadVR Envy over IP",
long_description=long_description,
Expand Down

0 comments on commit cfdb7c0

Please sign in to comment.