Home_Assistant_SkyQ_MediaPlayer: Error on Button Press - 2.2.0 Alpha 2

Describe the bug Error msg thrown when button pressed via mini-media-player card

To Reproduce Box configured via yaml. Integration shows SkyQ box no prob and displays what’s on, etc so all working there I think. Press any of the “buttons” on the card (eg Home) and error message thrown - see log below

Component versions

  1. What version of SkyQ component are you using? 2.2.0 Alpha 2
  2. What was the last version where the problem was not shown? 2.1.8

Your config.yaml

  - platform: skyq
    host: 192.168.10.242
    name: SkyQ Office
    room: Office
    #config_directory: '/config/'
    generate_switches_for_channels: true
    country: GBR
    sources:
      CHup: 'channelup'
      CHdn: 'channeldown'
      Select: 'select'                                                          
      Up: 'up'                                                                  
      Down: 'down'                                                              
      Left: 'left'                                                              
      Right: 'right'                                                            
      I: 'i'                                                                    
      Dismiss: 'dismiss'                                                        
      Sidebar: 'Sidebar'                                                        
      Home: 'home'                                                              
      TVGuide: 'tvguide'                                                        
      Sky: 'sky'                                                                
      Record: 'record'  

Output of HA logs

ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2799407504] local variable 'channel' referenced before assignment
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
  connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1253, in async_call
  task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1288, in _execute_service
  await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
  self._platforms.values(), func, call, required_features
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 453, in entity_service_call
  future.result()  # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in async_request_call
  await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 484, in _handle_entity_call
  await result
File "/config/custom_components/skyq/media_player.py", line 405, in async_select_source
  if channel:
UnboundLocalError: local variable 'channel' referenced before assignment

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

YAML adds no extra features, apart from simpler duplication of config.

I’ve posted a beta 1, because I think it is now at a level of code stability to warrant it, let me know how it goes.

This all helps, because it shows I need to do some proper documentation on how it should be setup. I just haven’t done that yet because I keep going… ‘I wonder if I can change it to do that…?’. Not happy with the custom sources, but I just can’t figure out how to make the config flow do it better…

So, no I don’t need you to post if no problem 😃

Cheers Roger. re the buttons, yes you are right. I’m using the mini media player card too so I know I can config in there. Updating and removing them from my existing config is “on the list” but haven’t gotten around to it…it worked so as usual it’s a case of it if ain’t broke.

Thanks again for looking at this

I’ll publish an alpha3 shortly which should fix this. Just as a comment though, you shouldn’t need things like channelup/down in your sources anymore, you can call them direct as detailed here:

https://community.home-assistant.io/t/custom-component-skyq-media-player/140306/370?u=rogtp.

It then allows you to keep sources for channels and the like, rather than basic functions from a remote control.

I’d be interested if you feel you still need them, just so I understand how people are using it.