Update the Russound RNET component to use enhanced Russound.py (#9739)
* Updated RussoundRNETDevice.update() to call and enhanced function that reduces network traffic Refer to issue #6 on the Russound project * Updated RussoundRNETDevice.update() to invoke an enhanced function to reduce network traffic PLease see issue #6 on the russound project * Updated REQUIREMENTS to use version 0.1.9 of the Russound component Please refer to issue #6 on the Russound rnet project * Corrected some minor style details to satisfy Houndbot * Update requirements_all.txtpull/9741/merge
parent
789929d445
commit
5df985a510
|
@ -15,7 +15,7 @@ from homeassistant.const import (
|
||||||
CONF_HOST, CONF_PORT, STATE_OFF, STATE_ON, CONF_NAME)
|
CONF_HOST, CONF_PORT, STATE_OFF, STATE_ON, CONF_NAME)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['russound==0.1.7']
|
REQUIREMENTS = ['russound==0.1.9']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -85,23 +85,30 @@ class RussoundRNETDevice(MediaPlayerDevice):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
if self._russ.get_power('1', self._zone_id) == 0:
|
# Updated this function to make a single call to get_zone_info, so that
|
||||||
self._state = STATE_OFF
|
# with a single call we can get On/Off, Volume and Source, reducing the
|
||||||
else:
|
# amount of traffic and speeding up the update process.
|
||||||
self._state = STATE_ON
|
ret = self._russ.get_zone_info('1', self._zone_id, 4)
|
||||||
|
_LOGGER.debug("ret= %s", ret)
|
||||||
self._volume = self._russ.get_volume('1', self._zone_id) / 100.0
|
if ret is not None:
|
||||||
|
_LOGGER.debug("Updating status for zone %s", self._zone_id)
|
||||||
|
if ret[0] == 0:
|
||||||
|
self._state = STATE_OFF
|
||||||
|
else:
|
||||||
|
self._state = STATE_ON
|
||||||
|
self._volume = ret[2] * 2 / 100.0
|
||||||
# Returns 0 based index for source.
|
# Returns 0 based index for source.
|
||||||
index = self._russ.get_source('1', self._zone_id)
|
index = ret[1]
|
||||||
# Possibility exists that user has defined list of all sources.
|
# Possibility exists that user has defined list of all sources.
|
||||||
# If a source is set externally that is beyond the defined list then
|
# If a source is set externally that is beyond the defined list then
|
||||||
# an exception will be thrown.
|
# an exception will be thrown.
|
||||||
# In this case return and unknown source (None)
|
# In this case return and unknown source (None)
|
||||||
try:
|
try:
|
||||||
self._source = self._sources[index]
|
self._source = self._sources[index]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
self._source = None
|
self._source = None
|
||||||
|
else:
|
||||||
|
_LOGGER.error("Could not update status for zone %s", self._zone_id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -912,7 +912,7 @@ roombapy==1.3.1
|
||||||
# rpi-rf==0.9.6
|
# rpi-rf==0.9.6
|
||||||
|
|
||||||
# homeassistant.components.media_player.russound_rnet
|
# homeassistant.components.media_player.russound_rnet
|
||||||
russound==0.1.7
|
russound==0.1.9
|
||||||
|
|
||||||
# homeassistant.components.media_player.russound_rio
|
# homeassistant.components.media_player.russound_rio
|
||||||
russound_rio==0.1.4
|
russound_rio==0.1.4
|
||||||
|
|
Loading…
Reference in New Issue