home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.32k stars 30.62k forks source link

Onkyo mediaplayer intergration generates errors #47918

Closed Proxx closed 3 years ago

Proxx commented 3 years ago

The problem

the logger generates errors:

UnboundLocalError: local variable 'video_information_raw' referenced before assignment

What is version of Home Assistant Core has the issue?

core-2021.3.4

What type of installation are you running?

Home Assistant Container

Integration causing the issue

onkyo

Link to integration documentation on our website

https://www.home-assistant.io/integrations/onkyo/

Anything in the logs that might be useful for us?

Logger: homeassistant.helpers.entity
Source: components/onkyo/media_player.py:346
First occurred: 22:28:25 (15 occurrences)
Last logged: 22:30:45

Update for media_player.tx_nr525_00xxb0xxx324 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 277, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 473, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py", line 346, in update
    self._parse_video_information(video_information_raw)
UnboundLocalError: local variable 'video_information_raw' referenced before assignment

commit #46228 has fixed #46130 but introduced this error

danieljkemp commented 3 years ago

FYI: It looks like the async update will fix this issue: https://github.com/winterscar/core/pull/6 That patch is part of a larger PR, so my guess is that it might reach 2012.4.1 (hopefully! I'm not up to date on the lifecycle...)

quadhammer commented 3 years ago

Just to confirm: 2021.4 hasn't fixed it yet, so hopefully 2021.4.1 will do the trick.

Everything works pretty well, except for the source being updated.

eg. I can change my source to video1, but if I query it in node red, it might report something like:

source: "tape-1_tv/tape"

The same thing happens with the card in home assistant.

Edit: still no luck with 2021.4.3

shinyshoes16 commented 3 years ago

Are you saying this is the case after the fix, or right now @quadhammer ?

Everything works pretty well, except for the source being updated.

Mine gives that error constantly right now and nothing updates in Home Assistant. Mine is an Integra DTR 50.2.

quadhammer commented 3 years ago

I'm still not getting sources updating even with the latest build of Home Assistant.

Logger: homeassistant.components.media_player
Source: /usr/local/lib/python3.8/asyncio/events.py:81
Integration: Media player (documentation, issues)
First occurred: 1:59:46 PM (1 occurrences)
Last logged: 1:59:46 PM

Setup of media_player platform onkyo is taking over 10 seconds.
Logger: homeassistant.helpers.entity
Source: components/onkyo/media_player.py:346
First occurred: 2:00:01 PM (17 occurrences)
Last logged: 2:01:41 PM

Update for media_player.prepro fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 292, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 490, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py", line 346, in update
    self._parse_audio_information(audio_information_raw)
UnboundLocalError: local variable 'audio_information_raw' referenced before assignment

System Health

version core-2021.4.4
installation_type Home Assistant OS
dev false
hassio true
docker true
virtualenv false
python_version 3.8.7
os_name Linux
os_version 5.4.109
arch x86_64
timezone Australia/Brisbane
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4648 Installed Version | 1.11.3 Stage | running Available Repositories | 777 Installed Repositories | 26
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 5.13 -- | -- update_channel | stable supervisor_version | supervisor-2021.03.9 docker_version | 19.03.15 disk_total | 30.8 GB disk_used | 9.4 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Samba share (9.3.1), Mosquitto broker (5.1.1), Duck DNS (1.12.5), Node-RED (8.2.1), Dropbox Sync (1.3.0), ESPHome (1.16.2), Zigbee2mqtt (1.18.1-1), WireGuard (0.5.1), AdGuard Home (4.0.0), File editor (5.2.0), Network UPS Tools (0.6.2), Let's Encrypt (4.11.0), Z-Wave JS to MQTT (0.11.0)
Lovelace dashboards | 2 -- | -- resources | 19 views | 17 mode | storage
ontaptom commented 3 years ago

Hi,

I'm still having this issue (both: audio_information_raw/video_information_raw) within core-2021.4.6

AS a workaround, is there a way to 'disable' even temporary, getting the source updating? Since that produces couple of thousands errors every day in my logs.. Example error on my side:


Logger: homeassistant.helpers.entity
Source: components/onkyo/media_player.py:346
First occurred: April 29, 2021, 1:35:47 PM (2627 occurrences)
Last logged: 1:06:36 AM
Update for media_player.pioneer fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 292, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 490, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py", line 346, in update
    self._parse_audio_information(audio_information_raw)
UnboundLocalError: local variable 'audio_information_raw' referenced before assignment

It seems the workaround would be to work on

  File "/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py", line 346, in update
    self._parse_audio_information(audio_information_raw)

And corresponding line for video_information_raw. However I have no experience with manually editing those files, not sure if that won't break integrity in my HA, or prevent me from doing the updates?

quadhammer commented 3 years ago

I'm still having this issue (both: audio_information_raw/video_information_raw) within core-2021.4.6

Same here, core-2021.4.6 still hasn't fixed it. I've just totally disabled the plug-in from the configuration.yaml until someone finds a way to make it work. A fix was mentioned on 17 March by @danieljkemp , so it's taking a long time to make it into the release.

mahk8 commented 3 years ago

Until the author fixes this issue, you can get rid of those pesky error message by add the following to "/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py" so to initialise the audio_information_raw and video_information_raw before it uses it.

Place it before line 314 in the file and line up the indentation. Should look something like...


        current_source_raw = self.command("input-selector query")
        audio_information_raw = []
        video_information_raw = []
`
quadhammer commented 3 years ago

"/usr/src/homeassistant/homeassistant/components/onkyo/media_player.py"

Unfortunately I'm using a virtual machine, Oracle VM virtualbox, so I don't think I can get in there and change those files. They don't seem to be exposed by my Samba share.

ontaptom commented 3 years ago

Awesome! That seems to do the trick, thanks @mahk8! @quadhammer I did a bit different trick, and hopefully you can follow the same: Instead of modifying existing component, I copied the onkyo component to my config/custom_components/ directory. From: https://github.com/home-assistant/core/tree/dev/homeassistant/components/onkyo. And assigned values of empty list to audio_information_raw/video_information_raw values as suggested by @mahk8

After HA restart, it surely took the 'custom' component, the only disadvantage at this point is this warning: No 'version' key in the manifest file for custom integration 'onkyo'. As of Home Assistant 2021.6, this integration will no longer be loaded. Please report this to the maintainer of 'onkyo'

But I hope before 2021.6 is released, this workaround will not be needed. And if so.. I suppose adding simple 'version' key to manifest file should do the trick as well. Hope that helps.

quadhammer commented 3 years ago

https://github.com/home-assistant/core/tree/dev/homeassistant/components/onkyo

Just for others trying to do this, you have to go to the root directory to find the download file button, i.e. https://github.com/home-assistant/core

Then code, download.zip

then you can just extract it, and search for the Onkyo folder, and follow @ontaptom 's excellent instructions.

One other caveat, make sure when you copy and paste

        audio_information_raw = []
        video_information_raw = []

they are all spaces beforehand, and not tabs, or it won't work.

Thanks for everyone's help in here. It's good to have it working!

mahk8 commented 3 years ago

Any chance of the author or maintainer adding these two lines for the next release?

This is such an easy fix so that we don't have to re-edit the existing file or maintain a custom version of the code.

quadhammer commented 3 years ago

We need a version key too, just to use the hacked component one above.

mahk8 commented 3 years ago

If you've created your own custom version and you've copied the original source directory then just add the following line to the manifest.json file. Insert the "version" key after the "name" key and make sure everything lines up.

"version": "0.0.0",

This should get rid of the "version key" nag and allows the custom integration to load.

Check the following link for explanation: https://developers.home-assistant.io/docs/creating_integration_manifest/#version

csacre commented 3 years ago

I have the same issue. Registering for notifications.

ludeeus commented 3 years ago

I have the same issue. Registering for notifications.

No need to reply to do that, you can just use the "subscribe" button on the right side ->