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.8k stars 30.89k forks source link

Plex continues to discover media servers after 1 server is setup and discovery is ignored #27816

Closed dshokouhi closed 4 years ago

dshokouhi commented 5 years ago

Home Assistant release with the issue:

0.100.2

Last working Home Assistant release (if known):

N/A as we were never able to see non-local servers before 0.100

Operating environment (Hass.io/Docker/Windows/etc.):

venv Integration:

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

Description of problem:

  1. Setup 1 plex server via discovery notification, proceed to setup config flow and select local server (my list also contains servers shared to me that are not local)
  2. disable plex in discovery integration
  3. Wait some time

the discovery notification for plex integration continues to show up despite the local server being setup and the notification being dismissed.

Personally I would expect for it to stop notifying after 1 server is setup or ask the user to stop searching or disable certain servers. The additional servers that show up are not mine and are just shared.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

plex:
  token: !secret plex_token

Traceback (if applicable):

n/a

Additional information: I am not sure what the expected behavior here is or if this is a known issue around discovery.

probot-home-assistant[bot] commented 5 years ago

Hey there @jjlawren, mind taking a look at this issue as its been labeled with a integration (plex) you are listed as a codeowner for? Thanks!

jjlawren commented 5 years ago

I think this is only a UI thing since the component aborts immediately if there's already a config or if you're in the process of creating one: https://github.com/home-assistant/home-assistant/blob/463c2e8d45bf89199ea2cb64881cc38e37f14627/homeassistant/components/plex/config_flow.py#L164:L168

dshokouhi commented 5 years ago

@jjlawren yea I wasn't really sure where this issue relied. I was thinking it was from discovery but maybe something else is triggering the notification?

image

Every time I dismiss it the notification comes back in like 20 min or so?

jjlawren commented 4 years ago

I can't reproduce this when Plex is the only integration that's discovered. Do you have any other integrations listed under "Discovered" that haven't been configured yet? They may be coming from SSDP or zeroconf, too.

If Plex is showing up under "Discovered" then that's unexpected.

dshokouhi commented 4 years ago

I only have Plex listed under discovered. I already have Plex configured with my local server selected. All the servers remaining in the drop down are ones that are shared to me and I do not own them.

Mariusthvdb commented 4 years ago

I had the same behavior when plex was configured in config:

taking it out there, and have Plex configured via the integrations page solved this.

Maybe this is related (if not please discard): I do have another issue, maybe related to the Plex component continually trying to find a server, and that is it seems to halt the system if and when my Synology disk station( on which Plex server is running is) shut down for power saving during the night. The log is filled with Plex errors. see https://community.home-assistant.io/t/plex-discovery-causing-trouble/150022

Wish we could set the Plex component to stop 'discovering' when the configured server is offline....

dshokouhi commented 4 years ago

I had the same behavior when plex was configured in config:

taking it out there, and have Plex configured via the integrations page solved this.

Ah let me try this today.

jjlawren commented 4 years ago

I only have Plex listed under discovered.

Once you have added a Plex server integration, it should no longer display under the "Discovered" header. I cannot reproduce this on my side as of yet.

I already have Plex configured with my local server selected. All the servers remaining in the drop down are ones that are shared to me and I do not own them.

This is normal. When you attempt to set up additional Plex integrations when multiple servers are available, it will only offer to configure servers which you have not already configured.

jjlawren commented 4 years ago

Ah, I think I might understand why this is happening. It's actually not related to discovery at all. It will occur when:

  1. An existing Plex integration is configured
  2. A Plex entry remains in your configuration.yaml which both: a. Contains a token b. Does not specify an explicit Plex server IP/hostname
  3. Multiple servers are linked to the Plex account associated with the token

What happens is that on startup it attempts to import the token in the yaml config, finds multiple servers, and then waits for the user to choose one. I think this is probably the correct default behavior.

You can avoid this by removing the plex: entry from configuration.yaml or by adding in either host&port or server config options.

Mariusthvdb commented 4 years ago

You can avoid this by removing the plex: entry from configuration.yaml or by adding in either host&port or server config options.

Great you are seeing to this. I must however add the following config which shows it also happens when a host and port are in fact configured (and Plex is also configured via the integration):

plex:
  host: !secret plex_ip
  port: 32400
##  username: !secret plex_username
##  password: !secret plex_password
  ssl: false
  verify_ssl: false
  token: !secret plex_token
  media_player:
    use_episode_art: true
    show_all_controls: false

I have the username and password commented, as that is a remnant from a previous configuration. Simply showing here so to make sure I havent set these.

completely removing the config section does indeed stop the constant discovery, as I reported above. Not sure if I miss necessary options by doing so though. The config settings seem more complete and detailed

jjlawren commented 4 years ago

It's not needed anymore. The configuration.yaml is not used directly by plex, but are imported to create an integration config entry. The integration is started using those config entry options. You can see what's stored in <config_dir>/.storage/core.config_entries. The media_player options viewable/editable through the UI by clicking the gear inside the Plex integration page.

Mariusthvdb commented 4 years ago

I see yes, thanks.. what about the ssl settings? Are they configurable or needed? I can see the verify_ssl: false in the config_entries, the ssl: false isn't there though.

jjlawren commented 4 years ago

That's now built into the URL's http/https prefix.

dshokouhi commented 4 years ago

Ah, I think I might understand why this is happening. It's actually not related to discovery at all. It will occur when:

  1. An existing Plex integration is configured
  2. A Plex entry remains in your configuration.yaml which both: a. Contains a token b. Does not specify an explicit Plex server IP/hostname
  3. Multiple servers are linked to the Plex account associated with the token

What happens is that on startup it attempts to import the token in the yaml config, finds multiple servers, and then waits for the user to choose one. I think this is probably the correct default behavior.

You can avoid this by removing the plex: entry from configuration.yaml or by adding in either host&port or server config options.

Yup that was it, after removing the configuration after the import it no longer attempts to discover other servers :) I am ok to close this now if you are @jjlawren

jjlawren commented 4 years ago

I have an idea on how to prevent this. Let's keep it open so I remember to fix it.