Skip to content

Commit

Permalink
Update to version 0.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ol-iver committed Dec 20, 2020
1 parent 445303f commit 0281fb3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 52 deletions.
2 changes: 1 addition & 1 deletion HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DATA
__title__ = 'denonavr'

VERSION
0.9.9.dev1
0.9.9

====================================================================================

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# denonavr
[![Version](https://img.shields.io/badge/version-v0.9.9.dev1-orange.svg)](https://github.com/scarface-4711/denonavr)
[![Version](https://img.shields.io/badge/version-v0.9.9-orange.svg)](https://github.com/scarface-4711/denonavr)
[![Build Status](https://travis-ci.com/scarface-4711/denonavr.svg?branch=master)](https://travis-ci.com/scarface-4711/denonavr)
[![PyPi](https://img.shields.io/pypi/v/denonavr.svg)](https://pypi.org/project/denonavr)
[![License](https://img.shields.io/github/license/scarface-4711/denonavr.svg)](LICENSE)

Automation Library for Denon AVR receivers - current version 0.9.9.dev1
Automation Library for Denon AVR receivers - current version 0.9.9

## Installation

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ denonavr
.. |Build Status| .. image:: https://travis-ci.com/scarface-4711/denonavr.svg?branch=master
:target: https://travis-ci.com/scarface-4711/denonavr

Automation Library for Denon AVR receivers - current version 0.9.9.dev1
Automation Library for Denon AVR receivers - current version 0.9.9

Installation
------------
Expand Down
2 changes: 1 addition & 1 deletion denonavr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
logging.getLogger(__name__).addHandler(logging.NullHandler())

__title__ = "denonavr"
__version__ = "0.9.9.dev1"
__version__ = "0.9.9"


def discover():
Expand Down
30 changes: 12 additions & 18 deletions denonavr/audyssey.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
_LOGGER = logging.getLogger("Audyssey")

MULTI_EQ_MAP = {"0": "Off", "1": "Flat", "2": "L/R Bypass", "3": "Reference"}
MULTI_EQ_MAP_LABELS = dict((value, key) for key, value in MULTI_EQ_MAP.items())
MULTI_EQ_MAP_LABELS = {(value, key) for key, value in MULTI_EQ_MAP.items()}

REF_LVL_OFFSET_MAP = {"0": "0dB", "1": "+5dB", "2": "+10dB", "3": "+15dB"}
REF_LVL_OFFSET_MAP_LABELS = dict(
(value, key) for key, value in REF_LVL_OFFSET_MAP.items()
)
REF_LVL_OFFSET_MAP_LABELS = {
(value, key) for key, value in REF_LVL_OFFSET_MAP.items()}

DYNAMIC_VOLUME_MAP = {"0": "Off", "1": "Light", "2": "Medium", "3": "Heavy"}
DYNAMIC_VOLUME_MAP_LABELS = dict(
(value, key) for key, value in DYNAMIC_VOLUME_MAP.items()
)
DYNAMIC_VOLUME_MAP_LABELS = {
(value, key) for key, value in DYNAMIC_VOLUME_MAP.items()}

COMMAND_ENDPOINT = "/goform/AppCommand0300.xml"

Expand Down Expand Up @@ -57,7 +55,7 @@ def send_command(self, xml_tree):
xml_tree.write(body, encoding="utf-8", xml_declaration=True)
try:
result = self.receiver.send_post_command(
command=COMMAND_ENDPOINT, body=body.getvalue())
COMMAND_ENDPOINT, body.getvalue())
except ConnectTimeout:
return
except RequestException:
Expand Down Expand Up @@ -93,7 +91,7 @@ def update(self):
ET.SubElement(param_list, "param", name=param)
tree = ET.ElementTree(root)

response = self.send_command(xml_tree=tree)
response = self.send_command(tree)
if response is None:
return False

Expand Down Expand Up @@ -147,35 +145,31 @@ def _set_audyssey(self, parameter, value):

def dynamiceq_off(self):
"""Turn DynamicEQ off."""
if self._set_audyssey(parameter="dynamiceq", value=0) is True:
if self._set_audyssey("dynamiceq", 0) is True:
self.dynamiceq = False

def dynamiceq_on(self):
"""Turn DynamicEQ on."""
if self._set_audyssey(parameter="dynamiceq", value=1) is True:
if self._set_audyssey("dynamiceq", 1) is True:
self.dynamiceq = True

def set_multieq(self, setting):
"""Set MultiEQ mode."""
if self._set_audyssey(
parameter="multeq", value=MULTI_EQ_MAP_LABELS.get(setting)
) is True:
"multeq", MULTI_EQ_MAP_LABELS.get(setting)) is True:
self.multeq = setting

def set_reflevoffset(self, setting):
"""Set Reference Level Offset."""
# Reference level offset can only be used with DynamicEQ
if self.dynamiceq is True:
if self._set_audyssey(
parameter="reflevoffset",
value=REF_LVL_OFFSET_MAP_LABELS.get(setting)
"reflevoffset", REF_LVL_OFFSET_MAP_LABELS.get(setting)
) is True:
self.reflevoffset = setting

def set_dynamicvol(self, setting):
"""Set Dynamic Volume."""
if self._set_audyssey(
parameter="dynamicvol",
value=DYNAMIC_VOLUME_MAP_LABELS.get(setting)
) is True:
"dynamicvol", DYNAMIC_VOLUME_MAP_LABELS.get(setting)) is True:
self.dynamicvol = setting
40 changes: 12 additions & 28 deletions denonavr/denonavr.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def get_status_xml(self, command, suppress_errors=False):
raise ValueError from err
elif res.status_code == 403:
self._handle_403_error(endpoint)
raise ValueError
else:
if not suppress_errors:
_LOGGER.error(
Expand All @@ -443,6 +444,7 @@ def send_get_command(self, command):
return True
elif res.status_code == 403:
self._handle_403_error(endpoint)
return False
else:
_LOGGER.error(
"Host %s returned HTTP status code %s to GET command at "
Expand Down Expand Up @@ -2069,9 +2071,7 @@ def _set_tone_control_command(self, parameter_type, value):
tree.write(body, encoding="utf-8", xml_declaration=True)

try:
self.send_post_command(
command=self._urls.appcommand, body=body.getvalue()
)
self.send_post_command(self._urls.appcommand, body.getvalue())
except requests.exceptions.RequestException:
_LOGGER.error("No connection to %s end point on host %s",
self._urls.appcommand, self._host)
Expand All @@ -2088,7 +2088,7 @@ def enable_tone_control(self):

if self._tone_control_adjust is True:
return True
elif self._set_tone_control_command(parameter_type='adjust', value=1):
elif self._set_tone_control_command('adjust', 1):
self._tone_control_adjust = True
return True
return False
Expand All @@ -2100,42 +2100,26 @@ def disable_tone_control(self):

if self._tone_control_adjust is False:
return True
elif self._set_tone_control_command(parameter_type='adjust', value=0):
elif self._set_tone_control_command('adjust', 0):
self._tone_control_adjust = False
return True
return False

def _set_tone_control(self, parameter_type, value):
"""Set tone control parameter."""
if value < 0 or value > 12:
raise ValueError(
"Invalid value for {parameter_type}".format(
parameter_type=parameter_type
)
)
raise ValueError("Invalid value for {}".format(parameter_type))

if not self.enable_tone_control():
return False

if self._set_tone_control_command(
parameter_type='{parameter_type}value'.format(
parameter_type=parameter_type
), value=value
):
setattr(
self,
'_{parameter_type}'.format(parameter_type=parameter_type),
value
)
'{}value'.format(parameter_type), value):
setattr(self, '_{}'.format(parameter_type), value)
setattr(
self,
'_{parameter_type}_level'.format(
parameter_type=parameter_type
),
self, '_{}_level'.format(parameter_type),
'{value:{sign}}dB'.format(
value=value-6, sign='' if value-6 == 0 else '+'
)
)
value=value-6, sign='' if value-6 == 0 else '+'))
return True
return False

Expand All @@ -2148,7 +2132,7 @@ def set_bass(self, bass):
Note:
Doesn't work, if Dynamic Equalizer is active.
"""
return self._set_tone_control(parameter_type='bass', value=bass)
return self._set_tone_control('bass', bass)

def set_treble(self, treble):
"""
Expand All @@ -2159,7 +2143,7 @@ def set_treble(self, treble):
Note:
Doesn't work, if Dynamic Equalizer is active.
"""
return self._set_tone_control(parameter_type='treble', value=treble)
return self._set_tone_control('treble', treble)


class DenonAVRZones(DenonAVR):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import find_packages, setup

setup(name='denonavr',
version='0.9.9.dev1',
version='0.9.9',
description='Automation Library for Denon AVR receivers',
long_description='Automation Library for Denon AVR receivers',
url='https://github.com/scarface-4711/denonavr',
Expand Down

0 comments on commit 0281fb3

Please sign in to comment.