Companion features from pyatv (app launch/list, power, Control Center) + opack negative-integer fix - #1
Open
camschroedes wants to merge 2 commits into
Open
Conversation
packInteger's final branch uses writeBigUInt64LE, which throws
ERR_OUT_OF_RANGE for any negative value (e.g. MediaControl skips:
sendCommand('_mcc', { _mcc: 7, _skpS: -10 })). Negative integers now
encode as float64 (0x36), which devices accept anywhere a number is
expected — pyatv sends these fields as floats too.
Co-Authored-By: Cameron Schroeder <64573040+camschroedes@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ports four Companion capabilities from pyatv's reference implementation
onto the existing public sendCommand path:
- launchApp(conn, bundleIdOrUrl): _launchApp with _bundleID, or _urlS
for URLs/schemes (tvOS deep links)
- listApps(conn): FetchLaunchableApplicationsEvent → { bundleId: name }
- sleep(conn) / wake(conn): HID 12/13 button press
- controlCenter(conn): single HID PageDown (19) — matching pyatv's
control_center(), which notably is not a Home hold
Verified against an Apple TV 4K (tvOS 18): launch by bundle id and URL,
app listing, sleep/wake all work over an existing paired session.
Co-Authored-By: Cameron Schroeder <64573040+camschroedes@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5 tasks
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.
Hi Brian — thanks for atvjs, it powers a Raycast Apple TV extension I've been building (camschroedes/raycast-apple-tv-remote). Along the way I ported a few Companion capabilities from pyatv on top of your public
sendCommand, and hit one real bug — contributing both back.Bug fix:
pack()crashes on negative integerspackInteger's final branch callswriteBigUInt64LE, which throwsERR_OUT_OF_RANGEfor any negative value:This bites anyone using MediaControl skip (
_mcc: 7, _skpS: -10for skip-backward). Negative integers now encode as float64 (0x36), which devices accept anywhere a number is expected — pyatv sends these fields as floats as well.Features (ported from pyatv's Companion implementation)
launchApp(conn, bundleIdOrUrl)—_launchAppwith_bundleID, or_urlSfor URLs/schemes (tvOS deep links)listApps(conn)—FetchLaunchableApplicationsEvent→{ bundleId: displayName }sleep(conn)/wake(conn)— HID 12/13 presscontrolCenter(conn)— single HID PageDown (19); notably pyatv'scontrol_center()is not a Home holdAll verified against an Apple TV 4K (tvOS 18) over a paired Companion session: bundle-id and URL launches, app listing, sleep/wake, and Control Center all work; skip ±10s works with the opack fix.
npm run build(tsc) passes. Happy to split the fix into its own PR or adjust API naming to taste.🤖 Generated with Claude Code