Repository navigation
fix: keep the board up between episodes - #3
Merged
Merged
Conversation
When an episode ends, Plex drops the session during its Up Next countdown and only starts a new one for the next episode afterwards. A poll that landed in that gap reported Idle, so the board flipped to a blank or "Nothing playing" screen, then flipped back once the next episode began. The plugin now keeps showing the last streams for a new Hold Between Episodes setting (hold_seconds, default 60, 0 turns it off), counted from the first poll that finds nothing. It also skips sessions that have no title yet, so a half-loaded session can't blank the board either. Bumps the plugin to 1.2.0. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A7aYfsnp25o3X3x3AYhzPQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A user reported that with a 30-second refresh, the board sometimes flips to an empty display between episodes, then flips back once the next one starts. Their workaround was to pull the data through Home Assistant and delay the entities.
When an episode ends, Plex removes the session from
/status/sessionsduring its Up Next countdown. It only creates a new session once the next episode starts. A poll that lands in that gap gets no sessions, so the plugin reportsIdlewith every media variable blank.Filtering out updates with a blank episode title doesn't help on its own. In the gap the session is usually missing entirely, not present with an empty title.
Change
hold_secondssetting, titled "Hold Between Episodes": default 60, range 0–600, 0 turns it off. When Plex reports no streams, the plugin keeps returning the last streams it saw until the hold runs out. The timer starts at the first empty poll, not the last poll that saw a stream, so the hold doesn't depend on the refresh interval. A new stream replaces the held one immediately and resets the timer.state,is_playingandstream_count.titleare skipped. A session Plex hasn't loaded yet has nothing to show, and it can't replace the stream being held.validate_configrejects ahold_secondsthat isn't a number or is outside 0–600.Trade-off: after playback really stops, "Nothing playing" now appears up to
hold_secondsplus one refresh later. Set the hold to 0 to get the old behavior.Tests
There are 13 new tests: 11 in
TestHoldBetweenEpisodesand 2 validation tests. I wrote them before the implementation.With only
import timeadded, so thetime.monotonicpatch resolves, they failed on behavior:Some tests already passed before the change, because they cover idle behavior that exists today. To check those, I broke the implementation in six ways and confirmed each break is caught:
test_last_stream_is_held_through_a_gapand 4 more<→<=at the hold boundarytest_idle_once_the_hold_runs_out,test_hold_counts_from_the_first_empty_poll,test_zero_turns_the_hold_offtest_idle_stays_idle_after_the_holdand 2 morehold_seconds: 0treated as the defaulttest_zero_turns_the_hold_offtest_stream_without_a_title_is_skipped,test_stream_without_a_title_does_not_replace_the_held_onetest_hold_restarts_after_playback_resumesA seventh mutation survived: removing the line that cleared the held list once the hold ran out. That showed the line had no effect on behavior, so I removed it from the implementation. One more redundant early return came out the same way.
Changed test:
test_minor_version_bumppinnedversion == "1.1.0", so any release would fail it. I renamed it totest_sign_in_is_not_a_breaking_release; it now asserts major 1 and at least 1.1. That keeps what it protected: sign-in shipped without breaking 1.0.x settings.Results:
./run_tests.sh: 125 passed,__init__.pyat 100% coverage.scripts/validate_plugins.py --plugin=plex --strict: passed, no warnings.Not verified: I couldn't test against a real Plex server. The gap behavior comes from how Plex handles Up Next sessions, not from a captured response. Once this ships, it's worth asking the reporting user to confirm the 60-second default covers their countdown.
🤖 Generated with Claude Code
https://claude.ai/code/session_01A7aYfsnp25o3X3x3AYhzPQ
Generated by Claude Code