From 7b9e3b1df792b275a97f4ce20603df2abce18ed1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Jan 2020 00:08:47 +0100 Subject: [PATCH] Add status checks to play and pause methods and make both methods public / Push to version 0.7.11 --- HELP.md | 2 +- README.md | 2 +- README.rst | 2 +- denonavr/__init__.py | 2 +- denonavr/denonavr.py | 14 ++++++++++---- setup.py | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/HELP.md b/HELP.md index aa0a734..7014677 100644 --- a/HELP.md +++ b/HELP.md @@ -29,7 +29,7 @@ DATA __title__ = 'denonavr' VERSION - 0.7.10 + 0.7.11 ==================================================================================== diff --git a/README.md b/README.md index 9ebc428..55e2a9f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # denonavr [![Build Status](https://travis-ci.org/scarface-4711/denonavr.svg?branch=master)](https://travis-ci.org/scarface-4711/denonavr) -Automation Library for Denon AVR receivers - current version 0.7.10 +Automation Library for Denon AVR receivers - current version 0.7.11 ## Installation diff --git a/README.rst b/README.rst index 3ef6c77..471249d 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ denonavr |Build Status| -Automation Library for Denon AVR receivers - current version 0.7.10 +Automation Library for Denon AVR receivers - current version 0.7.11 Installation ------------ diff --git a/denonavr/__init__.py b/denonavr/__init__.py index 42718c7..eb4208e 100644 --- a/denonavr/__init__.py +++ b/denonavr/__init__.py @@ -17,7 +17,7 @@ logging.getLogger(__name__).addHandler(logging.NullHandler()) __title__ = "denonavr" -__version__ = "0.7.10" +__version__ = "0.7.11" def discover(): diff --git a/denonavr/denonavr.py b/denonavr/denonavr.py index f71318a..27229d3 100644 --- a/denonavr/denonavr.py +++ b/denonavr/denonavr.py @@ -1543,14 +1543,17 @@ def toggle_play_pause(self): # Use Play/Pause button only for sources which support NETAUDIO if (self._state == STATE_PLAYING and self._input_func in self._netaudio_func_list): - return self._pause() + return self.pause() elif self._input_func in self._netaudio_func_list: - return self._play() + return self.play() - def _play(self): + def play(self): """Send play command to receiver command via HTTP post.""" # Use pause command only for sources which support NETAUDIO if self._input_func in self._netaudio_func_list: + if self._state == STATE_PLAYING: + _LOGGER.info("Already playing, play command not sent") + return False body = {"cmd0": "PutNetAudioCommand/CurEnter", "cmd1": "aspMainZone_WebUpdateStatus/", "ZoneName": "MAIN ZONE"} @@ -1565,10 +1568,13 @@ def _play(self): _LOGGER.error("Connection error: play command not sent.") return False - def _pause(self): + def pause(self): """Send pause command to receiver command via HTTP post.""" # Use pause command only for sources which support NETAUDIO if self._input_func in self._netaudio_func_list: + if self._state == STATE_PAUSED: + _LOGGER.info("Already paused, pause command not sent") + return False body = {"cmd0": "PutNetAudioCommand/CurEnter", "cmd1": "aspMainZone_WebUpdateStatus/", "ZoneName": "MAIN ZONE"} diff --git a/setup.py b/setup.py index bbb16d7..15846fc 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import find_packages, setup setup(name='denonavr', - version='0.7.10', + version='0.7.11', description='Automation Library for Denon AVR receivers', long_description='Automation Library for Denon AVR receivers', url='https://github.com/scarface-4711/denonavr',