Skip to content

Skip parsing Plex session if incomplete#33534

Merged
balloob merged 4 commits intohome-assistant:devfrom
jjlawren:plex_sensor_incomplete_session
Apr 6, 2020
Merged

Skip parsing Plex session if incomplete#33534
balloob merged 4 commits intohome-assistant:devfrom
jjlawren:plex_sensor_incomplete_session

Conversation

@jjlawren
Copy link
Copy Markdown
Contributor

@jjlawren jjlawren commented Apr 2, 2020

Proposed change

Sometimes incomplete data is returned for an actively playing session. Not much we can do besides skip it and try again later.

In this case the session details will be unavailable, but the session will still be counted in the total number of known sessions.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

Comment thread homeassistant/components/plex/sensor.py
@jjlawren
Copy link
Copy Markdown
Contributor Author

jjlawren commented Apr 2, 2020

Please hold off on merging, I'd like to dig into the problem a bit more first.

@jjlawren
Copy link
Copy Markdown
Contributor Author

jjlawren commented Apr 4, 2020

I think the underlying problem is a race condition when updates happen too frequently that's now addressed in #33560. Closing this for now.

@jjlawren
Copy link
Copy Markdown
Contributor Author

jjlawren commented Apr 5, 2020

Looks like this might still be necessary after all. Sometimes the data we receive from the Plex API actually isn't complete.

@jjlawren jjlawren reopened this Apr 5, 2020
Comment thread homeassistant/components/plex/sensor.py
Comment thread homeassistant/components/plex/sensor.py Outdated
@balloob balloob added this to the 0.108.0 milestone Apr 6, 2020
@balloob balloob merged commit c39fe36 into home-assistant:dev Apr 6, 2020
balloob pushed a commit that referenced this pull request Apr 6, 2020
* Skip parsing session if incomplete

* Schedule an update if session data is incomplete

* Mark as callback

* Remove update() & convert to async, abort if any session is incomplete
@jjlawren jjlawren deleted the plex_sensor_incomplete_session branch April 6, 2020 18:29
Comment thread homeassistant/components/plex/sensor.py
@property
def device_state_attributes(self):
"""Return the state attributes."""
return {content[0]: content[1] for content in self._now_playing}
Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally want to set the state attribute keys explicitly to be able to check formatting and content.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was legacy code copied over as-is. It's worked for a long time, I'd rather not touch it right now.

@jjlawren jjlawren mentioned this pull request Apr 7, 2020
20 tasks
@lock lock Bot locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLEX: IndexError: list index out of range

5 participants