ol-iver / denonavr

Automation Library for Denon AVR receivers.
MIT License
176 stars 67 forks source link

Wrong source reported when selecting source while powered off #75

Closed jjlawren closed 4 years ago

jjlawren commented 5 years ago

When I select a source when the receiver (AVR-x3400h, a 2017 model) is powered off, the receiver turns on directly to the requested source. However, the reported source is incorrect in denonavr, seeming to show to the previously selected state:

>>> import denonavr
>>> d = denonavr.DenonAVR("x3400h")
>>> d.update()
True
>>> d.state
'off'
>>> d.set_input_func("DVD")
True
>>> d.update()
True
>>> d.state
'on'
>>> d.input_func
'Shield'
>>>

The receiver itself is using the 'DVD' input at this point. The incorrect source is also reflected in Home Assistant.

DanskerUS commented 5 years ago

I have seen this as well. Same thing happens with sound mode. Note: power cycling receiver clears ALL_STEREO_MODE.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jjlawren commented 4 years ago

For anyone using HA that runs into this issue, I've since worked around the issue by adding some fallback logic:

receiver_linein_input:
  sequence:
    - service: media_player.select_source
      entity_id: media_player.x3400h
      data:
        source: 'Line-In'
    - wait_template: "{{ is_state('media_player.x3400h', 'on') }}"
      timeout: '00:00:15'
    - wait_template: "{{ not is_state_attr('media_player.x3400h', 'source', 'Line-In') }}"
      timeout: '00:00:10'
      continue_on_timeout: 'false'
    # Done unless source is incorrect
    - service: media_player.select_source
      entity_id: media_player.x3400h
      data:
        source: 'DVD'
    - service: media_player.select_source
      entity_id: media_player.x3400h
      data:
        source: 'Line-In'