iobroker.yamaha 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -21
- package/admin/i18n/de.json +25 -1
- package/admin/i18n/en.json +25 -1
- package/admin/i18n/es.json +25 -1
- package/admin/i18n/fr.json +25 -1
- package/admin/i18n/it.json +25 -1
- package/admin/i18n/nl.json +25 -1
- package/admin/i18n/pl.json +25 -1
- package/admin/i18n/pt.json +25 -1
- package/admin/i18n/ru.json +25 -1
- package/admin/i18n/uk.json +25 -1
- package/admin/i18n/zh-cn.json +25 -1
- package/build/lib/browse/browse-engine.js +35 -0
- package/build/lib/browse/browse-engine.js.map +3 -3
- package/build/lib/browse/objects.js +98 -8
- package/build/lib/browse/objects.js.map +2 -2
- package/build/lib/browse/surface.js +2 -1
- package/build/lib/browse/surface.js.map +2 -2
- package/build/lib/browse/types.js +6 -0
- package/build/lib/browse/types.js.map +2 -2
- package/build/lib/browse/xml-browse-driver.js +37 -18
- package/build/lib/browse/xml-browse-driver.js.map +2 -2
- package/build/lib/browse/ynca-browse-driver.js +64 -1
- package/build/lib/browse/ynca-browse-driver.js.map +2 -2
- package/build/lib/catalog/groups.js +1 -1
- package/build/lib/catalog/groups.js.map +2 -2
- package/build/lib/device-controller.js +24 -6
- package/build/lib/device-controller.js.map +2 -2
- package/build/lib/xml/device-controller.js +14 -3
- package/build/lib/xml/device-controller.js.map +2 -2
- package/build/lib/yxc/device-controller.js +8 -1
- package/build/lib/yxc/device-controller.js.map +2 -2
- package/build/lib/yxc/object-mapper.js +105 -13
- package/build/lib/yxc/object-mapper.js.map +2 -2
- package/build/main.js +1 -1
- package/build/main.js.map +2 -2
- package/io-package.json +27 -27
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/xml/device-controller.ts"],
|
|
4
|
-
"sourcesContent": ["import { CHANNEL_NAME_KEYS, type ObjectDef } from \"../catalog/types\";\nimport { tName } from \"../i18n\";\nimport {\n isPermanentXmlRefusal,\n parseInputList,\n parseReturnCode,\n parseSceneList,\n parseTunerInfo,\n type BasicStatus,\n type XmlScene,\n} from \"./protocol\";\nimport { parseXmlStatus, stateToXml, type XmlCommand } from \"./command-mapper\";\nimport { XML_AMP_CATALOG } from \"./catalog\";\nimport type { ConnectionHandle, ControllerLog } from \"../controller\";\nimport { errorMessage } from \"../util\";\nimport { PollDropDetector } from \"../lifecycle/poll-drop-detector\";\nimport type { ProbeMemory } from \"../lifecycle/probe-memory\";\nimport type { CommandGate } from \"../lifecycle/command-gate\";\nimport type { BrowseEngine } from \"../browse/browse-engine\";\nimport { createBrowseSurface } from \"../browse/surface\";\nimport { XML_BROWSE_SOURCES, XmlBrowseDriver } from \"../browse/xml-browse-driver\";\n\n/** XML/YNC has no push channel, so the state is polled at this interval by default. */\nconst DEFAULT_POLL_INTERVAL_MS = 60 * 1000;\n\ninterface XmlZone {\n /** Unified zone key (`main`, `zone2`, \u2026). */\n key: string;\n /** XML zone element (`Main_Zone`, `Zone_2`, \u2026). */\n element: string;\n /** State-id prefix for the zone. */\n prefix: string;\n}\n\nconst XML_ZONES: XmlZone[] = [\n { key: \"main\", element: \"Main_Zone\", prefix: \"\" },\n { key: \"zone2\", element: \"Zone_2\", prefix: \"multiroom.zone2.\" },\n { key: \"zone3\", element: \"Zone_3\", prefix: \"multiroom.zone3.\" },\n { key: \"zone4\", element: \"Zone_4\", prefix: \"multiroom.zone4.\" },\n];\n\n/** The subset of the XML client the controller uses (so tests can inject a fake). */\nexport interface XmlClientLike {\n /** Read a zone's Basic_Status. */\n getStatus(zone: string): Promise<BasicStatus>;\n /** Read the device's model name (System > Config). */\n getModelName(): Promise<string | undefined>;\n /** Send an inner command to a zone. */\n send(zone: string, inner: string): Promise<void>;\n /** Read an element's inner GET request and return the raw response body. */\n getXml(element: string, inner: string): Promise<string>;\n}\n\n/** The adapter callbacks the controller drives \u2014 narrow, so no adapter mock is needed in tests. */\nexport interface XmlControllerDeps {\n /** The XML client for this device. */\n client: XmlClientLike;\n /** Schedule the keepalive poll; returns a function that cancels it. */\n scheduleKeepalive(handler: () => void, ms: number): () => void;\n /** Create or update an object in the device tree. */\n upsertObject(id: string, def: ObjectDef): Promise<void>;\n /** Write a state value with ack (device-originated). */\n setStateAck(id: string, value: boolean | number | string): void;\n /** Adapter log. */\n log: ControllerLog;\n /**\n * The device's command gate: every request is paced through it, and its signal is the\n * connection's shutdown flag \u2014 a closed gate ends pending waits and stops state writes\n * from a poll that was already in flight. Absent in older tests \u2192 no browsing.\n */\n gate?: CommandGate;\n /** Per-device memory for answers that do not change while the device runs (see ProbeMemory). */\n probeMemory?: ProbeMemory;\n}\n\n/**\n * Drives one XML/YNC device: probe which zones answer, build the amp tree, seed\n * state, and route commands both ways. XML has no push, so state is refreshed by\n * a keepalive poll. Create-only.\n */\nexport class XmlDeviceController implements ConnectionHandle {\n private zones: XmlZone[] = [];\n private cancelKeepalive: (() => void) | undefined;\n private readonly dropDetector = new PollDropDetector();\n private browseEngine: BrowseEngine | undefined;\n /** The scenes each zone DECLARES (`Scene_Sel_Item`), for the recall write path. */\n private readonly scenesByZone = new Map<string, XmlScene[]>();\n /** Whether the device answers `<Tuner><Play_Info>` (the classic pre-2010 tuner). */\n private hasTuner = false;\n /** The amp state ids this controller actually created \u2014 the claim-with-proof gate for BOTH ways. */\n private readonly createdStates = new Set<string>();\n /** Per zone: the Basic_Status fields this device is known to deliver (persisted union). */\n private readonly zoneFields = new Map<string, Set<string>>();\n\n /**\n * @param deviceId the id-safe device id (object-tree path segment)\n * @param deps the client and adapter callbacks\n * @param pollIntervalMs how often to poll the device for state (default 60 s)\n */\n public constructor(\n private readonly deviceId: string,\n private readonly deps: XmlControllerDeps,\n private readonly pollIntervalMs: number = DEFAULT_POLL_INTERVAL_MS,\n ) {}\n\n /**\n * Probe each zone, create the tree for the ones that answer, seed state, and\n * start the keepalive poll.\n *\n * @returns true if the main zone answered and the tree was created\n */\n public async start(): Promise<boolean> {\n // Probe all zones in parallel and keep each answering zone's status, so a zone is\n // fetched once (for the probe) and seeded from that same response \u2014 not twice.\n const probes = await Promise.all(\n XML_ZONES.map(async zone => ({ zone, status: await this.tryGetStatus(zone.element) })),\n );\n const answered = probes.filter(probe => probe.status && Object.keys(probe.status).length > 0);\n if (!answered.some(probe => probe.zone.key === \"main\")) {\n this.deps.log.debug(`${this.deviceId}: no XML main zone \u2014 creating no objects`);\n return false;\n }\n this.zones = answered.map(probe => probe.zone);\n // Freshness guard for the (persisted) probe memory: the model name is the identity\n // this transport can read. A different device behind the address drops the\n // remembered XML declarations (scenes, inputs, tuner, browse sources); a device\n // that reports no model keeps them \u2014 the YNCA/YXC guards catch a swap there.\n let model: string | undefined;\n try {\n model = await this.deps.client.getModelName();\n if (model !== undefined && this.deps.probeMemory) {\n if (this.deps.probeMemory.remembered(\"xmlModel\") !== model) {\n // Every XML-owned memory key carries the xml prefix (xmlBrowseSources,\n // xmlScenes:*, xmlInputs:*, xmlTuner, xmlModel).\n this.deps.probeMemory.drop(key => key.startsWith(\"xml\"));\n this.deps.probeMemory.set(\"xmlModel\", model);\n }\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getModelName failed (${errorMessage(e)})`);\n }\n // The zone's own input list (`Input_Sel_Item`, per zone \u2014 Main and Zone 2 differ on\n // real hardware): the device says which inputs it accepts, so the input state gets a\n // dropdown instead of a free string. Constant per model \u2014 remembered per device.\n const inputsByZone = new Map<string, string[]>();\n for (const zone of this.zones) {\n const body = await this.probeXml(\n `xmlInputs:${zone.key}`,\n zone.element,\n \"<Input><Input_Sel_Item>GetParam</Input_Sel_Item></Input>\",\n );\n inputsByZone.set(zone.key, parseInputList(body));\n }\n // Claim with proof, XML edition (2.0.1): only the states whose Basic_Status field\n // this device DELIVERS are created \u2014 a blind full-catalog rollout left valueless\n // objects (hdmi.out2, sound.direct, \u2026) standing on devices without the feature.\n // The delivered field set is a model property, remembered per zone (union, so a\n // later standby start \u2014 which may report fewer fields \u2014 cannot shrink the tree).\n for (const { zone, status } of answered) {\n const key = `xmlStatusFields:${zone.key}`;\n const remembered = this.deps.probeMemory?.remembered<string[]>(key);\n const fields = new Set<string>(Array.isArray(remembered) ? remembered : []);\n for (const field of Object.keys(status ?? {})) {\n fields.add(field);\n }\n this.deps.probeMemory?.set(key, [...fields]);\n this.zoneFields.set(zone.key, fields);\n }\n // Every parent \u2014 the zone channels included \u2014 is created by the per-state loop below\n // and named from the shared CHANNEL_NAME_KEYS table (a zone that answered has at least\n // its power state, so its channel always comes into being this way).\n const createdChannels = new Set<string>();\n for (const zone of this.zones) {\n for (const entry of XML_AMP_CATALOG) {\n // Main/system-wide features (scenes, HDMI outputs, party) exist only on the main zone.\n if (entry.mainOnly && zone.key !== \"main\") {\n continue;\n }\n // Claim with proof: skip what this device's status never delivered.\n if (entry.statusField !== undefined && !this.zoneFields.get(zone.key)?.has(entry.statusField)) {\n continue;\n }\n const stateId = `${zone.prefix}${entry.state}`;\n // A dotted state (e.g. scene.recall) needs its parent channel created first.\n const segments = stateId.split(\".\");\n for (let i = 1; i < segments.length; i++) {\n const channelId = segments.slice(0, i).join(\".\");\n if (!createdChannels.has(channelId)) {\n createdChannels.add(channelId);\n await this.deps.upsertObject(`${this.deviceId}.${channelId}`, {\n id: channelId,\n type: \"channel\",\n common: {\n // Capitalised like the catalog path does it, so the same folder cannot end up\n // called \"sound\" here and \"Sound\" there depending on which transport owns it.\n name: CHANNEL_NAME_KEYS[segments[i - 1]]\n ? tName(CHANNEL_NAME_KEYS[segments[i - 1]])\n : segments[i - 1].charAt(0).toUpperCase() + segments[i - 1].slice(1),\n },\n });\n }\n }\n const { nameKey, descKey, ...rest } = entry.common;\n const common: ObjectDef[\"common\"] = {\n ...rest,\n name: tName(nameKey),\n // An absent key means the datapoint explains itself \u2014 the fleet standard wants the\n // field empty there rather than filled with invented prose.\n ...(descKey ? { desc: tName(descKey) } : {}),\n };\n // The device's own input list becomes the dropdown (XML-owned devices only \u2014\n // where YNCA is present its dropdown wins via the owner policy).\n const inputs = entry.state === \"input\" ? inputsByZone.get(zone.key) : undefined;\n if (inputs && inputs.length > 0) {\n common.states = Object.fromEntries(inputs.map(input => [input, input]));\n }\n await this.deps.upsertObject(`${this.deviceId}.${stateId}`, {\n id: stateId,\n type: \"state\",\n common,\n });\n this.createdStates.add(stateId);\n }\n }\n await this.setupScenes(createdChannels);\n await this.setupTuner(createdChannels);\n // Seed from the statuses already fetched during the probe \u2014 no second round-trip.\n for (const { zone, status } of answered) {\n if (status) {\n this.seedZone(zone, status);\n }\n }\n // The model name (already read by the freshness guard) for the device-manager card.\n // Best-effort \u2014 a device that does not report it still connects, the line stays empty.\n if (model) {\n // The info channel and info.model already exist \u2014 the adapter creates them for\n // every device up front, so the card renders even while the device is offline.\n this.emit(\"info.model\", model);\n }\n await this.setupBrowse();\n this.cancelKeepalive = this.deps.scheduleKeepalive(() => void this.keepalive(), this.pollIntervalMs);\n // The adapter logs one combined \"ready\" line across all transports; this stays at debug.\n this.deps.log.debug(`${this.deviceId}: Yamaha (XML) device ready (XML)`);\n return true;\n }\n\n /**\n * Read one element's list once per device: the answer is a property of the MODEL\n * (input lists, scene declarations), so reconnects reuse it via the probe memory.\n *\n * Only a DEFINITE answer is remembered: a body, or the model's own \"no such node\"\n * (bodyless HTTP 400 / return code 2, both captured on the RX-V6A) as \"declares none\".\n * A transient failure \u2014 timeout, connection error, HTTP 5xx, or a state-dependent\n * refusal (return code 3/4, \"not now\") \u2014 is NOT remembered: before this, one busy\n * moment during the first contact recorded \"no scenes\" for that device for good, until\n * the model changed. Now it is simply asked again on the next connect.\n *\n * @param key the probe-memory key\n * @param element the XML element to ask\n * @param inner the inner GET request\n * @returns the raw response body, or \"\" when the device (definitely or for now) has none\n */\n private async probeXml(key: string, element: string, inner: string): Promise<string> {\n const probe = async (): Promise<string> => {\n let body: string;\n try {\n body = await this.deps.client.getXml(element, inner);\n } catch (e) {\n if (isPermanentXmlRefusal(e)) {\n return \"\"; // the model has no such node \u2014 definite\n }\n throw e; // transient \u2014 not remembered\n }\n const rc = parseReturnCode(body);\n if (rc !== undefined && rc !== 0) {\n if (rc === 2) {\n return \"\"; // RC 2 = the node does not exist on this model \u2014 definite\n }\n throw new Error(`device refused ${element} probe (RC=${rc})`); // \"not now\" \u2014 not remembered\n }\n return body;\n };\n try {\n return this.deps.probeMemory ? await this.deps.probeMemory.once(key, probe) : await probe();\n } catch (e) {\n this.deps.log.debug(\n `${this.deviceId}: ${key} probe failed, asking again on the next connect (${errorMessage(e)})`,\n );\n return \"\";\n }\n }\n\n /**\n * Build the scene surface from the device's OWN declaration (#615): each zone's\n * `<Scene_Sel_Item>` names the scenes that exist, their titles and the write value\n * (`Scene N` via `<Scene_Sel>`). The predecessor blindly sent `Scene_Load` to a\n * fixed 1..12 main-zone state; the capture shows the device declaring `Scene_Sel`\n * instead \u2014 and declaring scenes for Zone 2 too.\n *\n * @param createdChannels the channel ids already created (extended here)\n */\n private async setupScenes(createdChannels: Set<string>): Promise<void> {\n for (const zone of this.zones) {\n const body = await this.probeXml(\n `xmlScenes:${zone.key}`,\n zone.element,\n \"<Scene><Scene_Sel_Item>GetParam</Scene_Sel_Item></Scene>\",\n );\n const scenes = parseSceneList(body);\n if (scenes.length === 0) {\n continue;\n }\n this.scenesByZone.set(zone.key, scenes);\n const channelId = `${zone.prefix}scene`;\n if (!createdChannels.has(channelId)) {\n createdChannels.add(channelId);\n await this.deps.upsertObject(`${this.deviceId}.${channelId}`, {\n id: channelId,\n type: \"channel\",\n common: { name: tName(CHANNEL_NAME_KEYS.scene ?? \"Scenes\") },\n });\n }\n const max = Math.max(...scenes.map(scene => scene.num));\n await this.deps.upsertObject(`${this.deviceId}.${channelId}.recall`, {\n id: `${channelId}.recall`,\n type: \"state\",\n common: {\n name: tName(\"recallScene\"),\n desc: tName(\"descRecallScene\"),\n type: \"number\",\n role: \"level\",\n read: true,\n write: true,\n min: 1,\n max,\n step: 1,\n // The declared titles as the dropdown, so the picker shows \"Movie Viewing\",\n // not a bare number.\n states: Object.fromEntries(scenes.map(scene => [scene.num, scene.title])),\n },\n });\n // ONE list state instead of a name datapoint per scene (v2.0.0): visualizations\n // read titles as VALUES (button captions \u2014 the #613 reporter's setup), and a\n // dropdown's labels are not readable, so the list carries them.\n await this.deps.upsertObject(`${this.deviceId}.${channelId}.list`, {\n id: `${channelId}.list`,\n type: \"state\",\n common: { name: tName(\"scenesNumberTitle\"), type: \"string\", role: \"json\", read: true, write: false },\n });\n this.emit(`${channelId}.list`, JSON.stringify(scenes));\n }\n }\n\n /**\n * Build the classic tuner surface (pre-2010 devices, where XML is the ONLY\n * transport \u2014 the predecessor served their tuner, the rewrite had dropped it).\n * Existence is probed once per device; the preset write is the openHAB-verified\n * `<Play_Control><Preset><Preset_Sel>`; frequency/RDS/tuned are read-only from\n * Play_Info. On newer devices YNCA/YXC own these ids via the owner policy.\n *\n * @param createdChannels the channel ids already created (extended here)\n */\n private async setupTuner(createdChannels: Set<string>): Promise<void> {\n const probe = await this.probeXml(\"xmlTuner\", \"Tuner\", \"<Play_Info>GetParam</Play_Info>\");\n if (probe.length === 0) {\n return;\n }\n this.hasTuner = true;\n if (!createdChannels.has(\"tuner\")) {\n createdChannels.add(\"tuner\");\n await this.deps.upsertObject(`${this.deviceId}.tuner`, {\n id: \"tuner\",\n type: \"channel\",\n common: { name: tName(CHANNEL_NAME_KEYS.tuner ?? \"Tuner\") },\n });\n }\n const state = async (id: string, common: ObjectDef[\"common\"]): Promise<void> => {\n await this.deps.upsertObject(`${this.deviceId}.tuner.${id}`, { id: `tuner.${id}`, type: \"state\", common });\n };\n await state(\"preset\", {\n name: tName(\"presetRecallByNumber\"),\n desc: tName(\"descPresetRecallByNumber\"),\n type: \"number\",\n role: \"level\",\n read: true,\n write: true,\n // Slot 1 upwards \u2014 `handleTunerWrite` drops a 0, so offering it as the lower bound\n // invited a write that goes nowhere.\n min: 1,\n max: 40,\n step: 1,\n });\n await state(\"frequency\", {\n name: tName(\"frequency\"),\n type: \"number\",\n role: \"value\",\n unit: \"kHz\",\n read: true,\n write: false,\n });\n await state(\"rdsService\", {\n name: tName(\"rdsStation\"),\n desc: tName(\"descRdsStation\"),\n type: \"string\",\n role: \"text\",\n read: true,\n write: false,\n });\n await state(\"rdsText\", {\n name: tName(\"rdsText\"),\n desc: tName(\"descRdsText\"),\n type: \"string\",\n role: \"text\",\n read: true,\n write: false,\n });\n await state(\"tuned\", {\n name: tName(\"tunedToAStation\"),\n desc: tName(\"descTunedToAStation\"),\n type: \"boolean\",\n role: \"indicator\",\n read: true,\n write: false,\n });\n await state(\"stereo\", {\n name: tName(\"stereoReception\"),\n desc: tName(\"descStereoReception\"),\n type: \"boolean\",\n role: \"indicator\",\n read: true,\n write: false,\n });\n // NOT `emitTunerInfo(probe)`: the probe body comes out of the PERSISTED memory on every\n // reconnect and restart, so seeding from it published a snapshot of an earlier session\n // \u2014 frequency, RDS station and text, \"tuned\" \u2014 as the CURRENT reading, until the first\n // poll up to a whole interval later. The existence verdict is a model property and stays\n // remembered; the values are read fresh. (Same class as the menu's resting shape, which\n // showed rows six days older than the connection until it was fixed.)\n await this.refreshTuner();\n }\n\n /**\n * Write the tuner states from a Play_Info response.\n *\n * @param xml the Play_Info response body\n */\n private emitTunerInfo(xml: string): void {\n const info = parseTunerInfo(xml);\n if (info.preset !== undefined) {\n this.emit(\"tuner.preset\", info.preset);\n }\n if (info.frequency !== undefined) {\n // Unified kHz (v2.0.0): the device reports FM in MHz, AM in kHz \u2014 normalize.\n this.emit(\"tuner.frequency\", Math.round(info.frequencyUnit === \"MHz\" ? info.frequency * 1000 : info.frequency));\n }\n if (info.rdsService !== undefined) {\n this.emit(\"tuner.rdsService\", info.rdsService);\n }\n if (info.rdsText !== undefined) {\n this.emit(\"tuner.rdsText\", info.rdsText);\n }\n if (info.tuned !== undefined) {\n this.emit(\"tuner.tuned\", info.tuned);\n }\n if (info.stereo !== undefined) {\n this.emit(\"tuner.stereo\", info.stereo);\n }\n }\n\n /**\n * Poll the tuner's Play_Info (keepalive) and write the states.\n */\n private async refreshTuner(): Promise<void> {\n try {\n this.emitTunerInfo(await this.deps.client.getXml(\"Tuner\", \"<Play_Info>GetParam</Play_Info>\"));\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: tuner Play_Info failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * A user write to `tuner.preset` \u2192 the openHAB-verified preset recall.\n *\n * @param stateId the state id relative to the device\n * @param value the written value\n * @returns true when the id was the tuner preset (handled here)\n */\n private handleTunerWrite(stateId: string, value: unknown): boolean {\n if (stateId !== \"tuner.preset\" || !this.hasTuner) {\n return stateId === \"tuner.preset\";\n }\n const num = Math.round(Number(value));\n if (!Number.isFinite(num) || num < 1) {\n return true;\n }\n void this.applyCommand({\n zone: \"Tuner\",\n inner: `<Play_Control><Preset><Preset_Sel>${num}</Preset_Sel></Preset></Play_Control>`,\n });\n return true;\n }\n\n /**\n * A user write to a zone's `scene.recall` \u2192 the DECLARED write element\n * (`<Scene><Scene_Sel>Scene N</Scene_Sel></Scene>`). Only zones that declared\n * scenes accept the write; a refusal lands in the log via applyCommand.\n *\n * @param stateId the state id relative to the device\n * @param value the written value\n * @returns true when the id was a scene recall (handled here)\n */\n private handleSceneWrite(stateId: string, value: unknown): boolean {\n const match = /^(?:multiroom\\.(zone[234])\\.)?scene\\.recall$/.exec(stateId);\n if (!match) {\n return false;\n }\n const zoneKey = match[1] ?? \"main\";\n const zone = this.zones.find(z => z.key === zoneKey);\n const scenes = this.scenesByZone.get(zoneKey);\n // A TITLE is as valid a write as a number (\"Movie Viewing\" \u2192 Scene 1).\n const byTitle =\n typeof value === \"string\" && !/^\\d+$/.test(value.trim())\n ? scenes?.find(scene => scene.title.toLowerCase() === value.trim().toLowerCase())?.num\n : undefined;\n const num = byTitle ?? Math.round(Number(value));\n if (!zone || !scenes || !scenes.some(scene => scene.num === num)) {\n return true;\n }\n void this.applyCommand({ zone: zone.element, inner: `<Scene><Scene_Sel>Scene ${num}</Scene_Sel></Scene>` });\n return true;\n }\n\n /**\n * Create the browsing surface (#613) when at least one source answers a List_Info\n * probe (NET_RADIO/SERVER/USB \u2014 the menus the predecessor adapter's users drove\n * via `Realtime.*.LINE1TXT` + `xmlCommand`). Skipped without a delay dep (older tests).\n */\n private async setupBrowse(): Promise<void> {\n const gate = this.deps.gate;\n if (!gate) {\n return;\n }\n const delay = (ms: number): Promise<void> => gate.delay(ms);\n // Which sources have a menu is a property of the MODEL, not of this connection \u2014 ask\n // once per device instead of costing three extra requests (up to five seconds on a\n // receiver that has no menus at all) on every single reconnect.\n const probe = async (): Promise<string[]> => {\n const probes = await Promise.all(\n XML_BROWSE_SOURCES.map(async source => {\n try {\n const body = await this.deps.client.getXml(source.element, \"<List_Info>GetParam</List_Info>\");\n return body.includes(\"<Menu_Status>\") ? source.key : undefined;\n } catch (e) {\n if (isPermanentXmlRefusal(e)) {\n return undefined; // this model has no menu for that source (bodyless HTTP 400)\n }\n throw e; // transient \u2014 \"no menus\" must not be remembered for good\n }\n }),\n );\n return probes.filter((key): key is string => key !== undefined);\n };\n let available: Set<string>;\n try {\n available = new Set(\n this.deps.probeMemory ? await this.deps.probeMemory.once(\"xmlBrowseSources\", probe) : await probe(),\n );\n } catch (e) {\n this.deps.log.debug(\n `${this.deviceId}: browse probe failed, asking again on the next connect (${errorMessage(e)})`,\n );\n return;\n }\n if (available.size === 0) {\n return;\n }\n const driver = new XmlBrowseDriver(this.deps.client, available, delay);\n this.browseEngine = await createBrowseSurface(driver, this.deviceId, {\n upsertObject: this.deps.upsertObject,\n emit: (id, value) => this.emit(id, value),\n log: this.deps.log,\n delay,\n });\n }\n\n /**\n * Write a device-originated value \u2014 but never after the connection was closed. A poll\n * that was already in flight when the adapter stopped would otherwise still write into\n * a tree that is being torn down.\n *\n * @param relativeId the state id relative to the device\n * @param value the value to write\n */\n private emit(relativeId: string, value: boolean | number | string): void {\n if (this.deps.gate?.closed) {\n return;\n }\n this.deps.setStateAck(`${this.deviceId}.${relativeId}`, value);\n }\n\n /**\n * Handle a state change: a user write (ack false) becomes an XML command; an\n * acked change (the device's own echo) is ignored.\n *\n * @param fullStateId the full state id (device id + \".\" + state)\n * @param ack whether the change is acked (device-originated)\n * @param value the new value\n */\n public handleStateChange(fullStateId: string, ack: boolean, value: unknown): void {\n if (ack) {\n return;\n }\n const prefix = `${this.deviceId}.`;\n if (!fullStateId.startsWith(prefix)) {\n return;\n }\n const stateId = fullStateId.slice(prefix.length);\n if (stateId.startsWith(\"player.browse.\")) {\n this.browseEngine?.handleWrite(stateId, value);\n return;\n }\n // Scenes and the classic tuner are device-declared (not in the static catalog).\n if (this.handleSceneWrite(stateId, value)) {\n return;\n }\n if (this.handleTunerWrite(stateId, value)) {\n return;\n }\n // Claim with proof, on the WRITE way too. Object creation has been proof-gated since\n // 2.0.1 (only fields this device's Basic_Status really delivers), but the write path was\n // not \u2014 the comment on `createdStates` claimed otherwise while it guarded the read side\n // alone. XML was the last transport without it: YNCA writes only through its per-device\n // write map, MusicCast only through device-declared endpoints. It bites on a datapoint an\n // adapter version before 2.0.1 created and that once carried a value, so no sweep removes\n // it: writing it put a blind command on the wire that the device answers with a refusal.\n if (!this.createdStates.has(stateId)) {\n this.deps.log.debug(`${this.deviceId}: ${stateId} was not reported by this device \u2014 write dropped`);\n return;\n }\n const command = stateToXml(stateId, value);\n if (command) {\n void this.applyCommand(command);\n }\n }\n\n /**\n * Register the supervisor's drop handler. XML has no push/socket-drop event, so a\n * drop is inferred from a run of failed polls (see keepalive).\n *\n * @param cb invoked once when the device is judged gone\n */\n public onDrop(cb: (reason?: Error) => void): void {\n this.dropDetector.onDrop(cb);\n }\n\n /** Cancel the keepalive poll. Synchronous \u2014 safe to call from onUnload. */\n public close(): void {\n this.browseEngine?.close();\n // Closing the gate empties its queue and aborts its signal: queued requests are\n // dropped and every pending wait ends, so nothing writes after the teardown.\n this.deps.gate?.close();\n this.cancelKeepalive?.();\n this.cancelKeepalive = undefined;\n }\n\n /**\n * Poll every live zone. If every zone fails for three consecutive failed polls in a\n * row, the device is judged gone and a drop is reported so the supervisor reconnects.\n */\n private async keepalive(): Promise<void> {\n // The keepalive is an async handler on an adapter timer: a rejection here is an\n // UNHANDLED rejection, and js-controller turns those into an adapter stop. Every step\n // below catches for itself today, so the guard is what makes that a guarantee instead\n // of something the next change has to remember.\n try {\n let anyOk = false;\n for (const zone of this.zones) {\n if (await this.refreshZone(zone)) {\n anyOk = true;\n }\n }\n if (this.hasTuner) {\n await this.refreshTuner();\n }\n this.dropDetector.record(anyOk);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: keepalive poll failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Fetch a zone's status and write its amp states with ack.\n *\n * @param zone the zone to refresh\n * @returns true if the status was fetched, false if the request failed\n */\n private async refreshZone(zone: XmlZone): Promise<boolean> {\n const status = await this.tryGetStatus(zone.element);\n if (!status) {\n return false;\n }\n this.seedZone(zone, status);\n return true;\n }\n\n /**\n * Write a zone's amp states from an already-fetched Basic_Status (used to seed\n * from the start-up probe without a second round-trip).\n *\n * @param zone the zone the status belongs to\n * @param status the parsed Basic_Status\n */\n private seedZone(zone: XmlZone, status: BasicStatus): void {\n // A field the device delivers for the FIRST time mid-run has no object yet\n // (claim-with-proof creates only proven fields at start): remember it \u2014 the next\n // start creates it \u2014 and skip the write, so no state lands without an object.\n const known = this.zoneFields.get(zone.key);\n if (known) {\n let grew = false;\n for (const field of Object.keys(status)) {\n if (!known.has(field)) {\n known.add(field);\n grew = true;\n }\n }\n if (grew) {\n this.deps.probeMemory?.set(`xmlStatusFields:${zone.key}`, [...known]);\n }\n }\n for (const update of parseXmlStatus(status, zone.key)) {\n if (this.createdStates.has(update.id)) {\n this.emit(update.id, update.value);\n }\n }\n }\n\n /**\n * Read a zone's status, swallowing errors (an absent zone or an offline device).\n *\n * @param element the XML zone element\n * @returns the parsed status, or undefined on failure\n */\n private async tryGetStatus(element: string): Promise<BasicStatus | undefined> {\n try {\n return await this.deps.client.getStatus(element);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getStatus(${element}) failed: ${errorMessage(e)}`);\n return undefined;\n }\n }\n\n /**\n * Send a mapped command to the device.\n *\n * @param command the XML command to apply\n */\n private async applyCommand(command: XmlCommand): Promise<void> {\n try {\n await this.deps.client.send(command.zone, command.inner);\n } catch (e) {\n this.deps.log.warn(`${this.deviceId}: XML command failed: ${errorMessage(e)}`);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkD;AAClD,kBAAsB;AACtB,sBAQO;AACP,4BAA4D;AAC5D,qBAAgC;AAEhC,kBAA6B;AAC7B,gCAAiC;AAIjC,qBAAoC;AACpC,+BAAoD;AAGpD,MAAM,2BAA2B,KAAK;AAWtC,MAAM,YAAuB;AAAA,EAC3B,EAAE,KAAK,QAAQ,SAAS,aAAa,QAAQ,GAAG;AAAA,EAChD,EAAE,KAAK,SAAS,SAAS,UAAU,QAAQ,mBAAmB;AAAA,EAC9D,EAAE,KAAK,SAAS,SAAS,UAAU,QAAQ,mBAAmB;AAAA,EAC9D,EAAE,KAAK,SAAS,SAAS,UAAU,QAAQ,mBAAmB;AAChE;AAyCO,MAAM,oBAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBpD,YACY,UACA,MACA,iBAAyB,0BAC1C;AAHiB;AACA;AACA;AAAA,EAChB;AAAA,EAtBK,QAAmB,CAAC;AAAA,EACpB;AAAA,EACS,eAAe,IAAI,2CAAiB;AAAA,EAC7C;AAAA;AAAA,EAES,eAAe,oBAAI,IAAwB;AAAA;AAAA,EAEpD,WAAW;AAAA;AAAA,EAEF,gBAAgB,oBAAI,IAAY;AAAA;AAAA,EAEhC,aAAa,oBAAI,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmB3D,MAAa,QAA0B;AA/GzC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AA;AAAA;AAAA,EAOA,MAAc,aAAa,SAAoC;AAC7D,QAAI;AACF,YAAM,KAAK,KAAK,OAAO,KAAK,QAAQ,MAAM,QAAQ,KAAK;AAAA,IACzD,SAAS,GAAG;AACV,WAAK,KAAK,IAAI,KAAK,GAAG,KAAK,QAAQ,6BAAyB,0BAAa,CAAC,CAAC,EAAE;AAAA,IAC/E;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import { CHANNEL_NAME_KEYS, type ObjectDef } from \"../catalog/types\";\nimport { tName } from \"../i18n\";\nimport {\n isPermanentXmlRefusal,\n parseInputList,\n parseReturnCode,\n parseSceneList,\n parseTunerInfo,\n type BasicStatus,\n type XmlScene,\n} from \"./protocol\";\nimport { parseXmlStatus, stateToXml, type XmlCommand } from \"./command-mapper\";\nimport { XML_AMP_CATALOG } from \"./catalog\";\nimport type { ConnectionHandle, ControllerLog } from \"../controller\";\nimport { errorMessage } from \"../util\";\nimport { PollDropDetector } from \"../lifecycle/poll-drop-detector\";\nimport type { ProbeMemory } from \"../lifecycle/probe-memory\";\nimport type { CommandGate } from \"../lifecycle/command-gate\";\nimport type { BrowseEngine } from \"../browse/browse-engine\";\nimport { createBrowseSurface } from \"../browse/surface\";\nimport { XML_BROWSE_SOURCES, XmlBrowseDriver } from \"../browse/xml-browse-driver\";\n\n/** XML/YNC has no push channel, so the state is polled at this interval by default. */\nconst DEFAULT_POLL_INTERVAL_MS = 60 * 1000;\n\ninterface XmlZone {\n /** Unified zone key (`main`, `zone2`, \u2026). */\n key: string;\n /** XML zone element (`Main_Zone`, `Zone_2`, \u2026). */\n element: string;\n /** State-id prefix for the zone. */\n prefix: string;\n}\n\nconst XML_ZONES: XmlZone[] = [\n { key: \"main\", element: \"Main_Zone\", prefix: \"\" },\n { key: \"zone2\", element: \"Zone_2\", prefix: \"multiroom.zone2.\" },\n { key: \"zone3\", element: \"Zone_3\", prefix: \"multiroom.zone3.\" },\n { key: \"zone4\", element: \"Zone_4\", prefix: \"multiroom.zone4.\" },\n];\n\n/** The subset of the XML client the controller uses (so tests can inject a fake). */\nexport interface XmlClientLike {\n /** Read a zone's Basic_Status. */\n getStatus(zone: string): Promise<BasicStatus>;\n /** Read the device's model name (System > Config). */\n getModelName(): Promise<string | undefined>;\n /** Send an inner command to a zone. */\n send(zone: string, inner: string): Promise<void>;\n /** Read an element's inner GET request and return the raw response body. */\n getXml(element: string, inner: string): Promise<string>;\n}\n\n/** The adapter callbacks the controller drives \u2014 narrow, so no adapter mock is needed in tests. */\nexport interface XmlControllerDeps {\n /** The XML client for this device. */\n client: XmlClientLike;\n /** Schedule the keepalive poll; returns a function that cancels it. */\n scheduleKeepalive(handler: () => void, ms: number): () => void;\n /** Create or update an object in the device tree. */\n upsertObject(id: string, def: ObjectDef): Promise<void>;\n /** Write a state value with ack (device-originated). */\n setStateAck(id: string, value: boolean | number | string): void;\n /** Adapter log. */\n log: ControllerLog;\n /**\n * The device's command gate: every request is paced through it, and its signal is the\n * connection's shutdown flag \u2014 a closed gate ends pending waits and stops state writes\n * from a poll that was already in flight. Absent in older tests \u2192 no browsing.\n */\n gate?: CommandGate;\n /** Per-device memory for answers that do not change while the device runs (see ProbeMemory). */\n probeMemory?: ProbeMemory;\n}\n\n/**\n * Drives one XML/YNC device: probe which zones answer, build the amp tree, seed\n * state, and route commands both ways. XML has no push, so state is refreshed by\n * a keepalive poll. Create-only.\n */\nexport class XmlDeviceController implements ConnectionHandle {\n private zones: XmlZone[] = [];\n private cancelKeepalive: (() => void) | undefined;\n private readonly dropDetector = new PollDropDetector();\n private browseEngine: BrowseEngine | undefined;\n /** The scenes each zone DECLARES (`Scene_Sel_Item`), for the recall write path. */\n private readonly scenesByZone = new Map<string, XmlScene[]>();\n /** Whether the device answers `<Tuner><Play_Info>` (the classic pre-2010 tuner). */\n private hasTuner = false;\n /** The amp state ids this controller actually created \u2014 the claim-with-proof gate for BOTH ways. */\n private readonly createdStates = new Set<string>();\n /** Per zone: the Basic_Status fields this device is known to deliver (persisted union). */\n private readonly zoneFields = new Map<string, Set<string>>();\n\n /**\n * @param deviceId the id-safe device id (object-tree path segment)\n * @param deps the client and adapter callbacks\n * @param pollIntervalMs how often to poll the device for state (default 60 s)\n */\n public constructor(\n private readonly deviceId: string,\n private readonly deps: XmlControllerDeps,\n private readonly pollIntervalMs: number = DEFAULT_POLL_INTERVAL_MS,\n ) {}\n\n /**\n * Probe each zone, create the tree for the ones that answer, seed state, and\n * start the keepalive poll.\n *\n * @returns true if the main zone answered and the tree was created\n */\n public async start(): Promise<boolean> {\n // Probe all zones in parallel and keep each answering zone's status, so a zone is\n // fetched once (for the probe) and seeded from that same response \u2014 not twice.\n const probes = await Promise.all(\n XML_ZONES.map(async zone => ({ zone, status: await this.tryGetStatus(zone.element) })),\n );\n const answered = probes.filter(probe => probe.status && Object.keys(probe.status).length > 0);\n if (!answered.some(probe => probe.zone.key === \"main\")) {\n this.deps.log.debug(`${this.deviceId}: no XML main zone \u2014 creating no objects`);\n return false;\n }\n this.zones = answered.map(probe => probe.zone);\n // Freshness guard for the (persisted) probe memory: the model name is the identity\n // this transport can read. A different device behind the address drops the\n // remembered XML declarations (scenes, inputs, tuner, browse sources); a device\n // that reports no model keeps them \u2014 the YNCA/YXC guards catch a swap there.\n let model: string | undefined;\n try {\n model = await this.deps.client.getModelName();\n if (model !== undefined && this.deps.probeMemory) {\n if (this.deps.probeMemory.remembered(\"xmlModel\") !== model) {\n // Every XML-owned memory key carries the xml prefix (xmlBrowseSources,\n // xmlScenes:*, xmlInputs:*, xmlTuner, xmlModel).\n this.deps.probeMemory.drop(key => key.startsWith(\"xml\"));\n this.deps.probeMemory.set(\"xmlModel\", model);\n }\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getModelName failed (${errorMessage(e)})`);\n }\n // The zone's own input list (`Input_Sel_Item`, per zone \u2014 Main and Zone 2 differ on\n // real hardware): the device says which inputs it accepts, so the input state gets a\n // dropdown instead of a free string. Constant per model \u2014 remembered per device.\n const inputsByZone = new Map<string, string[]>();\n for (const zone of this.zones) {\n const body = await this.probeXml(\n `xmlInputs:${zone.key}`,\n zone.element,\n \"<Input><Input_Sel_Item>GetParam</Input_Sel_Item></Input>\",\n );\n inputsByZone.set(zone.key, parseInputList(body));\n }\n // Claim with proof, XML edition (2.0.1): only the states whose Basic_Status field\n // this device DELIVERS are created \u2014 a blind full-catalog rollout left valueless\n // objects (hdmi.out2, sound.direct, \u2026) standing on devices without the feature.\n // The delivered field set is a model property, remembered per zone (union, so a\n // later standby start \u2014 which may report fewer fields \u2014 cannot shrink the tree).\n for (const { zone, status } of answered) {\n const key = `xmlStatusFields:${zone.key}`;\n const remembered = this.deps.probeMemory?.remembered<string[]>(key);\n const fields = new Set<string>(Array.isArray(remembered) ? remembered : []);\n for (const field of Object.keys(status ?? {})) {\n fields.add(field);\n }\n this.deps.probeMemory?.set(key, [...fields]);\n this.zoneFields.set(zone.key, fields);\n }\n // Every parent \u2014 the zone channels included \u2014 is created by the per-state loop below\n // and named from the shared CHANNEL_NAME_KEYS table (a zone that answered has at least\n // its power state, so its channel always comes into being this way).\n const createdChannels = new Set<string>();\n for (const zone of this.zones) {\n for (const entry of XML_AMP_CATALOG) {\n // Main/system-wide features (scenes, HDMI outputs, party) exist only on the main zone.\n if (entry.mainOnly && zone.key !== \"main\") {\n continue;\n }\n // Claim with proof: skip what this device's status never delivered.\n if (entry.statusField !== undefined && !this.zoneFields.get(zone.key)?.has(entry.statusField)) {\n continue;\n }\n const stateId = `${zone.prefix}${entry.state}`;\n // A dotted state (e.g. scene.recall) needs its parent channel created first.\n const segments = stateId.split(\".\");\n for (let i = 1; i < segments.length; i++) {\n const channelId = segments.slice(0, i).join(\".\");\n if (!createdChannels.has(channelId)) {\n createdChannels.add(channelId);\n await this.deps.upsertObject(`${this.deviceId}.${channelId}`, {\n id: channelId,\n type: \"channel\",\n common: {\n // Capitalised like the catalog path does it, so the same folder cannot end up\n // called \"sound\" here and \"Sound\" there depending on which transport owns it.\n name: CHANNEL_NAME_KEYS[segments[i - 1]]\n ? tName(CHANNEL_NAME_KEYS[segments[i - 1]])\n : segments[i - 1].charAt(0).toUpperCase() + segments[i - 1].slice(1),\n },\n });\n }\n }\n const { nameKey, descKey, ...rest } = entry.common;\n const common: ObjectDef[\"common\"] = {\n ...rest,\n name: tName(nameKey),\n // An absent key means the datapoint explains itself \u2014 the fleet standard wants the\n // field empty there rather than filled with invented prose.\n ...(descKey ? { desc: tName(descKey) } : {}),\n };\n // The device's own input list becomes the dropdown (XML-owned devices only \u2014\n // where YNCA is present its dropdown wins via the owner policy).\n const inputs = entry.state === \"input\" ? inputsByZone.get(zone.key) : undefined;\n if (inputs && inputs.length > 0) {\n common.states = Object.fromEntries(inputs.map(input => [input, input]));\n }\n await this.deps.upsertObject(`${this.deviceId}.${stateId}`, {\n id: stateId,\n type: \"state\",\n common,\n });\n this.createdStates.add(stateId);\n }\n }\n await this.setupScenes(createdChannels);\n await this.setupTuner(createdChannels);\n // Seed from the statuses already fetched during the probe \u2014 no second round-trip.\n for (const { zone, status } of answered) {\n if (status) {\n this.seedZone(zone, status);\n }\n }\n // The model name (already read by the freshness guard) for the device-manager card.\n // Best-effort \u2014 a device that does not report it still connects, the line stays empty.\n if (model) {\n // The info channel and info.model already exist \u2014 the adapter creates them for\n // every device up front, so the card renders even while the device is offline.\n this.emit(\"info.model\", model);\n }\n await this.setupBrowse();\n this.cancelKeepalive = this.deps.scheduleKeepalive(() => void this.keepalive(), this.pollIntervalMs);\n // The adapter logs one combined \"ready\" line across all transports; this stays at debug.\n this.deps.log.debug(`${this.deviceId}: Yamaha (XML) device ready (XML)`);\n return true;\n }\n\n /**\n * Read one element's list once per device: the answer is a property of the MODEL\n * (input lists, scene declarations), so reconnects reuse it via the probe memory.\n *\n * Only a DEFINITE answer is remembered: a body, or the model's own \"no such node\"\n * (bodyless HTTP 400 / return code 2, both captured on the RX-V6A) as \"declares none\".\n * A transient failure \u2014 timeout, connection error, HTTP 5xx, or a state-dependent\n * refusal (return code 3/4, \"not now\") \u2014 is NOT remembered: before this, one busy\n * moment during the first contact recorded \"no scenes\" for that device for good, until\n * the model changed. Now it is simply asked again on the next connect.\n *\n * @param key the probe-memory key\n * @param element the XML element to ask\n * @param inner the inner GET request\n * @returns the raw response body, or \"\" when the device (definitely or for now) has none\n */\n private async probeXml(key: string, element: string, inner: string): Promise<string> {\n const probe = async (): Promise<string> => {\n let body: string;\n try {\n body = await this.deps.client.getXml(element, inner);\n } catch (e) {\n if (isPermanentXmlRefusal(e)) {\n return \"\"; // the model has no such node \u2014 definite\n }\n throw e; // transient \u2014 not remembered\n }\n const rc = parseReturnCode(body);\n if (rc !== undefined && rc !== 0) {\n if (rc === 2) {\n return \"\"; // RC 2 = the node does not exist on this model \u2014 definite\n }\n throw new Error(`device refused ${element} probe (RC=${rc})`); // \"not now\" \u2014 not remembered\n }\n return body;\n };\n try {\n return this.deps.probeMemory ? await this.deps.probeMemory.once(key, probe) : await probe();\n } catch (e) {\n this.deps.log.debug(\n `${this.deviceId}: ${key} probe failed, asking again on the next connect (${errorMessage(e)})`,\n );\n return \"\";\n }\n }\n\n /**\n * Build the scene surface from the device's OWN declaration (#615): each zone's\n * `<Scene_Sel_Item>` names the scenes that exist, their titles and the write value\n * (`Scene N` via `<Scene_Sel>`). The predecessor blindly sent `Scene_Load` to a\n * fixed 1..12 main-zone state; the capture shows the device declaring `Scene_Sel`\n * instead \u2014 and declaring scenes for Zone 2 too.\n *\n * @param createdChannels the channel ids already created (extended here)\n */\n private async setupScenes(createdChannels: Set<string>): Promise<void> {\n for (const zone of this.zones) {\n const body = await this.probeXml(\n `xmlScenes:${zone.key}`,\n zone.element,\n \"<Scene><Scene_Sel_Item>GetParam</Scene_Sel_Item></Scene>\",\n );\n const scenes = parseSceneList(body);\n if (scenes.length === 0) {\n continue;\n }\n this.scenesByZone.set(zone.key, scenes);\n const channelId = `${zone.prefix}scene`;\n if (!createdChannels.has(channelId)) {\n createdChannels.add(channelId);\n await this.deps.upsertObject(`${this.deviceId}.${channelId}`, {\n id: channelId,\n type: \"channel\",\n common: { name: tName(CHANNEL_NAME_KEYS.scene ?? \"Scenes\") },\n });\n }\n const max = Math.max(...scenes.map(scene => scene.num));\n await this.deps.upsertObject(`${this.deviceId}.${channelId}.recall`, {\n id: `${channelId}.recall`,\n type: \"state\",\n common: {\n name: tName(\"recallScene\"),\n desc: tName(\"descRecallScene\"),\n type: \"number\",\n role: \"level\",\n read: true,\n write: true,\n min: 1,\n max,\n step: 1,\n // The declared titles as the dropdown, so the picker shows \"Movie Viewing\",\n // not a bare number.\n states: Object.fromEntries(scenes.map(scene => [scene.num, scene.title])),\n },\n });\n // ONE list state instead of a name datapoint per scene (v2.0.0): visualizations\n // read titles as VALUES (button captions \u2014 the #613 reporter's setup), and a\n // dropdown's labels are not readable, so the list carries them.\n await this.deps.upsertObject(`${this.deviceId}.${channelId}.list`, {\n id: `${channelId}.list`,\n type: \"state\",\n common: {\n name: tName(\"scenesNumberTitle\"),\n desc: tName(\"descScenesNumberTitle\"),\n type: \"string\",\n role: \"json\",\n read: true,\n write: false,\n },\n });\n this.emit(`${channelId}.list`, JSON.stringify(scenes));\n }\n }\n\n /**\n * Build the classic tuner surface (pre-2010 devices, where XML is the ONLY\n * transport \u2014 the predecessor served their tuner, the rewrite had dropped it).\n * Existence is probed once per device; the preset write is the openHAB-verified\n * `<Play_Control><Preset><Preset_Sel>`; frequency/RDS/tuned are read-only from\n * Play_Info. On newer devices YNCA/YXC own these ids via the owner policy.\n *\n * @param createdChannels the channel ids already created (extended here)\n */\n private async setupTuner(createdChannels: Set<string>): Promise<void> {\n const probe = await this.probeXml(\"xmlTuner\", \"Tuner\", \"<Play_Info>GetParam</Play_Info>\");\n if (probe.length === 0) {\n return;\n }\n this.hasTuner = true;\n if (!createdChannels.has(\"tuner\")) {\n createdChannels.add(\"tuner\");\n await this.deps.upsertObject(`${this.deviceId}.tuner`, {\n id: \"tuner\",\n type: \"channel\",\n common: { name: tName(CHANNEL_NAME_KEYS.tuner ?? \"Tuner\") },\n });\n }\n const state = async (id: string, common: ObjectDef[\"common\"]): Promise<void> => {\n await this.deps.upsertObject(`${this.deviceId}.tuner.${id}`, { id: `tuner.${id}`, type: \"state\", common });\n };\n await state(\"preset\", {\n name: tName(\"presetRecallByNumber\"),\n desc: tName(\"descPresetRecallByNumber\"),\n type: \"number\",\n role: \"level\",\n read: true,\n write: true,\n // Slot 1 upwards \u2014 `handleTunerWrite` drops a 0, so offering it as the lower bound\n // invited a write that goes nowhere.\n min: 1,\n max: 40,\n step: 1,\n });\n await state(\"frequency\", {\n name: tName(\"frequency\"),\n type: \"number\",\n role: \"value\",\n unit: \"kHz\",\n read: true,\n write: false,\n });\n await state(\"rdsService\", {\n name: tName(\"rdsStation\"),\n desc: tName(\"descRdsStation\"),\n type: \"string\",\n role: \"text\",\n read: true,\n write: false,\n });\n await state(\"rdsText\", {\n name: tName(\"rdsText\"),\n desc: tName(\"descRdsText\"),\n type: \"string\",\n role: \"text\",\n read: true,\n write: false,\n });\n await state(\"tuned\", {\n name: tName(\"tunedToAStation\"),\n desc: tName(\"descTunedToAStation\"),\n type: \"boolean\",\n role: \"indicator\",\n read: true,\n write: false,\n });\n await state(\"stereo\", {\n name: tName(\"stereoReception\"),\n desc: tName(\"descStereoReception\"),\n type: \"boolean\",\n role: \"indicator\",\n read: true,\n write: false,\n });\n // NOT `emitTunerInfo(probe)`: the probe body comes out of the PERSISTED memory on every\n // reconnect and restart, so seeding from it published a snapshot of an earlier session\n // \u2014 frequency, RDS station and text, \"tuned\" \u2014 as the CURRENT reading, until the first\n // poll up to a whole interval later. The existence verdict is a model property and stays\n // remembered; the values are read fresh. (Same class as the menu's resting shape, which\n // showed rows six days older than the connection until it was fixed.)\n await this.refreshTuner();\n }\n\n /**\n * Write the tuner states from a Play_Info response.\n *\n * @param xml the Play_Info response body\n */\n private emitTunerInfo(xml: string): void {\n const info = parseTunerInfo(xml);\n if (info.preset !== undefined) {\n this.emit(\"tuner.preset\", info.preset);\n }\n if (info.frequency !== undefined) {\n // Unified kHz (v2.0.0): the device reports FM in MHz, AM in kHz \u2014 normalize.\n this.emit(\"tuner.frequency\", Math.round(info.frequencyUnit === \"MHz\" ? info.frequency * 1000 : info.frequency));\n }\n if (info.rdsService !== undefined) {\n this.emit(\"tuner.rdsService\", info.rdsService);\n }\n if (info.rdsText !== undefined) {\n this.emit(\"tuner.rdsText\", info.rdsText);\n }\n if (info.tuned !== undefined) {\n this.emit(\"tuner.tuned\", info.tuned);\n }\n if (info.stereo !== undefined) {\n this.emit(\"tuner.stereo\", info.stereo);\n }\n }\n\n /**\n * Poll the tuner's Play_Info (keepalive) and write the states.\n */\n private async refreshTuner(): Promise<void> {\n try {\n this.emitTunerInfo(await this.deps.client.getXml(\"Tuner\", \"<Play_Info>GetParam</Play_Info>\"));\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: tuner Play_Info failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * A user write to `tuner.preset` \u2192 the openHAB-verified preset recall.\n *\n * @param stateId the state id relative to the device\n * @param value the written value\n * @returns true when the id was the tuner preset (handled here)\n */\n private handleTunerWrite(stateId: string, value: unknown): boolean {\n if (stateId !== \"tuner.preset\" || !this.hasTuner) {\n return stateId === \"tuner.preset\";\n }\n const num = Math.round(Number(value));\n if (!Number.isFinite(num) || num < 1) {\n return true;\n }\n void this.applyCommand({\n zone: \"Tuner\",\n inner: `<Play_Control><Preset><Preset_Sel>${num}</Preset_Sel></Preset></Play_Control>`,\n });\n return true;\n }\n\n /**\n * A user write to a zone's `scene.recall` \u2192 the DECLARED write element\n * (`<Scene><Scene_Sel>Scene N</Scene_Sel></Scene>`). Only zones that declared\n * scenes accept the write; a refusal lands in the log via applyCommand.\n *\n * @param stateId the state id relative to the device\n * @param value the written value\n * @returns true when the id was a scene recall (handled here)\n */\n private handleSceneWrite(stateId: string, value: unknown): boolean {\n const match = /^(?:multiroom\\.(zone[234])\\.)?scene\\.recall$/.exec(stateId);\n if (!match) {\n return false;\n }\n const zoneKey = match[1] ?? \"main\";\n const zone = this.zones.find(z => z.key === zoneKey);\n const scenes = this.scenesByZone.get(zoneKey);\n // A TITLE is as valid a write as a number (\"Movie Viewing\" \u2192 Scene 1).\n const byTitle =\n typeof value === \"string\" && !/^\\d+$/.test(value.trim())\n ? scenes?.find(scene => scene.title.toLowerCase() === value.trim().toLowerCase())?.num\n : undefined;\n const num = byTitle ?? Math.round(Number(value));\n if (!zone || !scenes || !scenes.some(scene => scene.num === num)) {\n return true;\n }\n void this.applyCommand({ zone: zone.element, inner: `<Scene><Scene_Sel>Scene ${num}</Scene_Sel></Scene>` });\n return true;\n }\n\n /**\n * Create the browsing surface (#613) when at least one source answers a List_Info\n * probe (NET_RADIO/SERVER/USB \u2014 the menus the predecessor adapter's users drove\n * via `Realtime.*.LINE1TXT` + `xmlCommand`). Skipped without a delay dep (older tests).\n */\n private async setupBrowse(): Promise<void> {\n const gate = this.deps.gate;\n if (!gate) {\n return;\n }\n const delay = (ms: number): Promise<void> => gate.delay(ms);\n // Which sources have a menu is a property of the MODEL, not of this connection \u2014 ask\n // once per device instead of costing three extra requests (up to five seconds on a\n // receiver that has no menus at all) on every single reconnect.\n const probe = async (): Promise<string[]> => {\n const probes = await Promise.all(\n XML_BROWSE_SOURCES.map(async source => {\n try {\n const body = await this.deps.client.getXml(source.element, \"<List_Info>GetParam</List_Info>\");\n return body.includes(\"<Menu_Status>\") ? source.key : undefined;\n } catch (e) {\n if (isPermanentXmlRefusal(e)) {\n return undefined; // this model has no menu for that source (bodyless HTTP 400)\n }\n throw e; // transient \u2014 \"no menus\" must not be remembered for good\n }\n }),\n );\n return probes.filter((key): key is string => key !== undefined);\n };\n let available: Set<string>;\n try {\n available = new Set(\n this.deps.probeMemory ? await this.deps.probeMemory.once(\"xmlBrowseSources\", probe) : await probe(),\n );\n } catch (e) {\n this.deps.log.debug(\n `${this.deviceId}: browse probe failed, asking again on the next connect (${errorMessage(e)})`,\n );\n return;\n }\n if (available.size === 0) {\n return;\n }\n const driver = new XmlBrowseDriver(this.deps.client, available, delay);\n this.browseEngine = await createBrowseSurface(driver, this.deviceId, {\n upsertObject: this.deps.upsertObject,\n emit: (id, value) => this.emit(id, value),\n log: this.deps.log,\n delay,\n });\n }\n\n /**\n * Write a device-originated value \u2014 but never after the connection was closed. A poll\n * that was already in flight when the adapter stopped would otherwise still write into\n * a tree that is being torn down.\n *\n * @param relativeId the state id relative to the device\n * @param value the value to write\n */\n private emit(relativeId: string, value: boolean | number | string): void {\n if (this.deps.gate?.closed) {\n return;\n }\n this.deps.setStateAck(`${this.deviceId}.${relativeId}`, value);\n }\n\n /**\n * Handle a state change: a user write (ack false) becomes an XML command; an\n * acked change (the device's own echo) is ignored.\n *\n * @param fullStateId the full state id (device id + \".\" + state)\n * @param ack whether the change is acked (device-originated)\n * @param value the new value\n */\n public handleStateChange(fullStateId: string, ack: boolean, value: unknown): void {\n if (ack) {\n return;\n }\n const prefix = `${this.deviceId}.`;\n if (!fullStateId.startsWith(prefix)) {\n return;\n }\n const stateId = fullStateId.slice(prefix.length);\n if (stateId.startsWith(\"remote.\")) {\n this.browseEngine?.handleRemoteWrite(stateId, value);\n return;\n }\n if (stateId.startsWith(\"player.browse.\")) {\n this.browseEngine?.handleWrite(stateId, value);\n return;\n }\n // Scenes and the classic tuner are device-declared (not in the static catalog).\n if (this.handleSceneWrite(stateId, value)) {\n return;\n }\n if (this.handleTunerWrite(stateId, value)) {\n return;\n }\n // Claim with proof, on the WRITE way too. Object creation has been proof-gated since\n // 2.0.1 (only fields this device's Basic_Status really delivers), but the write path was\n // not \u2014 the comment on `createdStates` claimed otherwise while it guarded the read side\n // alone. XML was the last transport without it: YNCA writes only through its per-device\n // write map, MusicCast only through device-declared endpoints. It bites on a datapoint an\n // adapter version before 2.0.1 created and that once carried a value, so no sweep removes\n // it: writing it put a blind command on the wire that the device answers with a refusal.\n if (!this.createdStates.has(stateId)) {\n this.deps.log.debug(`${this.deviceId}: ${stateId} was not reported by this device \u2014 write dropped`);\n return;\n }\n const command = stateToXml(stateId, value);\n if (command) {\n void this.applyCommand(command);\n }\n }\n\n /**\n * Register the supervisor's drop handler. XML has no push/socket-drop event, so a\n * drop is inferred from a run of failed polls (see keepalive).\n *\n * @param cb invoked once when the device is judged gone\n */\n public onDrop(cb: (reason?: Error) => void): void {\n this.dropDetector.onDrop(cb);\n }\n\n /** Cancel the keepalive poll. Synchronous \u2014 safe to call from onUnload. */\n public close(): void {\n this.browseEngine?.close();\n // Closing the gate empties its queue and aborts its signal: queued requests are\n // dropped and every pending wait ends, so nothing writes after the teardown.\n this.deps.gate?.close();\n this.cancelKeepalive?.();\n this.cancelKeepalive = undefined;\n }\n\n /**\n * Poll every live zone. If every zone fails for three consecutive failed polls in a\n * row, the device is judged gone and a drop is reported so the supervisor reconnects.\n */\n private async keepalive(): Promise<void> {\n // The keepalive is an async handler on an adapter timer: a rejection here is an\n // UNHANDLED rejection, and js-controller turns those into an adapter stop. Every step\n // below catches for itself today, so the guard is what makes that a guarantee instead\n // of something the next change has to remember.\n try {\n let anyOk = false;\n for (const zone of this.zones) {\n if (await this.refreshZone(zone)) {\n anyOk = true;\n }\n }\n if (this.hasTuner) {\n await this.refreshTuner();\n }\n this.dropDetector.record(anyOk);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: keepalive poll failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Fetch a zone's status and write its amp states with ack.\n *\n * @param zone the zone to refresh\n * @returns true if the status was fetched, false if the request failed\n */\n private async refreshZone(zone: XmlZone): Promise<boolean> {\n const status = await this.tryGetStatus(zone.element);\n if (!status) {\n return false;\n }\n this.seedZone(zone, status);\n return true;\n }\n\n /**\n * Write a zone's amp states from an already-fetched Basic_Status (used to seed\n * from the start-up probe without a second round-trip).\n *\n * @param zone the zone the status belongs to\n * @param status the parsed Basic_Status\n */\n private seedZone(zone: XmlZone, status: BasicStatus): void {\n // A field the device delivers for the FIRST time mid-run has no object yet\n // (claim-with-proof creates only proven fields at start): remember it \u2014 the next\n // start creates it \u2014 and skip the write, so no state lands without an object.\n const known = this.zoneFields.get(zone.key);\n if (known) {\n let grew = false;\n for (const field of Object.keys(status)) {\n if (!known.has(field)) {\n known.add(field);\n grew = true;\n }\n }\n if (grew) {\n this.deps.probeMemory?.set(`xmlStatusFields:${zone.key}`, [...known]);\n }\n }\n for (const update of parseXmlStatus(status, zone.key)) {\n if (this.createdStates.has(update.id)) {\n this.emit(update.id, update.value);\n }\n }\n }\n\n /**\n * Read a zone's status, swallowing errors (an absent zone or an offline device).\n *\n * @param element the XML zone element\n * @returns the parsed status, or undefined on failure\n */\n private async tryGetStatus(element: string): Promise<BasicStatus | undefined> {\n try {\n return await this.deps.client.getStatus(element);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getStatus(${element}) failed: ${errorMessage(e)}`);\n return undefined;\n }\n }\n\n /**\n * Send a mapped command to the device.\n *\n * @param command the XML command to apply\n */\n private async applyCommand(command: XmlCommand): Promise<void> {\n try {\n await this.deps.client.send(command.zone, command.inner);\n } catch (e) {\n this.deps.log.warn(`${this.deviceId}: XML command failed: ${errorMessage(e)}`);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkD;AAClD,kBAAsB;AACtB,sBAQO;AACP,4BAA4D;AAC5D,qBAAgC;AAEhC,kBAA6B;AAC7B,gCAAiC;AAIjC,qBAAoC;AACpC,+BAAoD;AAGpD,MAAM,2BAA2B,KAAK;AAWtC,MAAM,YAAuB;AAAA,EAC3B,EAAE,KAAK,QAAQ,SAAS,aAAa,QAAQ,GAAG;AAAA,EAChD,EAAE,KAAK,SAAS,SAAS,UAAU,QAAQ,mBAAmB;AAAA,EAC9D,EAAE,KAAK,SAAS,SAAS,UAAU,QAAQ,mBAAmB;AAAA,EAC9D,EAAE,KAAK,SAAS,SAAS,UAAU,QAAQ,mBAAmB;AAChE;AAyCO,MAAM,oBAAgD;AAAA;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AV,mBAAuB,IAAI,mBAAmB,KAAK,GAAG,IAAI,CAAC,GAAG,KAAK;AAAA,MACrE;AAAA,IACF;AACA,eAAW,cAAU,sCAAe,QAAQ,KAAK,GAAG,GAAG;AACrD,UAAI,KAAK,cAAc,IAAI,OAAO,EAAE,GAAG;AACrC,aAAK,KAAK,OAAO,IAAI,OAAO,KAAK;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAc,aAAa,SAAmD;AAC5E,QAAI;AACF,aAAO,MAAM,KAAK,KAAK,OAAO,UAAU,OAAO;AAAA,IACjD,SAAS,GAAG;AACV,WAAK,KAAK,IAAI,MAAM,GAAG,KAAK,QAAQ,eAAe,OAAO,iBAAa,0BAAa,CAAC,CAAC,EAAE;AACxF,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAc,aAAa,SAAoC;AAC7D,QAAI;AACF,YAAM,KAAK,KAAK,OAAO,KAAK,QAAQ,MAAM,QAAQ,KAAK;AAAA,IACzD,SAAS,GAAG;AACV,WAAK,KAAK,IAAI,KAAK,GAAG,KAAK,QAAQ,6BAAyB,0BAAa,CAAC,CAAC,EAAE;AAAA,IAC/E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -600,7 +600,14 @@ class YxcDeviceController {
|
|
|
600
600
|
await this.deps.upsertObject(`${this.deviceId}.${id}`, {
|
|
601
601
|
id,
|
|
602
602
|
type: "state",
|
|
603
|
-
common: {
|
|
603
|
+
common: {
|
|
604
|
+
name: (0, import_i18n.tName)("scenesNumberTitle"),
|
|
605
|
+
desc: (0, import_i18n.tName)("descScenesNumberTitle"),
|
|
606
|
+
type: "string",
|
|
607
|
+
role: "json",
|
|
608
|
+
read: true,
|
|
609
|
+
write: false
|
|
610
|
+
}
|
|
604
611
|
});
|
|
605
612
|
this.emit(id, JSON.stringify(list));
|
|
606
613
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/yxc/device-controller.ts"],
|
|
4
|
-
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { parseYxcFeatures, type YxcCapabilities, type YxcTunerFeatures } from \"./capability\";\nimport { mapYxcToObjects } from \"./object-mapper\";\nimport {\n parseYxcClock,\n parseYxcDistribution,\n parseYxcPlayInfo,\n parseYxcPlaylistNames,\n parseYxcPlayQueue,\n parseYxcPresetList,\n parseYxcRecentList,\n parseYxcSignalInfo,\n parseYxcStatus,\n parseYxcTunerInfo,\n parseYxcTunerPresetLists,\n PLAYER_CLEAR,\n stateToYxc,\n type PlayerTransport,\n type YxcCommand,\n} from \"./command-mapper\";\nimport { mediaToRefresh, netusbListsToRefresh, zonesToRefresh } from \"./push\";\nimport type { ObjectDef } from \"../catalog/types\";\nimport { tName } from \"../i18n\";\nimport type { StateValue } from \"../types\";\nimport type { ConnectionHandle, ControllerLog } from \"../controller\";\nimport { errorMessage } from \"../util\";\nimport { PollDropDetector } from \"../lifecycle/poll-drop-detector\";\nimport type { ProbeMemory } from \"../lifecycle/probe-memory\";\nimport { zonePrefix } from \"./zones\";\nimport { knownScenes, resolveSceneNumber } from \"../catalog/scene-titles\";\nimport type { CommandGate } from \"../lifecycle/command-gate\";\nimport type { BrowseEngine } from \"../browse/browse-engine\";\nimport { createBrowseSurface } from \"../browse/surface\";\nimport { YxcBrowseDriver } from \"../browse/yxc-browse-driver\";\n\n/** Renew interval for the push registration + state poll, well under the ~20 min expiry. */\nconst KEEPALIVE_MS = 5 * 60 * 1000;\n\n/**\n * With push working, run the full media/list/group sweep only every Nth keepalive (6 \u00D7 5 min\n * = every 30 minutes) \u2014 a safety net against a dropped UDP packet, not the primary path.\n */\nconst PUSH_MODE_FULL_SWEEP_EVERY = 6;\n\n/**\n * Extract the model name from a getDeviceInfo response, if it carries a non-empty one.\n *\n * @param deviceInfo the getDeviceInfo response\n * @returns the model name, or undefined\n */\nfunction modelNameFrom(deviceInfo: unknown): string | undefined {\n const model = (deviceInfo as { model_name?: unknown } | null)?.model_name;\n return typeof model === \"string\" && model.length > 0 ? model : undefined;\n}\n\n/**\n * Extract the name a user gave this device from a getNameText response.\n *\n * MusicCast keeps it as the main zone's text \u2014 that is the name shown in the app and\n * the one people recognise (\"Wohnzimmer\"). A device whose zone was never renamed\n * answers with a generic zone name; the caller filters those out.\n *\n * @param nameText the getNameText response\n * @returns the main zone's text, or undefined\n */\nexport function zoneNameFrom(nameText: unknown): string | undefined {\n const zones = (nameText as { zone_list?: unknown } | null)?.zone_list;\n if (!Array.isArray(zones)) {\n return undefined;\n }\n for (const zone of zones) {\n if (typeof zone !== \"object\" || zone === null) {\n continue;\n }\n const { id, text } = zone as { id?: unknown; text?: unknown };\n if (id === \"main\" && typeof text === \"string\" && text.trim().length > 0) {\n return text.trim();\n }\n }\n return undefined;\n}\n\nimport type { YxcClientLike } from \"./client-contract\";\n\n// Re-exported so existing importers (the tests' fakes) keep resolving it from here.\nexport type { YxcClientLike };\n\n/** The adapter callbacks the controller drives \u2014 narrow, so no adapter mock is needed in tests. */\nexport interface YxcControllerDeps {\n /** The YXC (MusicCast) client for this device. */\n client: YxcClientLike;\n /** Resolve another configured device's client by IP, for forming a multiroom group. */\n clientFor?: (ip: string) => YxcClientLike | undefined;\n /** Register a push handler for this device (by IP); returns a function that unregisters it. */\n registerPush(onPush: (event: unknown) => void): () => void;\n /**\n * Whether the shared push receiver is actually listening. With push the device reports\n * its own changes, so the keepalive only has to renew the subscription and refresh the\n * zone status; without it (the port is taken \u2014 see issue #611) the poll is the ONLY\n * source of change and has to cover everything. Absent = assume no push.\n */\n pushActive?(): boolean;\n /** Per-device memory for answers that do not change while the device runs (see ProbeMemory). */\n probeMemory?: ProbeMemory;\n /** Schedule the keepalive handler; returns a function that cancels it. */\n scheduleKeepalive(handler: () => void, ms: number): () => void;\n /** Create or update an object in the device tree. */\n upsertObject(id: string, def: ObjectDef): Promise<void>;\n /** Write a state value with ack (device-originated). */\n setStateAck(id: string, value: boolean | number | string): void;\n /** Report the name the device carries for itself, for the device object's label. */\n reportDeviceName?(name: string): void;\n /** Adapter log. */\n log: ControllerLog;\n /**\n * The device's command gate: every request is paced through it, and its signal is the\n * connection's shutdown flag \u2014 a closed gate ends pending waits and stops state writes\n * from a poll that was already in flight. Absent in older tests \u2192 no browsing.\n */\n gate?: CommandGate;\n}\n\n/**\n * Drives one MusicCast (YXC) device: read capabilities, build the object tree,\n * seed state from getStatus, and route commands both ways. Device pushes arrive\n * via the shared receiver as re-fetch signals; a keepalive poll renews the push\n * registration (the fix for the musiccast \"stops updating\" bug) and doubles as\n * the poll-only fallback when the push port is unavailable. Create-only.\n */\nexport class YxcDeviceController implements ConnectionHandle {\n private zones: string[] = [];\n private mediaBlocks: string[] = [];\n private cancelKeepalive: (() => void) | undefined;\n private cancelPush: (() => void) | undefined;\n private readonly dropDetector = new PollDropDetector();\n /** The tuner's current band, cached so a frequency write can supply it (setFreq needs band + freq). */\n private lastTunerBand = \"fm\";\n /** Each zone's currently selected input, from its status \u2014 see {@link zoneListeningTo}. */\n private readonly lastZoneInput = new Map<string, string>();\n /** The source the network player is currently on (netusb `input`, e.g. \"net_radio\"). */\n private lastNetusbInput = \"\";\n /** Which source currently feeds each zone's \"now playing\" block (v2.0.0 routing). */\n private readonly zonePlayerBlock = new Map<string, \"netusb\" | \"cd\">();\n /** Each zone's last-seen equalizer bands, cached so one band write can supply the other two. */\n private readonly lastEqualizer = new Map<string, { low: number; mid: number; high: number }>();\n /** Whether the device reports MusicCast-Link distribution (gates the dist poll and objects). */\n private hasDistribution = false;\n /** The device's last-seen distribution role (none/server/client), for the leave-group path. */\n private lastDistRole = \"none\";\n /** The tuner features (bands + preset mode) \u2014 a preset recall needs the band. */\n private tunerFeatures: YxcTunerFeatures | undefined;\n /** Whether the device reports the clock/alarm block (gates the clock poll). */\n private hasClock = false;\n /** The zones declaring `signal_info` (gates the audio-signal poll). */\n private signalZones: string[] = [];\n /** Whether netusb declares the MusicCast playlists / the play queue (gates their polls). */\n private hasMcPlaylist = false;\n private hasPlayQueue = false;\n /** Counts keepalive runs, so the safety-net sweep can run every Nth one under push. */\n private keepaliveRuns = 0;\n private browseEngine: BrowseEngine | undefined;\n\n /**\n * @param deviceId the id-safe device id (object-tree path segment)\n * @param deps the client and adapter callbacks\n */\n public constructor(\n private readonly deviceId: string,\n private readonly deps: YxcControllerDeps,\n ) {}\n\n /**\n * Read capabilities, create the object tree, seed state, and wire up push +\n * keepalive.\n *\n * @returns true if the device reported capabilities and its tree was created\n */\n public async start(): Promise<boolean> {\n // Freshness guard for the (persisted) probe memory: ONE LIVE getDeviceInfo proves\n // the device behind this address is still the one the memory was learned from. A\n // swapped or factory-reset device answers a different identity \u2014 its remembered\n // YXC answers are dropped and re-probed; a transient failure keeps the memory and\n // leaves the liveness verdict to the zone check below. Also feeds the model line.\n let model: string | undefined;\n try {\n const info = await this.deps.client.getDeviceInfo();\n model = modelNameFrom(info);\n const version = (info as { system_version?: unknown } | null)?.system_version;\n const identity = `${model ?? \"\"}|${typeof version === \"number\" || typeof version === \"string\" ? version : \"\"}`;\n if (this.deps.probeMemory && this.deps.probeMemory.remembered(\"yxcIdentity\") !== identity) {\n this.deps.probeMemory.drop(\n key => key === \"features\" || key === \"name\" || key === \"model\" || key === \"yxcIdentity\",\n );\n this.deps.probeMemory.set(\"yxcIdentity\", identity);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getDeviceInfo failed (${errorMessage(e)})`);\n }\n // Capabilities and name are constant while the device runs, so on a reconnect \u2014\n // and, persisted, on a restart \u2014 they come from the per-device memory instead of\n // costing more round-trips on a connection that is being (re-)established anyway.\n // A capability set with no zone at all is not a MusicCast device answering \u2014 it is a\n // truncated or malformed answer. Returned to this run, but NOT remembered: remembering\n // it would freeze the device's shape for good (every later connect reads the memory),\n // and it would also disarm the liveness check below, which needs the zones.\n const capabilities = await this.remember(\n \"features\",\n async () => parseYxcFeatures(await this.deps.client.getFeatures()),\n features => features.zones.length > 0,\n );\n const objects = mapYxcToObjects(capabilities);\n if (objects.length === 0) {\n this.deps.log.warn(`${this.deviceId}: no capabilities reported \u2014 creating no objects`);\n return false;\n }\n // Parents before children (channels before their states) \u2014 created in order.\n for (const object of objects) {\n await this.deps.upsertObject(`${this.deviceId}.${object.id}`, object);\n }\n await this.setupSceneLists(capabilities);\n // The DAB scan counters are the one DAB detail the device reports only after a\n // station scan (status stays not_ready before) \u2014 seed the documented start state\n // (nothing scanned) so they are not left as valueless read states; a real scan\n // result overwrites them via the tuner play info.\n if (capabilities.media.includes(\"tuner\") && (capabilities.tuner?.bands ?? []).includes(\"dab\")) {\n this.emit(\"tuner.dab.totalStations\", 0);\n this.emit(\"tuner.dab.scanProgress\", 0);\n }\n if (model) {\n // The info channel and info.model already exist \u2014 the adapter creates them for\n // every device up front, so the card renders even while the device is offline.\n this.emit(\"info.model\", model);\n }\n // The name the user gave the device in the MusicCast app. Best-effort like the model\n // above: an older device that does not answer getNameText simply keeps its label.\n if (this.deps.reportDeviceName) {\n try {\n const name = await this.remember(\"name\", async () => zoneNameFrom(await this.deps.client.getNameText()));\n if (name) {\n this.deps.reportDeviceName(name);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getNameText failed (${errorMessage(e)})`);\n }\n }\n this.zones = capabilities.zones.map(zone => zone.id);\n // Zones in parallel \u2014 disjoint writes, and a zone stuck in its timeout must not hold\n // up the device's readiness.\n const zonesAnswered = await Promise.all(this.zones.map(zone => this.refreshZone(zone)));\n // The zone status is the one request of this start that ALWAYS goes to the device: the\n // capabilities above come from the probe memory on every reconnect, and model/name are\n // best-effort, so nothing before this point can tell a live device from a dead one. Without\n // the check a reconnect to a receiver that had lost power still reported \"ready \u2014\n // MusicCast \u2713\" out of memory while YNCA and XML failed honestly, and info.connection stayed\n // true for a device that was not there (krobi's RX-V6A, 2026-08-26). A device that answers\n // no zone at all is gone \u2014 a standby device still answers, it just reports power=standby.\n // No `zones.length > 0` escape any more: a device that declares NO zone cannot prove it\n // is alive either, and the whole point of this check is that nothing may report \"ready\"\n // out of memory. Everything before it \u2014 capabilities, model, name \u2014 can come from the\n // persisted memory without a single request reaching the device.\n if (!zonesAnswered.some(Boolean)) {\n this.deps.log.debug(`${this.deviceId}: no zone answered getStatus \u2014 device unreachable (YXC)`);\n return false;\n }\n this.mediaBlocks = capabilities.media;\n this.tunerFeatures = capabilities.tuner;\n this.hasClock = capabilities.clock !== undefined;\n this.signalZones = capabilities.zones.filter(zone => zone.funcs.includes(\"signal_info\")).map(zone => zone.id);\n this.hasMcPlaylist = capabilities.netusbFuncs?.includes(\"mc_playlist\") ?? false;\n this.hasPlayQueue = capabilities.netusbFuncs?.includes(\"play_queue\") ?? false;\n await this.setupBrowse(capabilities);\n await this.refreshMedia();\n // Seed the WHOLE player block with its cleared shape for every zone NOT playing a\n // media source: the routing above only writes to listening zones, so on a device\n // that starts on HDMI the block would sit valueless until the first media playback\n // (live 2.0.0 deployment check \u2014 same gap the pre-release audit found for source).\n if (this.mediaBlocks.includes(\"netusb\") || this.mediaBlocks.includes(\"cd\")) {\n for (const zone of this.zones.length > 0 ? this.zones : [\"main\"]) {\n if (!this.zonePlayerBlock.has(zone)) {\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n }\n }\n await this.refreshLists();\n this.hasDistribution = capabilities.hasDistribution ?? false;\n if (this.hasDistribution) {\n await this.refreshDistribution();\n }\n this.cancelPush = this.deps.registerPush(event => this.onPush(event));\n this.cancelKeepalive = this.deps.scheduleKeepalive(() => void this.keepalive(), KEEPALIVE_MS);\n // The adapter logs one combined \"ready\" line across all transports; this stays at debug.\n this.deps.log.debug(`${this.deviceId}: MusicCast device ready (YXC)`);\n return true;\n }\n\n /**\n * Ask the device once per adapter run and remember the answer for later reconnects.\n *\n * @param key what is being remembered\n * @param probe the request to run when nothing is remembered yet\n * @param isUsable optional plausibility check \u2014 an answer it rejects is used but not remembered\n * @returns the remembered or freshly fetched value\n */\n private remember<T>(key: string, probe: () => Promise<T>, isUsable?: (value: T) => boolean): Promise<T> {\n return this.deps.probeMemory ? this.deps.probeMemory.once(key, probe, isUsable) : probe();\n }\n\n /**\n * The zone a recall should be routed to: recalling a favourite does not just start it, it\n * also switches THAT zone to the source. Sending everything to the main zone (as this did\n * before) means someone listening in zone 2 gets their favourite in the living room\n * instead \u2014 and the main zone switched away from whatever it was playing.\n *\n * The zone actually listening to the source is the right target; the main zone is the\n * fallback when nothing matches, which is also every single-zone device.\n *\n * @param source the input the recall belongs to (a network source, or \"tuner\")\n * @returns the zone to route the recall to\n */\n private zoneListeningTo(source: string): string {\n if (!source) {\n return \"main\";\n }\n // Main first: on a device where several zones share the source, it is the natural target.\n if (this.lastZoneInput.get(\"main\") === source) {\n return \"main\";\n }\n for (const [zone, input] of this.lastZoneInput) {\n if (input === source) {\n return zone;\n }\n }\n return \"main\";\n }\n\n /**\n * Write a device-originated value \u2014 but never after the connection was closed. A poll\n * or a browse fetch that was already in flight when the adapter stopped would otherwise\n * still write into a tree that is being torn down.\n *\n * @param relativeId the state id relative to the device\n * @param value the value to write\n */\n private emit(relativeId: string, value: boolean | number | string): void {\n if (this.deps.gate?.closed) {\n return;\n }\n this.deps.setStateAck(`${this.deviceId}.${relativeId}`, value);\n }\n\n /**\n * Handle a state change: a user write (ack false) becomes a YXC command; an\n * acked change (the device's own echo) is ignored to avoid a resend loop.\n *\n * @param fullStateId the full state id (device id + \".\" + state)\n * @param ack whether the change is acked (device-originated)\n * @param value the new value\n */\n public handleStateChange(fullStateId: string, ack: boolean, value: unknown): void {\n if (ack) {\n return;\n }\n const prefix = `${this.deviceId}.`;\n if (!fullStateId.startsWith(prefix)) {\n return;\n }\n const stateId = fullStateId.slice(prefix.length);\n if (stateId.startsWith(\"player.browse.\")) {\n this.browseEngine?.handleWrite(stateId, value);\n return;\n }\n // A scene TITLE resolves to its number via the shared device memory \u2014 the titles may\n // have come over XML or YNCA while MusicCast owns the recall.\n const sceneMatch = /^(?:multiroom\\.(zone[234])\\.)?scene\\.recall$/.exec(stateId);\n if (sceneMatch && typeof value === \"string\" && !/^\\d+$/.test(value.trim())) {\n const zoneKey = sceneMatch[1] ?? \"main\";\n const resolved = resolveSceneNumber(value, this.deps.probeMemory, zoneKey);\n if (resolved === undefined) {\n // Same rule as the YNCA side: a write that goes nowhere leaves a trace.\n this.deps.log.debug(\n `${this.deviceId}: scene \"${value}\" is unknown for ${zoneKey} \u2014 write dropped ` +\n `(known: ${\n knownScenes(this.deps.probeMemory, zoneKey)\n .map(scene => scene.title)\n .join(\", \") || \"none yet\"\n })`,\n );\n return;\n }\n value = resolved;\n }\n // Multiroom writes need controller state (the cached role), so they bypass the pure command map.\n if (stateId === \"multiroom.group.leave\") {\n void this.leaveGroup();\n return;\n }\n if (stateId === \"multiroom.group.linkDevice\") {\n void this.linkClient(String(value));\n return;\n }\n const command = stateToYxc(stateId, value);\n if (command) {\n void this.applyCommand(stateId, command);\n }\n }\n\n /**\n * Register the supervisor's drop handler. MusicCast has no socket-drop event, so a\n * drop is inferred from a run of failed keepalive polls (see keepalive).\n *\n * @param cb invoked once when the device is judged gone\n */\n public onDrop(cb: (reason?: Error) => void): void {\n this.dropDetector.onDrop(cb);\n }\n\n /**\n * Create the browsing surface (#613) when the device has the netusb block: the\n * `netusb/getListInfo` + `setListControl` API drives an 8-line window under\n * `player.browse.*`. Skipped without a delay dep (older tests).\n *\n * @param capabilities the parsed getFeatures capabilities\n */\n private async setupBrowse(capabilities: YxcCapabilities): Promise<void> {\n const gate = this.deps.gate;\n if (!gate || !capabilities.media.includes(\"netusb\")) {\n return;\n }\n const inputs = capabilities.zones.find(zone => zone.id === \"main\")?.inputs ?? [];\n const driver = new YxcBrowseDriver(this.deps.client, inputs);\n this.browseEngine = await createBrowseSurface(driver, this.deviceId, {\n upsertObject: this.deps.upsertObject,\n emit: (id, value) => this.emit(id, value),\n log: this.deps.log,\n delay: ms => gate.delay(ms),\n });\n }\n\n /** Cancel the keepalive and unregister the push handler. Synchronous \u2014 safe from onUnload. */\n public close(): void {\n this.browseEngine?.close();\n // Closing the gate empties its queue and aborts its signal: queued requests are\n // dropped and every pending wait ends, so nothing writes after the teardown.\n this.deps.gate?.close();\n this.cancelKeepalive?.();\n this.cancelKeepalive = undefined;\n // Unregister from the shared push receiver \u2014 otherwise a push arriving after\n // teardown would setState on a controller the adapter has already dropped.\n this.cancelPush?.();\n this.cancelPush = undefined;\n }\n\n /**\n * Handle a device push: each named zone is re-fetched via getStatus, each named\n * media source via getPlayInfo (the push itself is a change signal, not a value\n * carrier). Refreshing only the named sources keeps a track-change push from\n * re-polling every source.\n *\n * @param event the parsed push event\n */\n private onPush(event: unknown): void {\n for (const zone of zonesToRefresh(event)) {\n if (this.zones.includes(zone)) {\n void this.refreshZone(zone);\n }\n }\n for (const block of mediaToRefresh(event)) {\n if (this.mediaBlocks.includes(block)) {\n void this.refreshMediaSource(block);\n }\n }\n // The favourites/recently-played lists announce their changes as flags in the push.\n const lists = netusbListsToRefresh(event);\n if (lists.presets && this.mediaBlocks.includes(\"netusb\")) {\n void this.refreshNetusbPresets();\n }\n if (lists.recent && this.mediaBlocks.includes(\"netusb\")) {\n void this.refreshNetusbRecent();\n }\n }\n\n /**\n * Poll every zone (which renews the push registration and refreshes state) and the\n * media sources. If every zone poll fails for three consecutive failed runs in a row,\n * the device is judged gone and a drop is reported so the supervisor can flip\n * info.connection and reconnect.\n */\n private async keepalive(): Promise<void> {\n // The keepalive is an async handler on an adapter timer: a rejection here is an\n // UNHANDLED rejection, and js-controller turns those into an adapter stop. Every step\n // below catches for itself today, so the guard is what makes that a guarantee instead\n // of something the next change has to remember.\n try {\n // Zones in parallel: their writes are disjoint and one zone stuck in its timeout must\n // not delay the others (a four-zone receiver used to poll them strictly in series).\n const zones = this.zones.length > 0 ? this.zones : [\"main\"];\n const anyOk = (await Promise.all(zones.map(zone => this.refreshZone(zone)))).some(Boolean);\n // Every request above already carried the subscription headers, so the push\n // registration is renewed either way. What still has to be polled depends on whether\n // push works: with push the device announces media, list and group changes itself, so\n // the full sweep only runs occasionally as a safety net (UDP can drop a packet);\n // without push it is the only way anything ever updates.\n this.keepaliveRuns++;\n const fullSweep = !this.deps.pushActive?.() || this.keepaliveRuns % PUSH_MODE_FULL_SWEEP_EVERY === 0;\n if (fullSweep) {\n await this.refreshMedia();\n await this.refreshLists();\n if (this.hasDistribution) {\n await this.refreshDistribution();\n }\n }\n this.dropDetector.record(anyOk);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: keepalive poll failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Refresh the list-shaped surfaces: the netusb favourites and recently-played\n * lists, the tuner preset lists, and the clock/alarm settings. Each is\n * best-effort \u2014 a device without the feature answers with an error code and the\n * state simply stays.\n */\n private async refreshLists(): Promise<void> {\n if (this.mediaBlocks.includes(\"netusb\")) {\n await this.refreshNetusbPresets();\n await this.refreshNetusbRecent();\n if (this.hasMcPlaylist) {\n await this.refreshPlaylists();\n }\n if (this.hasPlayQueue) {\n await this.refreshPlayQueue();\n }\n }\n if (this.mediaBlocks.includes(\"tuner\")) {\n await this.refreshTunerPresets();\n }\n if (this.hasClock) {\n await this.refreshClock();\n }\n await this.refreshSignalInfo();\n }\n\n /** Fetch the MusicCast playlist names and write the JSON list state. */\n private async refreshPlaylists(): Promise<void> {\n try {\n const update = parseYxcPlaylistNames(await this.deps.client.getMcPlaylistName());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getMcPlaylistName failed: ${errorMessage(e)}`);\n }\n }\n\n /** Fetch the network player's play queue and write the JSON state. */\n private async refreshPlayQueue(): Promise<void> {\n try {\n const update = parseYxcPlayQueue(await this.deps.client.getPlayQueue());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getPlayQueue failed: ${errorMessage(e)}`);\n }\n }\n\n /** Fetch each declaring zone's audio-signal info and write the signal states. */\n private async refreshSignalInfo(): Promise<void> {\n for (const zone of this.signalZones) {\n try {\n for (const update of parseYxcSignalInfo(await this.deps.client.getSignalInfo(zone), zone)) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getSignalInfo(${zone}) failed: ${errorMessage(e)}`);\n }\n }\n }\n\n /** Fetch the stored netusb favourites and write the JSON list state. */\n private async refreshNetusbPresets(): Promise<void> {\n try {\n const update = parseYxcPresetList(await this.deps.client.getPresetInfo());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getPresetInfo failed: ${errorMessage(e)}`);\n }\n }\n\n /** Fetch the recently-played list and write the JSON list state. */\n private async refreshNetusbRecent(): Promise<void> {\n try {\n const update = parseYxcRecentList(await this.deps.client.getRecentInfo());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getRecentInfo failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Fetch the tuner preset lists \u2014 the shared `common` list, or one per band on\n * devices with separate lists \u2014 and write the JSON state.\n */\n private async refreshTunerPresets(): Promise<void> {\n const bands = this.tunerFeatures?.presetType === \"common\" ? [\"common\"] : (this.tunerFeatures?.bands ?? [\"fm\"]);\n const byBand: Record<string, unknown> = {};\n for (const band of bands) {\n try {\n byBand[band] = await this.deps.client.getTunerPresetInfo(band);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getTunerPresetInfo(${band}) failed: ${errorMessage(e)}`);\n }\n }\n const update = parseYxcTunerPresetLists(byBand);\n if (update) {\n this.emit(update.id, update.value);\n }\n }\n\n /** Fetch the clock/alarm settings and write the read-only clock states. */\n private async refreshClock(): Promise<void> {\n try {\n for (const update of parseYxcClock(await this.deps.client.getClockSettings())) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getClockSettings failed: ${errorMessage(e)}`);\n }\n }\n\n /** Refresh every player source the device offers (network player, cd, tuner). */\n private async refreshMedia(): Promise<void> {\n // The three sources (netusb/cd/tuner) write disjoint states \u2014 fetch them together.\n await Promise.all(this.mediaBlocks.map(block => this.refreshMediaSource(block)));\n }\n\n /**\n * Fetch one media source's play info and write the parsed states with ack. The\n * source picks the getPlayInfo argument and the parser: netusb and cd share the\n * play-info shape (different channel), the tuner has its own band/frequency/RDS.\n *\n * @param block the media block (`netusb`, `cd`, `tuner`)\n */\n private async refreshMediaSource(block: string): Promise<void> {\n const arg = block === \"netusb\" ? undefined : block;\n try {\n const info = await this.deps.client.getPlayInfo(arg);\n if (block === \"tuner\") {\n for (const update of parseYxcTunerInfo(info)) {\n this.emit(update.id, update.value);\n if (update.id === \"tuner.band\") {\n this.lastTunerBand = String(update.value);\n }\n }\n return;\n }\n const source: \"netusb\" | \"cd\" = block === \"cd\" ? \"cd\" : \"netusb\";\n const updates = parseYxcPlayInfo(info, source);\n if (source === \"netusb\") {\n const active = updates.find(update => update.id === \"player.source\");\n if (typeof active?.value === \"string\") {\n this.lastNetusbInput = active.value;\n }\n }\n this.routePlayerBlock(source, updates);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getPlayInfo(${arg ?? \"\"}) failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Which player source a zone's input feeds into its \"now playing\" block: `cd` for\n * the disc input, `netusb` when the zone's input IS the network player's active\n * source. Anything else (HDMI, analog, tuner) plays no media block.\n *\n * @param input the zone's currently selected input\n * @returns the feeding source, or undefined when the input is no media player\n */\n private playerBlockFor(input: string | undefined): \"netusb\" | \"cd\" | undefined {\n if (input === \"cd\" && this.mediaBlocks.includes(\"cd\")) {\n return \"cd\";\n }\n if (input !== undefined && input !== \"\" && input === this.lastNetusbInput && this.mediaBlocks.includes(\"netusb\")) {\n return \"netusb\";\n }\n return undefined;\n }\n\n /**\n * Route one source's play info into the \"now playing\" block of every zone listening\n * to it (v2.0.0): main flat, the other zones under their multiroom folder. A zone\n * that LEFT the source gets its block cleared once \u2014 the previous program's metadata\n * must not linger under a zone that no longer plays it. Drive-own `player.cd.*`\n * extras are device-global and emitted once, unprefixed.\n *\n * @param block the source the updates came from\n * @param updates the parsed flat player updates\n */\n private routePlayerBlock(block: \"netusb\" | \"cd\", updates: StateValue[]): void {\n const zones = this.zones.length > 0 ? this.zones : [\"main\"];\n for (const zone of zones) {\n const expected = this.playerBlockFor(this.lastZoneInput.get(zone));\n const previous = this.zonePlayerBlock.get(zone);\n if (previous === block && expected !== block) {\n // The zone left OUR source \u2014 clear; the new source's refresh fills its own values.\n this.zonePlayerBlock.delete(zone);\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n if (expected === block) {\n if (previous !== block) {\n this.zonePlayerBlock.set(zone, block);\n if (previous !== undefined) {\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n }\n this.emitPlayerUpdates(zone, updates);\n }\n }\n for (const update of updates) {\n if (update.id.startsWith(\"player.cd.\")) {\n this.emit(update.id, update.value);\n }\n }\n }\n\n /**\n * One scene.list JSON per scene-capable zone (v2.0.0): every recall slot the zone\n * declares (getFeatures scene_num), titled from the shared per-device memory where\n * another transport reported titles (XML Scene_Sel_Item / YNCA SCENExNAME). A\n * MusicCast-only device has no title source and lists its slots with empty titles \u2014\n * the COUNT is what its getFeatures declares (review finding: the promised list was\n * missing entirely on devices whose only transport is MusicCast).\n *\n * @param capabilities the device's parsed getFeatures capabilities\n */\n private async setupSceneLists(capabilities: YxcCapabilities): Promise<void> {\n for (const zone of capabilities.zones) {\n if (!zone.funcs.includes(\"scene\") || zone.sceneNum === undefined || zone.sceneNum <= 0) {\n continue;\n }\n const titles = new Map(knownScenes(this.deps.probeMemory, zone.id).map(scene => [scene.num, scene.title]));\n const list = Array.from({ length: zone.sceneNum }, (_unused, i) => ({\n num: i + 1,\n title: titles.get(i + 1) ?? \"\",\n }));\n const id = `${zonePrefix(zone.id)}scene.list`;\n await this.deps.upsertObject(`${this.deviceId}.${id}`, {\n id,\n type: \"state\",\n common: { name: tName(\"scenesNumberTitle\"), type: \"string\", role: \"json\", read: true, write: false },\n });\n this.emit(id, JSON.stringify(list));\n }\n }\n\n /**\n * Re-evaluate which source feeds a zone's player block after ITS input changed:\n * clear the block when the zone left a media source, and fetch the joined source's\n * play info right away so the block fills now, not at the next sweep.\n *\n * @param zone the zone whose input just changed\n */\n private retargetZonePlayer(zone: string): void {\n const expected = this.playerBlockFor(this.lastZoneInput.get(zone));\n const previous = this.zonePlayerBlock.get(zone);\n if (previous === expected) {\n return;\n }\n if (previous !== undefined) {\n this.zonePlayerBlock.delete(zone);\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n if (expected !== undefined) {\n // routePlayerBlock (inside this refresh) records the zone's new source.\n void this.refreshMediaSource(expected);\n }\n }\n\n /**\n * Emit flat player updates into one zone's block (main flat, zones prefixed),\n * skipping the device-global drive extras.\n *\n * @param zone the target zone\n * @param updates the flat player updates\n */\n private emitPlayerUpdates(zone: string, updates: StateValue[]): void {\n const prefix = zonePrefix(zone);\n for (const update of updates) {\n if (!update.id.startsWith(\"player.cd.\")) {\n this.emit(`${prefix}${update.id}`, update.value);\n }\n }\n }\n\n /**\n * Fetch the MusicCast-Link distribution info and write the parsed dist states with ack,\n * caching the role for the leave-group path.\n */\n private async refreshDistribution(): Promise<void> {\n try {\n const info = await this.deps.client.getDistributionInfo();\n for (const update of parseYxcDistribution(info)) {\n this.emit(update.id, update.value);\n if (update.id === \"multiroom.group.role\") {\n this.lastDistRole = String(update.value);\n }\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getDistributionInfo failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Leave the current MusicCast-Link group: a server stops distributing, a client clears\n * its membership. Then re-read the distribution state so the tree reflects the change.\n */\n private async leaveGroup(): Promise<void> {\n try {\n if (this.lastDistRole === \"server\") {\n await this.deps.client.stopDistribution();\n } else {\n await this.deps.client.setClientInfo({ group_id: \"\", zone: [\"main\"] });\n }\n await this.refreshDistribution();\n } catch (e) {\n // A user action failing must be visible \u2014 warn, like every other write command.\n this.deps.log.warn(`${this.deviceId}: leaveGroup failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Form a MusicCast-Link group with another configured device: give the client the shared\n * group id, add it to this device's roster as the server, and start distributing. The group\n * id is derived from this device's id, so re-linking reuses the same group rather than a new one.\n *\n * @param clientIp the IP of the client device to add (must be a configured device)\n */\n private async linkClient(clientIp: string): Promise<void> {\n const clientClient = this.deps.clientFor?.(clientIp);\n if (!clientClient) {\n this.deps.log.warn(`${this.deviceId}: cannot link ${clientIp} \u2014 not a known device`);\n return;\n }\n try {\n const groupId = createHash(\"md5\").update(this.deviceId).digest(\"hex\");\n await clientClient.setClientInfo({ group_id: groupId, zone: [\"main\"] });\n await this.deps.client.setServerInfo({ group_id: groupId, zone: \"main\", type: \"add\", client_list: [clientIp] });\n await this.deps.client.startDistribution(0);\n await this.refreshDistribution();\n } catch (e) {\n // A user action failing must be visible \u2014 warn, like every other write command.\n this.deps.log.warn(`${this.deviceId}: linkClient(${clientIp}) failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Fetch a zone's status and write its amp states with ack.\n *\n * @param zone the zone to refresh\n * @returns true if the status was fetched, false if the request failed\n */\n private async refreshZone(zone: string): Promise<boolean> {\n try {\n const status = await this.deps.client.getStatus(zone);\n const updates = parseYxcStatus(status, zone);\n for (const update of updates) {\n this.emit(update.id, update.value);\n // The EXACT id, not a suffix: this value decides which source a zone's player block\n // and its transport buttons follow. A future status field ending in \"input\" would\n // have bent that routing silently.\n if (update.id === `${zonePrefix(zone)}input` && typeof update.value === \"string\") {\n const previous = this.lastZoneInput.get(zone);\n this.lastZoneInput.set(zone, update.value);\n if (previous !== update.value) {\n // The zone changed its input \u2014 re-target its player block NOW. Media\n // pushes alone cannot cover this: a zone leaving a still-playing source\n // (or joining one another zone already plays) changes nothing about the\n // source itself, so no netusb/cd push ever arrives (2.0.0 review finding).\n this.retargetZonePlayer(zone);\n }\n }\n }\n this.cacheEqualizer(zone, updates);\n return true;\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getStatus(${zone}) failed: ${errorMessage(e)}`);\n return false;\n }\n }\n\n /**\n * Cache a zone's equalizer bands from its status updates, so a later single-band\n * write can send setEqualizer with all three (the device sets them together).\n *\n * @param zone the zone the updates belong to\n * @param updates the parsed status updates for that zone\n */\n private cacheEqualizer(zone: string, updates: StateValue[]): void {\n // Same definition the status parser uses \u2014 see lib/yxc/zones.ts on why this must not\n // be spelled out a second time.\n const prefix = zonePrefix(zone);\n const band = (b: string): number | undefined => {\n const u = updates.find(x => x.id === `${prefix}sound.equalizer.${b}`);\n return typeof u?.value === \"number\" ? u.value : undefined;\n };\n const low = band(\"low\");\n const mid = band(\"mid\");\n const high = band(\"high\");\n if (low === undefined && mid === undefined && high === undefined) {\n return;\n }\n const cur = this.lastEqualizer.get(zone);\n if (!cur) {\n // No cache yet: only a COMPLETE triple may seed it. Filling the gaps with 0 would hand\n // the write path exactly the invented 0/0/0 it refuses to send \u2014 that safeguard only\n // works if this cache never lies about a band.\n if (low === undefined || mid === undefined || high === undefined) {\n return;\n }\n this.lastEqualizer.set(zone, { low, mid, high });\n return;\n }\n this.lastEqualizer.set(zone, { low: low ?? cur.low, mid: mid ?? cur.mid, high: high ?? cur.high });\n }\n\n /**\n * Apply a mapped command. A plain command runs its client call directly; the two\n * commands that need controller-cached state (equalizer bands, tuner band) are\n * completed here \u2014 the only place that state lives.\n *\n * @param stateId the written state id, for the failure log line\n * @param command the YXC command to apply\n */\n private async applyCommand(stateId: string, command: YxcCommand): Promise<void> {\n try {\n switch (command.kind) {\n case \"run\":\n await command.run(this.deps.client);\n break;\n case \"equalizer\": {\n // The device sets all three bands in one call, so the other two come from the\n // cache. Without a cached set we must NOT invent 0/0/0 \u2014 that would silently\n // flatten the user's other two bands. The cache fills from a zone status, so\n // fetch one first; only if even that fails is the write refused (with a warning).\n const { zone, band, value } = command;\n let current = this.lastEqualizer.get(zone);\n if (!current) {\n await this.refreshZone(zone);\n current = this.lastEqualizer.get(zone);\n }\n if (!current) {\n this.deps.log.warn(\n `${this.deviceId}: not writing ${stateId} \u2014 the device has not reported its equalizer bands yet`,\n );\n break;\n }\n const next = { ...current, [band]: value };\n // Cache BEFORE the round-trip: a second band written straight afterwards\n // reads this cache at dispatch \u2014 caching after the await would make it\n // compute from the pre-write triple and undo this band on the device.\n this.lastEqualizer.set(zone, next);\n await this.deps.client.setEqualizer(next.low, next.mid, next.high, zone);\n break;\n }\n case \"tunerBand\":\n // Remember it BEFORE the round-trip: a frequency written straight afterwards\n // reads this cache synchronously at dispatch, while the band call may still\n // be in flight \u2014 and the poll that would report it back runs minutes later.\n this.lastTunerBand = command.band;\n await this.deps.client.setBand(command.band);\n break;\n case \"tunerFreq\":\n await this.deps.client.setFreq(this.lastTunerBand, command.value);\n break;\n case \"tunerPreset\": {\n // Shared-list devices recall on `common`; separate-list devices on the current band.\n const band = this.tunerFeatures?.presetType === \"common\" ? \"common\" : this.lastTunerBand;\n await this.deps.client.recallTunerPreset(band, command.value, this.zoneListeningTo(\"tuner\"));\n break;\n }\n case \"netusbPreset\":\n await this.deps.client.recallPreset(command.value, this.zoneListeningTo(this.lastNetusbInput));\n break;\n case \"netusbRecent\":\n await this.deps.client.recallRecentItem(command.value, this.zoneListeningTo(this.lastNetusbInput));\n break;\n case \"playerTransport\": {\n // The unified block's buttons act on whatever the ZONE is playing (v2.0.0) \u2014\n // derived FRESH from the zone's input, never from the routing map: a stale\n // map entry would send the command to the source the zone just left.\n const block = this.playerBlockFor(this.lastZoneInput.get(command.zone));\n if (block === undefined) {\n this.deps.log.debug(`${this.deviceId}: ${stateId} ignored \u2014 ${command.zone} is not playing a media source`);\n break;\n }\n await this.runTransport(block, command.action);\n break;\n }\n }\n } catch (e) {\n this.deps.log.warn(`${this.deviceId}: write to ${stateId} failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Run one transport action on the given player source. The CD transport routes\n * through the one `setCDPlayback(action)` method (not the per-action helpers, one\n * of which sends the wrong command in the library).\n *\n * @param block the source the zone is playing\n * @param action the transport action\n */\n private async runTransport(block: \"netusb\" | \"cd\", action: PlayerTransport): Promise<void> {\n const client = this.deps.client;\n if (block === \"netusb\") {\n const net: Record<PlayerTransport, () => Promise<unknown>> = {\n play: () => client.playNet(),\n pause: () => client.pauseNet(),\n stop: () => client.stopNet(),\n next: () => client.nextNet(),\n prev: () => client.prevNet(),\n repeatToggle: () => client.toggleNetRepeat(),\n shuffleToggle: () => client.toggleNetShuffle(),\n };\n await net[action]();\n return;\n }\n const cd: Record<PlayerTransport, () => Promise<unknown>> = {\n play: () => client.setCDPlayback(\"play\"),\n pause: () => client.setCDPlayback(\"pause\"),\n stop: () => client.setCDPlayback(\"stop\"),\n next: () => client.setCDPlayback(\"next\"),\n prev: () => client.setCDPlayback(\"previous\"),\n repeatToggle: () => client.toggleCDRepeat(),\n shuffleToggle: () => client.toggleCDShuffle(),\n };\n await cd[action]();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,wBAA8E;AAC9E,2BAAgC;AAChC,4BAgBO;AACP,kBAAqE;AAErE,kBAAsB;AAGtB,kBAA6B;AAC7B,gCAAiC;AAEjC,mBAA2B;AAC3B,0BAAgD;AAGhD,qBAAoC;AACpC,+BAAgC;AAGhC,MAAM,eAAe,IAAI,KAAK;AAM9B,MAAM,6BAA6B;AAQnC,SAAS,cAAc,YAAyC;AAC9D,QAAM,QAAS,yCAAgD;AAC/D,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAYO,SAAS,aAAa,UAAuC;AAClE,QAAM,QAAS,qCAA6C;AAC5D,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO;AAAA,EACT;AACA,aAAW,QAAQ,OAAO;AACxB,QAAI,OAAO,SAAS,YAAY,SAAS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c,UAAU;AAAA,MAC3C,cAAc,MAAM,OAAO,eAAe;AAAA,MAC1C,eAAe,MAAM,OAAO,gBAAgB;AAAA,IAC9C;AACA,UAAM,GAAG,MAAM,EAAE;AAAA,EACnB;AACF;",
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { parseYxcFeatures, type YxcCapabilities, type YxcTunerFeatures } from \"./capability\";\nimport { mapYxcToObjects } from \"./object-mapper\";\nimport {\n parseYxcClock,\n parseYxcDistribution,\n parseYxcPlayInfo,\n parseYxcPlaylistNames,\n parseYxcPlayQueue,\n parseYxcPresetList,\n parseYxcRecentList,\n parseYxcSignalInfo,\n parseYxcStatus,\n parseYxcTunerInfo,\n parseYxcTunerPresetLists,\n PLAYER_CLEAR,\n stateToYxc,\n type PlayerTransport,\n type YxcCommand,\n} from \"./command-mapper\";\nimport { mediaToRefresh, netusbListsToRefresh, zonesToRefresh } from \"./push\";\nimport type { ObjectDef } from \"../catalog/types\";\nimport { tName } from \"../i18n\";\nimport type { StateValue } from \"../types\";\nimport type { ConnectionHandle, ControllerLog } from \"../controller\";\nimport { errorMessage } from \"../util\";\nimport { PollDropDetector } from \"../lifecycle/poll-drop-detector\";\nimport type { ProbeMemory } from \"../lifecycle/probe-memory\";\nimport { zonePrefix } from \"./zones\";\nimport { knownScenes, resolveSceneNumber } from \"../catalog/scene-titles\";\nimport type { CommandGate } from \"../lifecycle/command-gate\";\nimport type { BrowseEngine } from \"../browse/browse-engine\";\nimport { createBrowseSurface } from \"../browse/surface\";\nimport { YxcBrowseDriver } from \"../browse/yxc-browse-driver\";\n\n/** Renew interval for the push registration + state poll, well under the ~20 min expiry. */\nconst KEEPALIVE_MS = 5 * 60 * 1000;\n\n/**\n * With push working, run the full media/list/group sweep only every Nth keepalive (6 \u00D7 5 min\n * = every 30 minutes) \u2014 a safety net against a dropped UDP packet, not the primary path.\n */\nconst PUSH_MODE_FULL_SWEEP_EVERY = 6;\n\n/**\n * Extract the model name from a getDeviceInfo response, if it carries a non-empty one.\n *\n * @param deviceInfo the getDeviceInfo response\n * @returns the model name, or undefined\n */\nfunction modelNameFrom(deviceInfo: unknown): string | undefined {\n const model = (deviceInfo as { model_name?: unknown } | null)?.model_name;\n return typeof model === \"string\" && model.length > 0 ? model : undefined;\n}\n\n/**\n * Extract the name a user gave this device from a getNameText response.\n *\n * MusicCast keeps it as the main zone's text \u2014 that is the name shown in the app and\n * the one people recognise (\"Wohnzimmer\"). A device whose zone was never renamed\n * answers with a generic zone name; the caller filters those out.\n *\n * @param nameText the getNameText response\n * @returns the main zone's text, or undefined\n */\nexport function zoneNameFrom(nameText: unknown): string | undefined {\n const zones = (nameText as { zone_list?: unknown } | null)?.zone_list;\n if (!Array.isArray(zones)) {\n return undefined;\n }\n for (const zone of zones) {\n if (typeof zone !== \"object\" || zone === null) {\n continue;\n }\n const { id, text } = zone as { id?: unknown; text?: unknown };\n if (id === \"main\" && typeof text === \"string\" && text.trim().length > 0) {\n return text.trim();\n }\n }\n return undefined;\n}\n\nimport type { YxcClientLike } from \"./client-contract\";\n\n// Re-exported so existing importers (the tests' fakes) keep resolving it from here.\nexport type { YxcClientLike };\n\n/** The adapter callbacks the controller drives \u2014 narrow, so no adapter mock is needed in tests. */\nexport interface YxcControllerDeps {\n /** The YXC (MusicCast) client for this device. */\n client: YxcClientLike;\n /** Resolve another configured device's client by IP, for forming a multiroom group. */\n clientFor?: (ip: string) => YxcClientLike | undefined;\n /** Register a push handler for this device (by IP); returns a function that unregisters it. */\n registerPush(onPush: (event: unknown) => void): () => void;\n /**\n * Whether the shared push receiver is actually listening. With push the device reports\n * its own changes, so the keepalive only has to renew the subscription and refresh the\n * zone status; without it (the port is taken \u2014 see issue #611) the poll is the ONLY\n * source of change and has to cover everything. Absent = assume no push.\n */\n pushActive?(): boolean;\n /** Per-device memory for answers that do not change while the device runs (see ProbeMemory). */\n probeMemory?: ProbeMemory;\n /** Schedule the keepalive handler; returns a function that cancels it. */\n scheduleKeepalive(handler: () => void, ms: number): () => void;\n /** Create or update an object in the device tree. */\n upsertObject(id: string, def: ObjectDef): Promise<void>;\n /** Write a state value with ack (device-originated). */\n setStateAck(id: string, value: boolean | number | string): void;\n /** Report the name the device carries for itself, for the device object's label. */\n reportDeviceName?(name: string): void;\n /** Adapter log. */\n log: ControllerLog;\n /**\n * The device's command gate: every request is paced through it, and its signal is the\n * connection's shutdown flag \u2014 a closed gate ends pending waits and stops state writes\n * from a poll that was already in flight. Absent in older tests \u2192 no browsing.\n */\n gate?: CommandGate;\n}\n\n/**\n * Drives one MusicCast (YXC) device: read capabilities, build the object tree,\n * seed state from getStatus, and route commands both ways. Device pushes arrive\n * via the shared receiver as re-fetch signals; a keepalive poll renews the push\n * registration (the fix for the musiccast \"stops updating\" bug) and doubles as\n * the poll-only fallback when the push port is unavailable. Create-only.\n */\nexport class YxcDeviceController implements ConnectionHandle {\n private zones: string[] = [];\n private mediaBlocks: string[] = [];\n private cancelKeepalive: (() => void) | undefined;\n private cancelPush: (() => void) | undefined;\n private readonly dropDetector = new PollDropDetector();\n /** The tuner's current band, cached so a frequency write can supply it (setFreq needs band + freq). */\n private lastTunerBand = \"fm\";\n /** Each zone's currently selected input, from its status \u2014 see {@link zoneListeningTo}. */\n private readonly lastZoneInput = new Map<string, string>();\n /** The source the network player is currently on (netusb `input`, e.g. \"net_radio\"). */\n private lastNetusbInput = \"\";\n /** Which source currently feeds each zone's \"now playing\" block (v2.0.0 routing). */\n private readonly zonePlayerBlock = new Map<string, \"netusb\" | \"cd\">();\n /** Each zone's last-seen equalizer bands, cached so one band write can supply the other two. */\n private readonly lastEqualizer = new Map<string, { low: number; mid: number; high: number }>();\n /** Whether the device reports MusicCast-Link distribution (gates the dist poll and objects). */\n private hasDistribution = false;\n /** The device's last-seen distribution role (none/server/client), for the leave-group path. */\n private lastDistRole = \"none\";\n /** The tuner features (bands + preset mode) \u2014 a preset recall needs the band. */\n private tunerFeatures: YxcTunerFeatures | undefined;\n /** Whether the device reports the clock/alarm block (gates the clock poll). */\n private hasClock = false;\n /** The zones declaring `signal_info` (gates the audio-signal poll). */\n private signalZones: string[] = [];\n /** Whether netusb declares the MusicCast playlists / the play queue (gates their polls). */\n private hasMcPlaylist = false;\n private hasPlayQueue = false;\n /** Counts keepalive runs, so the safety-net sweep can run every Nth one under push. */\n private keepaliveRuns = 0;\n private browseEngine: BrowseEngine | undefined;\n\n /**\n * @param deviceId the id-safe device id (object-tree path segment)\n * @param deps the client and adapter callbacks\n */\n public constructor(\n private readonly deviceId: string,\n private readonly deps: YxcControllerDeps,\n ) {}\n\n /**\n * Read capabilities, create the object tree, seed state, and wire up push +\n * keepalive.\n *\n * @returns true if the device reported capabilities and its tree was created\n */\n public async start(): Promise<boolean> {\n // Freshness guard for the (persisted) probe memory: ONE LIVE getDeviceInfo proves\n // the device behind this address is still the one the memory was learned from. A\n // swapped or factory-reset device answers a different identity \u2014 its remembered\n // YXC answers are dropped and re-probed; a transient failure keeps the memory and\n // leaves the liveness verdict to the zone check below. Also feeds the model line.\n let model: string | undefined;\n try {\n const info = await this.deps.client.getDeviceInfo();\n model = modelNameFrom(info);\n const version = (info as { system_version?: unknown } | null)?.system_version;\n const identity = `${model ?? \"\"}|${typeof version === \"number\" || typeof version === \"string\" ? version : \"\"}`;\n if (this.deps.probeMemory && this.deps.probeMemory.remembered(\"yxcIdentity\") !== identity) {\n this.deps.probeMemory.drop(\n key => key === \"features\" || key === \"name\" || key === \"model\" || key === \"yxcIdentity\",\n );\n this.deps.probeMemory.set(\"yxcIdentity\", identity);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getDeviceInfo failed (${errorMessage(e)})`);\n }\n // Capabilities and name are constant while the device runs, so on a reconnect \u2014\n // and, persisted, on a restart \u2014 they come from the per-device memory instead of\n // costing more round-trips on a connection that is being (re-)established anyway.\n // A capability set with no zone at all is not a MusicCast device answering \u2014 it is a\n // truncated or malformed answer. Returned to this run, but NOT remembered: remembering\n // it would freeze the device's shape for good (every later connect reads the memory),\n // and it would also disarm the liveness check below, which needs the zones.\n const capabilities = await this.remember(\n \"features\",\n async () => parseYxcFeatures(await this.deps.client.getFeatures()),\n features => features.zones.length > 0,\n );\n const objects = mapYxcToObjects(capabilities);\n if (objects.length === 0) {\n this.deps.log.warn(`${this.deviceId}: no capabilities reported \u2014 creating no objects`);\n return false;\n }\n // Parents before children (channels before their states) \u2014 created in order.\n for (const object of objects) {\n await this.deps.upsertObject(`${this.deviceId}.${object.id}`, object);\n }\n await this.setupSceneLists(capabilities);\n // The DAB scan counters are the one DAB detail the device reports only after a\n // station scan (status stays not_ready before) \u2014 seed the documented start state\n // (nothing scanned) so they are not left as valueless read states; a real scan\n // result overwrites them via the tuner play info.\n if (capabilities.media.includes(\"tuner\") && (capabilities.tuner?.bands ?? []).includes(\"dab\")) {\n this.emit(\"tuner.dab.totalStations\", 0);\n this.emit(\"tuner.dab.scanProgress\", 0);\n }\n if (model) {\n // The info channel and info.model already exist \u2014 the adapter creates them for\n // every device up front, so the card renders even while the device is offline.\n this.emit(\"info.model\", model);\n }\n // The name the user gave the device in the MusicCast app. Best-effort like the model\n // above: an older device that does not answer getNameText simply keeps its label.\n if (this.deps.reportDeviceName) {\n try {\n const name = await this.remember(\"name\", async () => zoneNameFrom(await this.deps.client.getNameText()));\n if (name) {\n this.deps.reportDeviceName(name);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getNameText failed (${errorMessage(e)})`);\n }\n }\n this.zones = capabilities.zones.map(zone => zone.id);\n // Zones in parallel \u2014 disjoint writes, and a zone stuck in its timeout must not hold\n // up the device's readiness.\n const zonesAnswered = await Promise.all(this.zones.map(zone => this.refreshZone(zone)));\n // The zone status is the one request of this start that ALWAYS goes to the device: the\n // capabilities above come from the probe memory on every reconnect, and model/name are\n // best-effort, so nothing before this point can tell a live device from a dead one. Without\n // the check a reconnect to a receiver that had lost power still reported \"ready \u2014\n // MusicCast \u2713\" out of memory while YNCA and XML failed honestly, and info.connection stayed\n // true for a device that was not there (krobi's RX-V6A, 2026-08-26). A device that answers\n // no zone at all is gone \u2014 a standby device still answers, it just reports power=standby.\n // No `zones.length > 0` escape any more: a device that declares NO zone cannot prove it\n // is alive either, and the whole point of this check is that nothing may report \"ready\"\n // out of memory. Everything before it \u2014 capabilities, model, name \u2014 can come from the\n // persisted memory without a single request reaching the device.\n if (!zonesAnswered.some(Boolean)) {\n this.deps.log.debug(`${this.deviceId}: no zone answered getStatus \u2014 device unreachable (YXC)`);\n return false;\n }\n this.mediaBlocks = capabilities.media;\n this.tunerFeatures = capabilities.tuner;\n this.hasClock = capabilities.clock !== undefined;\n this.signalZones = capabilities.zones.filter(zone => zone.funcs.includes(\"signal_info\")).map(zone => zone.id);\n this.hasMcPlaylist = capabilities.netusbFuncs?.includes(\"mc_playlist\") ?? false;\n this.hasPlayQueue = capabilities.netusbFuncs?.includes(\"play_queue\") ?? false;\n await this.setupBrowse(capabilities);\n await this.refreshMedia();\n // Seed the WHOLE player block with its cleared shape for every zone NOT playing a\n // media source: the routing above only writes to listening zones, so on a device\n // that starts on HDMI the block would sit valueless until the first media playback\n // (live 2.0.0 deployment check \u2014 same gap the pre-release audit found for source).\n if (this.mediaBlocks.includes(\"netusb\") || this.mediaBlocks.includes(\"cd\")) {\n for (const zone of this.zones.length > 0 ? this.zones : [\"main\"]) {\n if (!this.zonePlayerBlock.has(zone)) {\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n }\n }\n await this.refreshLists();\n this.hasDistribution = capabilities.hasDistribution ?? false;\n if (this.hasDistribution) {\n await this.refreshDistribution();\n }\n this.cancelPush = this.deps.registerPush(event => this.onPush(event));\n this.cancelKeepalive = this.deps.scheduleKeepalive(() => void this.keepalive(), KEEPALIVE_MS);\n // The adapter logs one combined \"ready\" line across all transports; this stays at debug.\n this.deps.log.debug(`${this.deviceId}: MusicCast device ready (YXC)`);\n return true;\n }\n\n /**\n * Ask the device once per adapter run and remember the answer for later reconnects.\n *\n * @param key what is being remembered\n * @param probe the request to run when nothing is remembered yet\n * @param isUsable optional plausibility check \u2014 an answer it rejects is used but not remembered\n * @returns the remembered or freshly fetched value\n */\n private remember<T>(key: string, probe: () => Promise<T>, isUsable?: (value: T) => boolean): Promise<T> {\n return this.deps.probeMemory ? this.deps.probeMemory.once(key, probe, isUsable) : probe();\n }\n\n /**\n * The zone a recall should be routed to: recalling a favourite does not just start it, it\n * also switches THAT zone to the source. Sending everything to the main zone (as this did\n * before) means someone listening in zone 2 gets their favourite in the living room\n * instead \u2014 and the main zone switched away from whatever it was playing.\n *\n * The zone actually listening to the source is the right target; the main zone is the\n * fallback when nothing matches, which is also every single-zone device.\n *\n * @param source the input the recall belongs to (a network source, or \"tuner\")\n * @returns the zone to route the recall to\n */\n private zoneListeningTo(source: string): string {\n if (!source) {\n return \"main\";\n }\n // Main first: on a device where several zones share the source, it is the natural target.\n if (this.lastZoneInput.get(\"main\") === source) {\n return \"main\";\n }\n for (const [zone, input] of this.lastZoneInput) {\n if (input === source) {\n return zone;\n }\n }\n return \"main\";\n }\n\n /**\n * Write a device-originated value \u2014 but never after the connection was closed. A poll\n * or a browse fetch that was already in flight when the adapter stopped would otherwise\n * still write into a tree that is being torn down.\n *\n * @param relativeId the state id relative to the device\n * @param value the value to write\n */\n private emit(relativeId: string, value: boolean | number | string): void {\n if (this.deps.gate?.closed) {\n return;\n }\n this.deps.setStateAck(`${this.deviceId}.${relativeId}`, value);\n }\n\n /**\n * Handle a state change: a user write (ack false) becomes a YXC command; an\n * acked change (the device's own echo) is ignored to avoid a resend loop.\n *\n * @param fullStateId the full state id (device id + \".\" + state)\n * @param ack whether the change is acked (device-originated)\n * @param value the new value\n */\n public handleStateChange(fullStateId: string, ack: boolean, value: unknown): void {\n if (ack) {\n return;\n }\n const prefix = `${this.deviceId}.`;\n if (!fullStateId.startsWith(prefix)) {\n return;\n }\n const stateId = fullStateId.slice(prefix.length);\n if (stateId.startsWith(\"player.browse.\")) {\n this.browseEngine?.handleWrite(stateId, value);\n return;\n }\n // A scene TITLE resolves to its number via the shared device memory \u2014 the titles may\n // have come over XML or YNCA while MusicCast owns the recall.\n const sceneMatch = /^(?:multiroom\\.(zone[234])\\.)?scene\\.recall$/.exec(stateId);\n if (sceneMatch && typeof value === \"string\" && !/^\\d+$/.test(value.trim())) {\n const zoneKey = sceneMatch[1] ?? \"main\";\n const resolved = resolveSceneNumber(value, this.deps.probeMemory, zoneKey);\n if (resolved === undefined) {\n // Same rule as the YNCA side: a write that goes nowhere leaves a trace.\n this.deps.log.debug(\n `${this.deviceId}: scene \"${value}\" is unknown for ${zoneKey} \u2014 write dropped ` +\n `(known: ${\n knownScenes(this.deps.probeMemory, zoneKey)\n .map(scene => scene.title)\n .join(\", \") || \"none yet\"\n })`,\n );\n return;\n }\n value = resolved;\n }\n // Multiroom writes need controller state (the cached role), so they bypass the pure command map.\n if (stateId === \"multiroom.group.leave\") {\n void this.leaveGroup();\n return;\n }\n if (stateId === \"multiroom.group.linkDevice\") {\n void this.linkClient(String(value));\n return;\n }\n const command = stateToYxc(stateId, value);\n if (command) {\n void this.applyCommand(stateId, command);\n }\n }\n\n /**\n * Register the supervisor's drop handler. MusicCast has no socket-drop event, so a\n * drop is inferred from a run of failed keepalive polls (see keepalive).\n *\n * @param cb invoked once when the device is judged gone\n */\n public onDrop(cb: (reason?: Error) => void): void {\n this.dropDetector.onDrop(cb);\n }\n\n /**\n * Create the browsing surface (#613) when the device has the netusb block: the\n * `netusb/getListInfo` + `setListControl` API drives an 8-line window under\n * `player.browse.*`. Skipped without a delay dep (older tests).\n *\n * @param capabilities the parsed getFeatures capabilities\n */\n private async setupBrowse(capabilities: YxcCapabilities): Promise<void> {\n const gate = this.deps.gate;\n if (!gate || !capabilities.media.includes(\"netusb\")) {\n return;\n }\n const inputs = capabilities.zones.find(zone => zone.id === \"main\")?.inputs ?? [];\n const driver = new YxcBrowseDriver(this.deps.client, inputs);\n this.browseEngine = await createBrowseSurface(driver, this.deviceId, {\n upsertObject: this.deps.upsertObject,\n emit: (id, value) => this.emit(id, value),\n log: this.deps.log,\n delay: ms => gate.delay(ms),\n });\n }\n\n /** Cancel the keepalive and unregister the push handler. Synchronous \u2014 safe from onUnload. */\n public close(): void {\n this.browseEngine?.close();\n // Closing the gate empties its queue and aborts its signal: queued requests are\n // dropped and every pending wait ends, so nothing writes after the teardown.\n this.deps.gate?.close();\n this.cancelKeepalive?.();\n this.cancelKeepalive = undefined;\n // Unregister from the shared push receiver \u2014 otherwise a push arriving after\n // teardown would setState on a controller the adapter has already dropped.\n this.cancelPush?.();\n this.cancelPush = undefined;\n }\n\n /**\n * Handle a device push: each named zone is re-fetched via getStatus, each named\n * media source via getPlayInfo (the push itself is a change signal, not a value\n * carrier). Refreshing only the named sources keeps a track-change push from\n * re-polling every source.\n *\n * @param event the parsed push event\n */\n private onPush(event: unknown): void {\n for (const zone of zonesToRefresh(event)) {\n if (this.zones.includes(zone)) {\n void this.refreshZone(zone);\n }\n }\n for (const block of mediaToRefresh(event)) {\n if (this.mediaBlocks.includes(block)) {\n void this.refreshMediaSource(block);\n }\n }\n // The favourites/recently-played lists announce their changes as flags in the push.\n const lists = netusbListsToRefresh(event);\n if (lists.presets && this.mediaBlocks.includes(\"netusb\")) {\n void this.refreshNetusbPresets();\n }\n if (lists.recent && this.mediaBlocks.includes(\"netusb\")) {\n void this.refreshNetusbRecent();\n }\n }\n\n /**\n * Poll every zone (which renews the push registration and refreshes state) and the\n * media sources. If every zone poll fails for three consecutive failed runs in a row,\n * the device is judged gone and a drop is reported so the supervisor can flip\n * info.connection and reconnect.\n */\n private async keepalive(): Promise<void> {\n // The keepalive is an async handler on an adapter timer: a rejection here is an\n // UNHANDLED rejection, and js-controller turns those into an adapter stop. Every step\n // below catches for itself today, so the guard is what makes that a guarantee instead\n // of something the next change has to remember.\n try {\n // Zones in parallel: their writes are disjoint and one zone stuck in its timeout must\n // not delay the others (a four-zone receiver used to poll them strictly in series).\n const zones = this.zones.length > 0 ? this.zones : [\"main\"];\n const anyOk = (await Promise.all(zones.map(zone => this.refreshZone(zone)))).some(Boolean);\n // Every request above already carried the subscription headers, so the push\n // registration is renewed either way. What still has to be polled depends on whether\n // push works: with push the device announces media, list and group changes itself, so\n // the full sweep only runs occasionally as a safety net (UDP can drop a packet);\n // without push it is the only way anything ever updates.\n this.keepaliveRuns++;\n const fullSweep = !this.deps.pushActive?.() || this.keepaliveRuns % PUSH_MODE_FULL_SWEEP_EVERY === 0;\n if (fullSweep) {\n await this.refreshMedia();\n await this.refreshLists();\n if (this.hasDistribution) {\n await this.refreshDistribution();\n }\n }\n this.dropDetector.record(anyOk);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: keepalive poll failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Refresh the list-shaped surfaces: the netusb favourites and recently-played\n * lists, the tuner preset lists, and the clock/alarm settings. Each is\n * best-effort \u2014 a device without the feature answers with an error code and the\n * state simply stays.\n */\n private async refreshLists(): Promise<void> {\n if (this.mediaBlocks.includes(\"netusb\")) {\n await this.refreshNetusbPresets();\n await this.refreshNetusbRecent();\n if (this.hasMcPlaylist) {\n await this.refreshPlaylists();\n }\n if (this.hasPlayQueue) {\n await this.refreshPlayQueue();\n }\n }\n if (this.mediaBlocks.includes(\"tuner\")) {\n await this.refreshTunerPresets();\n }\n if (this.hasClock) {\n await this.refreshClock();\n }\n await this.refreshSignalInfo();\n }\n\n /** Fetch the MusicCast playlist names and write the JSON list state. */\n private async refreshPlaylists(): Promise<void> {\n try {\n const update = parseYxcPlaylistNames(await this.deps.client.getMcPlaylistName());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getMcPlaylistName failed: ${errorMessage(e)}`);\n }\n }\n\n /** Fetch the network player's play queue and write the JSON state. */\n private async refreshPlayQueue(): Promise<void> {\n try {\n const update = parseYxcPlayQueue(await this.deps.client.getPlayQueue());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getPlayQueue failed: ${errorMessage(e)}`);\n }\n }\n\n /** Fetch each declaring zone's audio-signal info and write the signal states. */\n private async refreshSignalInfo(): Promise<void> {\n for (const zone of this.signalZones) {\n try {\n for (const update of parseYxcSignalInfo(await this.deps.client.getSignalInfo(zone), zone)) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getSignalInfo(${zone}) failed: ${errorMessage(e)}`);\n }\n }\n }\n\n /** Fetch the stored netusb favourites and write the JSON list state. */\n private async refreshNetusbPresets(): Promise<void> {\n try {\n const update = parseYxcPresetList(await this.deps.client.getPresetInfo());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getPresetInfo failed: ${errorMessage(e)}`);\n }\n }\n\n /** Fetch the recently-played list and write the JSON list state. */\n private async refreshNetusbRecent(): Promise<void> {\n try {\n const update = parseYxcRecentList(await this.deps.client.getRecentInfo());\n if (update) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getRecentInfo failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Fetch the tuner preset lists \u2014 the shared `common` list, or one per band on\n * devices with separate lists \u2014 and write the JSON state.\n */\n private async refreshTunerPresets(): Promise<void> {\n const bands = this.tunerFeatures?.presetType === \"common\" ? [\"common\"] : (this.tunerFeatures?.bands ?? [\"fm\"]);\n const byBand: Record<string, unknown> = {};\n for (const band of bands) {\n try {\n byBand[band] = await this.deps.client.getTunerPresetInfo(band);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getTunerPresetInfo(${band}) failed: ${errorMessage(e)}`);\n }\n }\n const update = parseYxcTunerPresetLists(byBand);\n if (update) {\n this.emit(update.id, update.value);\n }\n }\n\n /** Fetch the clock/alarm settings and write the read-only clock states. */\n private async refreshClock(): Promise<void> {\n try {\n for (const update of parseYxcClock(await this.deps.client.getClockSettings())) {\n this.emit(update.id, update.value);\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getClockSettings failed: ${errorMessage(e)}`);\n }\n }\n\n /** Refresh every player source the device offers (network player, cd, tuner). */\n private async refreshMedia(): Promise<void> {\n // The three sources (netusb/cd/tuner) write disjoint states \u2014 fetch them together.\n await Promise.all(this.mediaBlocks.map(block => this.refreshMediaSource(block)));\n }\n\n /**\n * Fetch one media source's play info and write the parsed states with ack. The\n * source picks the getPlayInfo argument and the parser: netusb and cd share the\n * play-info shape (different channel), the tuner has its own band/frequency/RDS.\n *\n * @param block the media block (`netusb`, `cd`, `tuner`)\n */\n private async refreshMediaSource(block: string): Promise<void> {\n const arg = block === \"netusb\" ? undefined : block;\n try {\n const info = await this.deps.client.getPlayInfo(arg);\n if (block === \"tuner\") {\n for (const update of parseYxcTunerInfo(info)) {\n this.emit(update.id, update.value);\n if (update.id === \"tuner.band\") {\n this.lastTunerBand = String(update.value);\n }\n }\n return;\n }\n const source: \"netusb\" | \"cd\" = block === \"cd\" ? \"cd\" : \"netusb\";\n const updates = parseYxcPlayInfo(info, source);\n if (source === \"netusb\") {\n const active = updates.find(update => update.id === \"player.source\");\n if (typeof active?.value === \"string\") {\n this.lastNetusbInput = active.value;\n }\n }\n this.routePlayerBlock(source, updates);\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getPlayInfo(${arg ?? \"\"}) failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Which player source a zone's input feeds into its \"now playing\" block: `cd` for\n * the disc input, `netusb` when the zone's input IS the network player's active\n * source. Anything else (HDMI, analog, tuner) plays no media block.\n *\n * @param input the zone's currently selected input\n * @returns the feeding source, or undefined when the input is no media player\n */\n private playerBlockFor(input: string | undefined): \"netusb\" | \"cd\" | undefined {\n if (input === \"cd\" && this.mediaBlocks.includes(\"cd\")) {\n return \"cd\";\n }\n if (input !== undefined && input !== \"\" && input === this.lastNetusbInput && this.mediaBlocks.includes(\"netusb\")) {\n return \"netusb\";\n }\n return undefined;\n }\n\n /**\n * Route one source's play info into the \"now playing\" block of every zone listening\n * to it (v2.0.0): main flat, the other zones under their multiroom folder. A zone\n * that LEFT the source gets its block cleared once \u2014 the previous program's metadata\n * must not linger under a zone that no longer plays it. Drive-own `player.cd.*`\n * extras are device-global and emitted once, unprefixed.\n *\n * @param block the source the updates came from\n * @param updates the parsed flat player updates\n */\n private routePlayerBlock(block: \"netusb\" | \"cd\", updates: StateValue[]): void {\n const zones = this.zones.length > 0 ? this.zones : [\"main\"];\n for (const zone of zones) {\n const expected = this.playerBlockFor(this.lastZoneInput.get(zone));\n const previous = this.zonePlayerBlock.get(zone);\n if (previous === block && expected !== block) {\n // The zone left OUR source \u2014 clear; the new source's refresh fills its own values.\n this.zonePlayerBlock.delete(zone);\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n if (expected === block) {\n if (previous !== block) {\n this.zonePlayerBlock.set(zone, block);\n if (previous !== undefined) {\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n }\n this.emitPlayerUpdates(zone, updates);\n }\n }\n for (const update of updates) {\n if (update.id.startsWith(\"player.cd.\")) {\n this.emit(update.id, update.value);\n }\n }\n }\n\n /**\n * One scene.list JSON per scene-capable zone (v2.0.0): every recall slot the zone\n * declares (getFeatures scene_num), titled from the shared per-device memory where\n * another transport reported titles (XML Scene_Sel_Item / YNCA SCENExNAME). A\n * MusicCast-only device has no title source and lists its slots with empty titles \u2014\n * the COUNT is what its getFeatures declares (review finding: the promised list was\n * missing entirely on devices whose only transport is MusicCast).\n *\n * @param capabilities the device's parsed getFeatures capabilities\n */\n private async setupSceneLists(capabilities: YxcCapabilities): Promise<void> {\n for (const zone of capabilities.zones) {\n if (!zone.funcs.includes(\"scene\") || zone.sceneNum === undefined || zone.sceneNum <= 0) {\n continue;\n }\n const titles = new Map(knownScenes(this.deps.probeMemory, zone.id).map(scene => [scene.num, scene.title]));\n const list = Array.from({ length: zone.sceneNum }, (_unused, i) => ({\n num: i + 1,\n title: titles.get(i + 1) ?? \"\",\n }));\n const id = `${zonePrefix(zone.id)}scene.list`;\n await this.deps.upsertObject(`${this.deviceId}.${id}`, {\n id,\n type: \"state\",\n common: {\n name: tName(\"scenesNumberTitle\"),\n desc: tName(\"descScenesNumberTitle\"),\n type: \"string\",\n role: \"json\",\n read: true,\n write: false,\n },\n });\n this.emit(id, JSON.stringify(list));\n }\n }\n\n /**\n * Re-evaluate which source feeds a zone's player block after ITS input changed:\n * clear the block when the zone left a media source, and fetch the joined source's\n * play info right away so the block fills now, not at the next sweep.\n *\n * @param zone the zone whose input just changed\n */\n private retargetZonePlayer(zone: string): void {\n const expected = this.playerBlockFor(this.lastZoneInput.get(zone));\n const previous = this.zonePlayerBlock.get(zone);\n if (previous === expected) {\n return;\n }\n if (previous !== undefined) {\n this.zonePlayerBlock.delete(zone);\n this.emitPlayerUpdates(zone, PLAYER_CLEAR);\n }\n if (expected !== undefined) {\n // routePlayerBlock (inside this refresh) records the zone's new source.\n void this.refreshMediaSource(expected);\n }\n }\n\n /**\n * Emit flat player updates into one zone's block (main flat, zones prefixed),\n * skipping the device-global drive extras.\n *\n * @param zone the target zone\n * @param updates the flat player updates\n */\n private emitPlayerUpdates(zone: string, updates: StateValue[]): void {\n const prefix = zonePrefix(zone);\n for (const update of updates) {\n if (!update.id.startsWith(\"player.cd.\")) {\n this.emit(`${prefix}${update.id}`, update.value);\n }\n }\n }\n\n /**\n * Fetch the MusicCast-Link distribution info and write the parsed dist states with ack,\n * caching the role for the leave-group path.\n */\n private async refreshDistribution(): Promise<void> {\n try {\n const info = await this.deps.client.getDistributionInfo();\n for (const update of parseYxcDistribution(info)) {\n this.emit(update.id, update.value);\n if (update.id === \"multiroom.group.role\") {\n this.lastDistRole = String(update.value);\n }\n }\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getDistributionInfo failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Leave the current MusicCast-Link group: a server stops distributing, a client clears\n * its membership. Then re-read the distribution state so the tree reflects the change.\n */\n private async leaveGroup(): Promise<void> {\n try {\n if (this.lastDistRole === \"server\") {\n await this.deps.client.stopDistribution();\n } else {\n await this.deps.client.setClientInfo({ group_id: \"\", zone: [\"main\"] });\n }\n await this.refreshDistribution();\n } catch (e) {\n // A user action failing must be visible \u2014 warn, like every other write command.\n this.deps.log.warn(`${this.deviceId}: leaveGroup failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Form a MusicCast-Link group with another configured device: give the client the shared\n * group id, add it to this device's roster as the server, and start distributing. The group\n * id is derived from this device's id, so re-linking reuses the same group rather than a new one.\n *\n * @param clientIp the IP of the client device to add (must be a configured device)\n */\n private async linkClient(clientIp: string): Promise<void> {\n const clientClient = this.deps.clientFor?.(clientIp);\n if (!clientClient) {\n this.deps.log.warn(`${this.deviceId}: cannot link ${clientIp} \u2014 not a known device`);\n return;\n }\n try {\n const groupId = createHash(\"md5\").update(this.deviceId).digest(\"hex\");\n await clientClient.setClientInfo({ group_id: groupId, zone: [\"main\"] });\n await this.deps.client.setServerInfo({ group_id: groupId, zone: \"main\", type: \"add\", client_list: [clientIp] });\n await this.deps.client.startDistribution(0);\n await this.refreshDistribution();\n } catch (e) {\n // A user action failing must be visible \u2014 warn, like every other write command.\n this.deps.log.warn(`${this.deviceId}: linkClient(${clientIp}) failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Fetch a zone's status and write its amp states with ack.\n *\n * @param zone the zone to refresh\n * @returns true if the status was fetched, false if the request failed\n */\n private async refreshZone(zone: string): Promise<boolean> {\n try {\n const status = await this.deps.client.getStatus(zone);\n const updates = parseYxcStatus(status, zone);\n for (const update of updates) {\n this.emit(update.id, update.value);\n // The EXACT id, not a suffix: this value decides which source a zone's player block\n // and its transport buttons follow. A future status field ending in \"input\" would\n // have bent that routing silently.\n if (update.id === `${zonePrefix(zone)}input` && typeof update.value === \"string\") {\n const previous = this.lastZoneInput.get(zone);\n this.lastZoneInput.set(zone, update.value);\n if (previous !== update.value) {\n // The zone changed its input \u2014 re-target its player block NOW. Media\n // pushes alone cannot cover this: a zone leaving a still-playing source\n // (or joining one another zone already plays) changes nothing about the\n // source itself, so no netusb/cd push ever arrives (2.0.0 review finding).\n this.retargetZonePlayer(zone);\n }\n }\n }\n this.cacheEqualizer(zone, updates);\n return true;\n } catch (e) {\n this.deps.log.debug(`${this.deviceId}: getStatus(${zone}) failed: ${errorMessage(e)}`);\n return false;\n }\n }\n\n /**\n * Cache a zone's equalizer bands from its status updates, so a later single-band\n * write can send setEqualizer with all three (the device sets them together).\n *\n * @param zone the zone the updates belong to\n * @param updates the parsed status updates for that zone\n */\n private cacheEqualizer(zone: string, updates: StateValue[]): void {\n // Same definition the status parser uses \u2014 see lib/yxc/zones.ts on why this must not\n // be spelled out a second time.\n const prefix = zonePrefix(zone);\n const band = (b: string): number | undefined => {\n const u = updates.find(x => x.id === `${prefix}sound.equalizer.${b}`);\n return typeof u?.value === \"number\" ? u.value : undefined;\n };\n const low = band(\"low\");\n const mid = band(\"mid\");\n const high = band(\"high\");\n if (low === undefined && mid === undefined && high === undefined) {\n return;\n }\n const cur = this.lastEqualizer.get(zone);\n if (!cur) {\n // No cache yet: only a COMPLETE triple may seed it. Filling the gaps with 0 would hand\n // the write path exactly the invented 0/0/0 it refuses to send \u2014 that safeguard only\n // works if this cache never lies about a band.\n if (low === undefined || mid === undefined || high === undefined) {\n return;\n }\n this.lastEqualizer.set(zone, { low, mid, high });\n return;\n }\n this.lastEqualizer.set(zone, { low: low ?? cur.low, mid: mid ?? cur.mid, high: high ?? cur.high });\n }\n\n /**\n * Apply a mapped command. A plain command runs its client call directly; the two\n * commands that need controller-cached state (equalizer bands, tuner band) are\n * completed here \u2014 the only place that state lives.\n *\n * @param stateId the written state id, for the failure log line\n * @param command the YXC command to apply\n */\n private async applyCommand(stateId: string, command: YxcCommand): Promise<void> {\n try {\n switch (command.kind) {\n case \"run\":\n await command.run(this.deps.client);\n break;\n case \"equalizer\": {\n // The device sets all three bands in one call, so the other two come from the\n // cache. Without a cached set we must NOT invent 0/0/0 \u2014 that would silently\n // flatten the user's other two bands. The cache fills from a zone status, so\n // fetch one first; only if even that fails is the write refused (with a warning).\n const { zone, band, value } = command;\n let current = this.lastEqualizer.get(zone);\n if (!current) {\n await this.refreshZone(zone);\n current = this.lastEqualizer.get(zone);\n }\n if (!current) {\n this.deps.log.warn(\n `${this.deviceId}: not writing ${stateId} \u2014 the device has not reported its equalizer bands yet`,\n );\n break;\n }\n const next = { ...current, [band]: value };\n // Cache BEFORE the round-trip: a second band written straight afterwards\n // reads this cache at dispatch \u2014 caching after the await would make it\n // compute from the pre-write triple and undo this band on the device.\n this.lastEqualizer.set(zone, next);\n await this.deps.client.setEqualizer(next.low, next.mid, next.high, zone);\n break;\n }\n case \"tunerBand\":\n // Remember it BEFORE the round-trip: a frequency written straight afterwards\n // reads this cache synchronously at dispatch, while the band call may still\n // be in flight \u2014 and the poll that would report it back runs minutes later.\n this.lastTunerBand = command.band;\n await this.deps.client.setBand(command.band);\n break;\n case \"tunerFreq\":\n await this.deps.client.setFreq(this.lastTunerBand, command.value);\n break;\n case \"tunerPreset\": {\n // Shared-list devices recall on `common`; separate-list devices on the current band.\n const band = this.tunerFeatures?.presetType === \"common\" ? \"common\" : this.lastTunerBand;\n await this.deps.client.recallTunerPreset(band, command.value, this.zoneListeningTo(\"tuner\"));\n break;\n }\n case \"netusbPreset\":\n await this.deps.client.recallPreset(command.value, this.zoneListeningTo(this.lastNetusbInput));\n break;\n case \"netusbRecent\":\n await this.deps.client.recallRecentItem(command.value, this.zoneListeningTo(this.lastNetusbInput));\n break;\n case \"playerTransport\": {\n // The unified block's buttons act on whatever the ZONE is playing (v2.0.0) \u2014\n // derived FRESH from the zone's input, never from the routing map: a stale\n // map entry would send the command to the source the zone just left.\n const block = this.playerBlockFor(this.lastZoneInput.get(command.zone));\n if (block === undefined) {\n this.deps.log.debug(`${this.deviceId}: ${stateId} ignored \u2014 ${command.zone} is not playing a media source`);\n break;\n }\n await this.runTransport(block, command.action);\n break;\n }\n }\n } catch (e) {\n this.deps.log.warn(`${this.deviceId}: write to ${stateId} failed: ${errorMessage(e)}`);\n }\n }\n\n /**\n * Run one transport action on the given player source. The CD transport routes\n * through the one `setCDPlayback(action)` method (not the per-action helpers, one\n * of which sends the wrong command in the library).\n *\n * @param block the source the zone is playing\n * @param action the transport action\n */\n private async runTransport(block: \"netusb\" | \"cd\", action: PlayerTransport): Promise<void> {\n const client = this.deps.client;\n if (block === \"netusb\") {\n const net: Record<PlayerTransport, () => Promise<unknown>> = {\n play: () => client.playNet(),\n pause: () => client.pauseNet(),\n stop: () => client.stopNet(),\n next: () => client.nextNet(),\n prev: () => client.prevNet(),\n repeatToggle: () => client.toggleNetRepeat(),\n shuffleToggle: () => client.toggleNetShuffle(),\n };\n await net[action]();\n return;\n }\n const cd: Record<PlayerTransport, () => Promise<unknown>> = {\n play: () => client.setCDPlayback(\"play\"),\n pause: () => client.setCDPlayback(\"pause\"),\n stop: () => client.setCDPlayback(\"stop\"),\n next: () => client.setCDPlayback(\"next\"),\n prev: () => client.setCDPlayback(\"previous\"),\n repeatToggle: () => client.toggleCDRepeat(),\n shuffleToggle: () => client.toggleCDShuffle(),\n };\n await cd[action]();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,wBAA8E;AAC9E,2BAAgC;AAChC,4BAgBO;AACP,kBAAqE;AAErE,kBAAsB;AAGtB,kBAA6B;AAC7B,gCAAiC;AAEjC,mBAA2B;AAC3B,0BAAgD;AAGhD,qBAAoC;AACpC,+BAAgC;AAGhC,MAAM,eAAe,IAAI,KAAK;AAM9B,MAAM,6BAA6B;AAQnC,SAAS,cAAc,YAAyC;AAC9D,QAAM,QAAS,yCAAgD;AAC/D,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAYO,SAAS,aAAa,UAAuC;AAClE,QAAM,QAAS,qCAA6C;AAC5D,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,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