fix: wrap replacement deck in BetterDeck on resume from sleep by mattmattox · Pull Request #565 · StreamController/StreamController · GitHub
Skip to content

fix: wrap replacement deck in BetterDeck on resume from sleep#565

Merged
Core447 merged 1 commit into
StreamController:mainfrom
mattmattox:fix/resume-from-sleep-betterdeck
Mar 5, 2026
Merged

fix: wrap replacement deck in BetterDeck on resume from sleep#565
Core447 merged 1 commit into
StreamController:mainfrom
mattmattox:fix/resume-from-sleep-betterdeck

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Summary

Fixes #464 — StreamController becomes non-functional after the laptop resumes from sleep, requiring a manual app restart.

Root cause:

DeckController stores its device as a BetterDeck wrapper (defined in BetterDeck.py). BetterDeck provides get_rotation() and transparent key-index remapping for rotated decks.

On resume, on_resumed() calls get_device_by_serial() which returns a raw StreamDeck SDK device (not a BetterDeck), then assigns it directly:

deck_controller.deck = new_device  # raw SDK object — no get_rotation()
deck_controller.update_all_inputs()  # crashes immediately

update_all_inputs() calls self.deck_controller.deck.get_rotation() at line 1980/1982 of DeckController.py, which fails because the raw SDK object doesn't have that method:

AttributeError: 'StreamDeckOriginalV2' object has no attribute 'get_rotation'

Fix:

Preserve the existing rotation from the old BetterDeck, then wrap the new raw device in a fresh BetterDeck before assigning it — exactly as DeckController.__init__ does on first load:

current_rotation = deck_controller.deck.get_rotation()
deck_controller.deck = BetterDeck(new_device, current_rotation)

BetterDeck is already imported in DeckManager.py.

Test plan

  • Sleep and resume the laptop with a Stream Deck connected — confirm it comes back to life without restarting the app
  • Confirm a rotated deck retains its rotation after resume
  • Confirm normal startup/operation is unaffected

On resume from suspend, on_resumed() called get_device_by_serial() which
returns a raw StreamDeck SDK device, then assigned it directly to
deck_controller.deck. This replaced the BetterDeck wrapper (which
provides get_rotation() and key-index remapping) with the raw device.

The subsequent update_all_inputs() call crashed immediately with:
  AttributeError: 'StreamDeckOriginalV2' has no attribute 'get_rotation'

Fix: preserve the existing rotation from the old BetterDeck, then wrap
the new raw device in a fresh BetterDeck before assigning it.

Fixes StreamController#464
@Core447 Core447 merged commit 6327094 into StreamController:main Mar 5, 2026
@Core447

Core447 commented Mar 5, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Not functional after laptop resumes from sleep

2 participants