bertbert72 / HomeAssistant_VirginTivo

HomeAssistant component for control of Virgin Media Tivo boxes
GNU General Public License v3.0
29 stars 22 forks source link

virgintivo: Error on device update - KeyError: 702 #48

Closed richard-scott closed 4 years ago

richard-scott commented 4 years ago

Unable to use the add-on at all today ;-(

Log Details (ERROR)
Logger: homeassistant.components.media_player
Source: custom_components/virgintivo/media_player.py:498
Integration: Media player (documentation, issues)
First occurred: 9:30:04 AM (1 occurrences)
Last logged: 9:30:04 AM

virgintivo: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 324, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/virgintivo/media_player.py", line 576, in update
    override_idx = self.override_channel(new_channel_id)
  File "/config/custom_components/virgintivo/media_player.py", line 498, in override_channel
    if self._force_hd_on_tv and self._channels[channel_id][CONF_HDCHANNEL] and not self._sdoverride['enabled']:
KeyError: 702
mastermc0 commented 4 years ago

From a quick check it looks like this is due to the site being used to pull the channel list being updated to have tables in a new format. I’m gonna have a play around later and see if I can confirm this.

Will let you know how I get on.

bertbert72 commented 4 years ago

Yes, looks like the table structure was changed yesterday. I've only had a very quick look. I'll have a more thorough check tonight to see. That's the problem with web scraping - you're always at the mercy of changes to the site

mastermc0 commented 4 years ago

have

Was gonna have a crack myself but given I bumble my way through Python I’ll leave it to you.

bertbert72 commented 4 years ago

Feel free to have a go if you like. It's not like that section of the code is going to win any beauty prizes. The bit that parses the site is under get_channel_listings. It combines any override definitions within the configuration with whatever it gleans from the site. Hacks abound! The whole bit could do with a proper tidy,

Otherwise I'll have a go tonight. Can't actually access the site from my work laptop to see the details of what has changed. Just what I can view on my phone. I can see that there are now separate columns for HD and SD, but don't know what else was done.

bertbert72 commented 4 years ago

A very quick fix in the meantime would be to manually override the URL in the configuration to point to the page before the change. E.g.

  - platform: virgintivo
    tivos:
      1:
        name: Virgin V6
        host: TIVO-C68000020000000
    tvchannellists:
      enable: True
      url: https://www.tvchannellists.com/index.php?title=List_of_channels_on_Virgin_Media_(UK)&oldid=65570
bertbert72 commented 4 years ago

Hopefully that is now working in the latest release. Limited testing as kids are watching the TV and don't appreciate me mucking about too much. Let me know if any issues.

mastermc0 commented 4 years ago

All good here nice one on the quick fix!

richard-scott commented 4 years ago

Thanks for the fix :-)