Skip to content

Commit

Permalink
Merge pull request #7 from robhuls/robhuls-patch-1
Browse files Browse the repository at this point in the history
Fix NAD7050 hangs with identical settings
  • Loading branch information
joopert authored Jan 6, 2018
2 parents c398493 + 25d640d commit 33253fc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions nad_receiver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,16 @@ def status(self):

def power_off(self):
"""Power the device off."""
self._send(self.CMD_POWERSAVE + self.CMD_OFF)
status = self.status()
if status['power']: # Setting power off when it is already off can cause hangs
self._send(self.CMD_POWERSAVE + self.CMD_OFF)

def power_on(self):
"""Power the device on."""
self._send(self.CMD_ON, read_reply=True)
status = self.status()
if not status['power']:
self._send(self.CMD_ON, read_reply=True)
sleep(0.5) # Give NAD7050 some time before next command

def set_volume(self, volume):
"""Set volume level of the device. Accepts integer values 0-200."""
Expand All @@ -241,11 +246,14 @@ def mute(self):
def unmute(self):
"""Unmute the device."""
self._send(self.CMD_UNMUTE)

def select_source(self, source):
"""Select a source from the list of sources."""
if source in self.SOURCES:
self._send(self.CMD_SOURCE + self.SOURCES[source], read_reply=True)
status = self.status()
if status['power']: # Changing source when off may hang NAD7050
if status['source'] != source: # Setting the source to the current source will hang the NAD7050
if source in self.SOURCES:
self._send(self.CMD_SOURCE + self.SOURCES[source], read_reply=True)

def available_sources(self):
"""Return a list of available sources."""
Expand Down

0 comments on commit 33253fc

Please sign in to comment.