/** * Philips TV API Client * Handles all communication with the Philips TV JointSpace API (v6) */ import type { VolumeState, TVSource, TVApplication, TVChannel, RemoteKey, SystemInfo, AmbilightStyleName, AmbilightTopology, AmbilightCached, AmbilightColor } from './types.js'; /** Built-in HDMI sources for Android TV (Philips) */ export declare const HDMI_SOURCES: Readonly>; /** Watch TV source URI */ export declare const WATCH_TV_URI = "content://android.media.tv/channel"; /** Home screen virtual source URI */ export declare const HOME_URI = "virtual:home"; export interface PhilipsTVClientConfig { ip: string; mac: string; username: string; password: string; } export declare class PhilipsTVClient { private readonly config; private readonly debug; /** Promise chain that serializes all requests to the TV */ private requestQueue; /** Cached app intents — maps packageName to the intent returned by the TV */ private appIntents; /** Shared digest auth session — avoids a 401 round-trip on every request */ private readonly authSession; constructor(config: PhilipsTVClientConfig, debug?: (message: string) => void); /** * Queued request wrapper. Serializes all API calls so only one HTTP * exchange is in-flight at a time, with a small delay between requests * to avoid overwhelming the TV's lightweight JointSpace API server. * * A queue-level timeout ensures requests that wait too long behind * earlier (timed-out) requests are dropped before exceeding * Homebridge's characteristic callback timeout. */ private request; /** Performs the actual HTTP request with digest auth handling. */ private executeRequest; /** * Perform a fresh digest auth handshake from a 401 response, * caching the parameters for subsequent requests. */ private freshDigestAuth; /** * Parse a JSON response body. Returns null only on parse failure. * Empty bodies on 2xx responses return an empty object (common for POST success). */ private parseJsonResponse; private get; private post; getPowerState(): Promise; setPowerState(on: boolean): Promise; private tryWakeOnLan; getVolume(): Promise; setVolume(volume: number): Promise; setMuted(muted: boolean): Promise; /** * Fetches available sources from the TV API. * Falls back to built-in sources if the API call fails. * * An optional timeout override lets callers that are not bound by * HomeKit's characteristic callback deadline (e.g. the setup wizard) * give a momentarily-slow TV a longer chance to return real sources * before falling back. */ getSources(timeout?: number): Promise; /** * Returns hardcoded built-in sources (Watch TV + HDMI ports). * Use getSources() instead for dynamic source fetching. */ getBuiltInSources(): TVSource[]; launchWatchTV(): Promise; launchHome(): Promise; setSource(sourceUri: string): Promise; getApplications(timeout?: number): Promise; /** * Launch an app by package name. * * @param className - Explicit launch activity. Required to reliably launch * apps the TV's `/applications` endpoint does not report (e.g. sideloaded * apps) — Philips firmware rejects a launch without a valid className. * When omitted, a cached intent from {@link getApplications} is used, * falling back to a best-effort `.MainActivity` guess (the common * Android convention, e.g. `com.netflix.ninja.MainActivity`). * @param action - Intent action (defaults to `android.intent.action.MAIN`). */ launchApplication(packageName: string, className?: string, action?: string): Promise; getCurrentActivity(): Promise; /** * Get the full launch intent of the app currently open on the TV. * Used to capture the package/class/action of an app for a custom-app entry. */ getCurrentActivityIntent(): Promise<{ packageName: string; className: string | null; action: string | null; } | null>; private launchIntent; getChannels(): Promise; setChannel(ccid: number, channelListId?: string): Promise; sendKey(key: RemoteKey): Promise; getSystemInfo(): Promise; isReachable(): Promise; getAmbilightPower(): Promise; setAmbilightPower(on: boolean): Promise; /** * Get the current Ambilight style/mode */ getAmbilightStyle(): Promise; /** * Set Ambilight to a specific style * @param style - The style name: OFF, FOLLOW_VIDEO, FOLLOW_AUDIO, FOLLOW_COLOR, etc. * @param algorithm - Optional algorithm for FOLLOW_AUDIO (e.g., 'ENERGY_ADAPTIVE_BRIGHTNESS') */ setAmbilightStyle(style: AmbilightStyleName, algorithm?: string): Promise; /** * Set Ambilight to Follow Video mode * @param style - Video style: STANDARD, NATURAL, FOOTBALL, VIVID, GAME, COMFORT, RELAX */ setAmbilightFollowVideo(style?: string): Promise; /** * Set Ambilight to Follow Audio mode * @param algorithm - Audio algorithm: ENERGY_ADAPTIVE_BRIGHTNESS, VU_METER, SPECTRUM_ANALYZER, etc. */ setAmbilightFollowAudio(algorithm?: string): Promise; /** * Set Ambilight to Follow Color (static color) mode * @param color - The color to display (hue, saturation, brightness each 0-255) * @param speed - Animation speed (0-255), 0 = static */ setAmbilightFollowColor(color: AmbilightColor, speed?: number): Promise; /** * Set Ambilight to Lounge Light mode (preset colors) * @param preset - Preset name: 'Hot lava', 'Deep water', 'Fresh nature', 'Warm White', 'Cool white' */ setAmbilightLounge(preset?: string): Promise; /** * Turn Ambilight off. * Tries styleName OFF first, falls back to /ambilight/power. */ setAmbilightOff(): Promise; /** * Get Ambilight topology (number of LEDs on each side) */ getAmbilightTopology(): Promise; /** * Set Ambilight brightness * @param brightness - Brightness level (0-10) */ setAmbilightBrightness(brightness: number): Promise; /** * Set Ambilight saturation * @param saturation - Saturation level (0-10) */ setAmbilightSaturation(saturation: number): Promise; /** * Get whether the Ambilight+Hue integration (Hue lamps follow Ambilight) is on. */ getAmbilightHue(): Promise; /** * Enable or disable the Ambilight+Hue integration (Hue lamps follow Ambilight). */ setAmbilightHue(on: boolean): Promise; wakeUp(): Promise; private sleep; }