-
-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Update the Russound RNET component to use enhanced Russound.py #9739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
1588d61
6f55614
83b1bc3
9e4b003
64519f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| CONF_HOST, CONF_PORT, STATE_OFF, STATE_ON, CONF_NAME) | ||
| import homeassistant.helpers.config_validation as cv | ||
|
|
||
| REQUIREMENTS = ['russound==0.1.7'] | ||
| REQUIREMENTS = ['russound==0.1.9'] | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -85,24 +85,36 @@ def __init__(self, hass, russ, sources, zone_id, extra): | |
|
|
||
| def update(self): | ||
| """Retrieve latest state.""" | ||
| if self._russ.get_power('1', self._zone_id) == 0: | ||
| self._state = STATE_OFF | ||
| # Updated this function to make a single call to get_zone_info, so that | ||
| # with a single call we can get On/Off, Volume and Source, reducing the | ||
| # amount of traffic and speeding up the update process. | ||
| ret = self._russ.get_zone_info('1', self._zone_id, 4) | ||
| _LOGGER.debug("ret= %s", ret) | ||
| if ret is not None: | ||
| _LOGGER.debug("Updating status for zone %s", self._zone_id) | ||
| #if self._russ.get_power('1', self._zone_id) == 0: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. block comment should start with '# ' |
||
| if ret[0] == 0: | ||
| self._state = STATE_OFF | ||
| else: | ||
| self._state = STATE_ON | ||
|
|
||
| self._volume = ret[2] * 2 / 100.0 | ||
| #self._volume = self._russ.get_volume('1', self._zone_id) / 100.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. block comment should start with '# ' |
||
|
|
||
| # Returns 0 based index for source. | ||
| #index = self._russ.get_source('1', self._zone_id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. block comment should start with '# ' |
||
| index = ret[1] | ||
| # Possibility exists that user has defined list of all sources. | ||
| # If a source is set externally that is beyond the defined list then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (80 > 79 characters) |
||
| # an exception will be thrown. | ||
| # In this case return and unknown source (None) | ||
| try: | ||
| self._source = self._sources[index] | ||
| except IndexError: | ||
| self._source = None | ||
| else: | ||
| self._state = STATE_ON | ||
|
|
||
| self._volume = self._russ.get_volume('1', self._zone_id) / 100.0 | ||
|
|
||
| # Returns 0 based index for source. | ||
| index = self._russ.get_source('1', self._zone_id) | ||
| # Possibility exists that user has defined list of all sources. | ||
| # If a source is set externally that is beyond the defined list then | ||
| # an exception will be thrown. | ||
| # In this case return and unknown source (None) | ||
| try: | ||
| self._source = self._sources[index] | ||
| except IndexError: | ||
| self._source = None | ||
|
|
||
| _LOGGER.error("Could not update status for zone %s", self._zone_id) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blank line contains whitespace |
||
| @property | ||
| def name(self): | ||
| """Return the name of the zone.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preference:
Our preferred style is the pattern shown below. This saves us from having to indent the rest of the function. This will also line up the indentation of the comments below with the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @armills , thank you for your feedback. Could it be possible to do the merge like this just for this moment, so that I can concentrate on additional enhancements to the Russound RNET component? Right now this component cannot reconnect if there is a communications error (forcing you to a full Hass restart), and would like to make fixing this my first priority. I will have the update ready in a week from now (including this style change). Do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's no problem. Not a blocker to merge. Thanks for the contribution! 🎉