Skip to content

Commit

Permalink
Protect exit jingles counter from underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-stepanov committed May 3, 2024
1 parent c155216 commit b2f79e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion advent/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="1.6.0"
__version__="1.6.1b1"
5 changes: 3 additions & 2 deletions advent/advent.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def startAction(self):
return self.in_action

def stopAction(self):
self.exit_jingles -= 1
if self.exit_jingles > 0:
self.exit_jingles -= 1
if self.exit_jingles == 0:
self.in_action = not(self.tvc.restoreVolume() if self.action == 'lower_volume' else self.tvc.toggleMute())
return 2 if self.in_action else 0
Expand Down Expand Up @@ -310,7 +311,7 @@ def run(self):
if ret == 0:
LOGGER.info('TV volume restored' if self.tv.getAction() == 'lower_volume' else 'TV unmuted')
elif ret == 1:
LOGGER.info('Muti-jingle ignored; remaining in action')
LOGGER.info('Multi-jingle ignored; remaining in action')
else:
LOGGER.warning('Warning: TV action failed')
else:
Expand Down

0 comments on commit b2f79e3

Please sign in to comment.