Skip to content
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

Read power state from AVR instead of relying on internal state. #14794

Closed
wants to merge 1 commit into from

Conversation

klada
Copy link
Contributor

@klada klada commented Jun 3, 2018

Description:

Right now Home Assistant does not read the power state directly from of a Denon AVR. The power state of the device only gets updated when it is turned on and off through hass. Since the device can also be controlled directly (e.g. through the remote) it would be better to read the power state directly from the device if possible.

Related issue (if applicable):

fixes #14792

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

@homeassistant
Copy link
Contributor

Hi @klada,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@starkillerOG
Copy link
Contributor

@klada Actually the power state is red from the device itself.
it is updated in line 158 of denonavr.py:

def update(self):
   ...
   self._state = self._receiver.state
   ...

In the denonavr library of scarface-4711 , this update takes place in lines 435 to 461:

        # Set state and media image URL based on current source
        # and power status
        if (self._power == POWER_ON) and (
                self._input_func in self._playing_func_list):
            if self._update_media_data():
                pass
            else:
                _LOGGER.error(
                    "Update of media data for source %s in %s failed",
                    self._input_func, self._zone)
        elif self._power == POWER_ON:
            self._state = STATE_ON
            self._title = None
            self._artist = None
            self._album = None
            self._band = None
            self._frequency = None
            self._station = None
            self._image_url = None
        else:
            self._state = STATE_OFF
            self._title = None
            self._artist = None
            self._album = None
            self._band = None
            self._frequency = None
self._station = None

where the self._update_media_data() provides a status "playing" or "paused" when the AVR is powered on and palying a source that can be paused such as direct mp3 files playing or airplay streaming or someting like that.

@home-assistant home-assistant deleted a comment Jun 4, 2018
@klada
Copy link
Contributor Author

klada commented Jun 4, 2018

@MartinHjelmare I have a Denon AVR-X6300, which does not call _update_avr. It uses _update_avr_2016 instead, which leaves the state empty. So this patch is probably a workaround for newer receivers. I'll try to fix this upstream.

@balloob
Copy link
Member

balloob commented Jun 7, 2018

Will close this PR then, new PR welcome when upstream fixed.

@balloob balloob closed this Jun 7, 2018
@ghost ghost removed the small-pr PRs with less than 30 lines. label Jun 7, 2018
@klada klada mentioned this pull request Jun 10, 2018
klada added a commit to klada/home-assistant that referenced this pull request Jun 10, 2018
fabaff pushed a commit that referenced this pull request Jun 10, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

denonavr: Power state is not read from AVR
4 participants