RogerSelwyn / Home_Assistant_SkyQ_MediaPlayer

Home Assistant SkyQ Media player component
MIT License
101 stars 17 forks source link

[BUG] Cannot select all sources for each skyq instance #123

Closed mark007 closed 1 year ago

mark007 commented 1 year ago

Describe the bug
When configuring the integration within the HA UI, if I select all the channels/sources for a given skyq instance, some channels will not be selected after I go to reconfigure the integration such as '342 - Sky Comedy HD'. After I reconfigure and select those channels/sources that had not selected and hit 'Submit', the integration shows a flashing 'Initializing' sign in the HA UI and an error is seen in the logs.

To Reproduce
Steps to reproduce the behavior: Try to select all sources for a given integration instance during configuration. (It can take a while, lots of clicks, maybe a possible future improvement ;) )

  1. What were you doing/watching at the time ? NA
  2. What channel were you on? NA
  3. What time did the problem occur? 20:37 on 20th October 2022
  4. Where are you (bear in mind component supports GBR/ITA at the moment)? Ireland

Expected behavior
I expect to be able to select all channels/sources for each skyq instance as I use them in some automations.

Screenshots
If applicable, add screenshots to help explain your problem.

Component versions

  1. What version of SkyQ component are you using? v2.9.10

  2. What was the last version where the problem was not shown? As this is my first time using a UI configuration, I have no previous version to compare against.

Your configuration
How have you setup your devices, by UI or YAML? UI.

Your configuration from the options dialogue
or

Output of HA logs

Logger: homeassistant.components.media_player Source: helpers/entity_platform.py:520 Integration: Media Player (documentation, issues) First occurred: 20:36:30 (45 occurrences) Last logged: 20:37:32

Platform skyq does not generate unique IDs. ID IRL04888466641 already exists - ignoring media_player.living_room_sky

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:520 Integration: Sensor (documentation, issues) First occurred: 20:36:30 (45 occurrences) Last logged: 20:37:32

Platform skyq does not generate unique IDs. ID IRL04888466641_used already exists - ignoring sensor.living_room_sky_used_storage

Additional context
Add any other context about the problem here.

RogerSelwyn commented 1 year ago

I've done some work on your other bug that should fix it, just testing another fix through for a bug I spotted.

When doing initial setup, did you select all channels, or just a (large) number? I'd like to start from there, if it isn't configuring them all up. Maybe there are some limits in HA for select boxes. Or of course a bug in my code 😕

mark007 commented 1 year ago

Thanks a lot @RogerSelwyn

Actually when I added two instances of the skyq integration in the UI, my intention was to select all of the channels. I noticed one of my automations wasn't working so I went to check if I had missed some and thats when I noticed most but not all were checked. I am not 100% sure at this point actually if I missed those few that are now unticked, in the UI the first time around, or if I actually did select them all but only say 95% of them saved. Whatever I did first time around, I now definitely can't tick them and hit submit without HA errors appearing.

The integration does report Success though after I hit submit. But in the background the 'Initializing' can be seen constantly flickering on/off repeatedly until I refresh the page. Heres a shot of that.

https://ibb.co/74xK333

RogerSelwyn commented 1 year ago

OK, there are probably two problems here.

The channel list issue is because I only store the channel name, because channel numbers change and I wanted for people not to have to re-configure if they do. I relied on channel names being unique, but they aren't - in GBR 'Sky Comedy HD' shows different programmes on 114 and 308. Because when I present them back to the gui, it looks up the name in the list of channels, it will only pick up the first instance in the channel list.

The second problem you are reporting doesn't happen for me, but it maybe because you are IRL. I'll try to test, but it can be a problem for me to pretend it is IRL when my box is actually GBR... We'll see what I can do.

mark007 commented 1 year ago

Thanks so much @RogerSelwyn If there is anything I can give as input from my side let me know.

RogerSelwyn commented 1 year ago

Would you be prepared to manually copy in the install from Github rather than me creating a release. I've not fixed the channel problem (that will take some work but I know the issue), but I'd like to see what is happening with the unique_id issue because that shouldn't happen.

I've added some extra debug logging which will say when the old config has been unloaded and the new one loaded which will tell me if things match up and are in the right order. You should get something like the below when you go to configure and hit the submit button.

2022-10-21 13:50:10.105 DEBUG (MainThread) [custom_components.skyq.config_flow] D0010 - Config options flow initiated for: Sky Q, 192.168.1.122, GBR06270868572
2022-10-21 13:50:18.223 DEBUG (MainThread) [custom_components.skyq] D0020 - Unload 192.168.1.122, GBR06270868572
2022-10-21 13:50:18.499 DEBUG (MainThread) [custom_components.skyq] D0030 - Unload OK 192.168.1.122, GBR06270868572
2022-10-21 13:50:18.499 DEBUG (MainThread) [custom_components.skyq] D0010 - Load 192.168.1.122, GBR06270868572
2022-10-21 13:50:29.200 INFO (MainThread) [custom_components.skyq.classes.power] I0020 - Device is now available after startup: Sky Q

All the IPs and unique IDs should tie up

mark007 commented 1 year ago

Perfect, if you can send me a few steps to follow, I can do that this evening.

RogerSelwyn commented 1 year ago

This will help if you have FTP type access to your site using something like FileZilla:

You will need to have the following in your config before you reboot:

  logs:
    custom_components.skyq: debug

If this isn't possible, then I'll create an install you can use. Got to go walk now....

mark007 commented 1 year ago

Cheers, I have uploaded the changed init and config_flow files and set the debug log level and restarted. I'll see what the logs show in the morning.

RogerSelwyn commented 1 year ago

There are other changes as well elsewhere in the current code set, but I don’t think that will cause issues.

mark007 commented 1 year ago

Did you want me to revert to the yaml based setup for the test of the duplicate entities?

RogerSelwyn commented 1 year ago

No, because the error you reported was from ui setup. If you had both ui and yaml, then you would very likely have got duplicates.

mark007 commented 1 year ago

Got ya. I can get logs now after trying to submit in the UI. Logs below are from just now, after reconfiguring my living room sky, skyq integration instance. I selected two of the unselected sources and hit Submit and below was the result.

2022-10-21 18:28:01.399 DEBUG (MainThread) [custom_components.skyq.config_flow] D0010 - Config options flow initiated for: Living Room Sky, 192.168.86.23, IRL04888466641 2022-10-21 18:28:12.451 DEBUG (MainThread) [custom_components.skyq] D0020 - Unload 192.168.86.23, IRL04888466641 2022-10-21 18:28:12.604 DEBUG (MainThread) [custom_components.skyq] D0030 - Unload OK 192.168.86.23, IRL04888466641 2022-10-21 18:28:12.604 DEBUG (MainThread) [custom_components.skyq] D0010 - Load 192.168.86.23, IRL04888466641

RogerSelwyn commented 1 year ago

See #125 to track the bug related to unique IDs

RogerSelwyn commented 1 year ago

Fixed with - https://github.com/RogerSelwyn/Home_Assistant_SkyQ_MediaPlayer/releases/tag/v2.9.11

RogerSelwyn commented 1 year ago

Ahh you did, missed it. I'll review

mark007 commented 1 year ago

Fixed with - https://github.com/RogerSelwyn/Home_Assistant_SkyQ_MediaPlayer/releases/tag/v2.9.11

Thanks a lot @RogerSelwyn very much appreciate the updates

leeandy1 commented 1 year ago

I am also having issues in adding additional channels to my already set up device. I am already running v2.10.0

I tick the channels and click submit but if I then go back in to the UI configuration they are no longer selected

RogerSelwyn commented 1 year ago

I am also having issues in adding additional channels to my already set up device. I am already running v2.10.0

I tick the channels and click submit but if I then go back in to the UI configuration they are no longer selected

Please provide some more details, specifically which channels you can't select. Also, are there any errors in the logs, and do you see a duplicate channel name in the list?

leeandy1 commented 1 year ago

I tried to add 302 and 303. I can select them fine and when I re-expand the drop down they remain selected. One thing that I do notice is that when I click submit on the first page it does not take me to the advanced options page (option is selected). There are no duplicated channels in the list. I do not see any errors in the log.

RogerSelwyn commented 1 year ago

I tried to add 302 and 303. I can select them fine and when I re-expand the drop down they remain selected. One thing that I do notice is that when I click submit on the first page it does not take me to the advanced options page (option is selected). There are no duplicated channels in the list. I do not see any errors in the log.

I'll see if I can figure something, but I'd probably delete it and re-add the box. Shouldn't impact your setup in any way as long as you use the same config options. Don't think you need to re-install the integration.

I've literally gone through and configured those channels, no problem. Seems weird.

leeandy1 commented 1 year ago

Ok so I have deleted the device and re-added. I have selected all the channels I need, including 302 and 303 and it has worked this time. Maybe something was corrupt in my config.

Thanks for your help.

RogerSelwyn commented 1 year ago

Ok so I have deleted the device and re-added. I have selected all the channels I need, including 302 and 303 and it has worked this time. Maybe something was corrupt in my config.

Thanks for your help.

I would suspect I have some dodgy code somewhere, but I fear that it may be difficult for me to replicate. I have deleted and re-created sooooo many times in my dev environment.