{"record":{"id":"dc6ba78b98f9a3ce","repo":"AprilNEA/OpenLogi","slug":"multiple-standalone-lights-found-select-one-with-device","errorCode":null,"errorMessage":"multiple standalone lights found; select one with --device","messagePattern":"multiple standalone lights found; select one with --device","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/light.rs","lineNumber":186,"sourceCode":"        product_id: device.address.product_id,\n        usage_page: device.address.usage_page,\n        usage_id: device.address.usage_id,\n        identity: device.address.identity.clone(),\n    };\n    openlogi_hid::apply_litra(&route, model, command)\n        .await\n        .context(\"failed to write the light command\")\n}\n\nfn select<'a>(\n    devices: &'a [StandaloneDevice],\n    query: Option<&str>,\n) -> Result<&'a StandaloneDevice> {\n    let Some(query) = query else {\n        return match devices {\n            [] => Err(anyhow!(\"no supported standalone light found\")),\n            [device] => Ok(device),\n            _ => Err(anyhow!(\n                \"multiple standalone lights found; select one with --device\"\n            )),\n        };\n    };\n    let query = query.to_ascii_lowercase();\n    let mut matches = devices.iter().filter(|device| {\n        device.display_name.to_ascii_lowercase().contains(&query)\n            || device\n                .address\n                .identity\n                .to_ascii_lowercase()\n                .contains(&query)\n    });\n    let Some(device) = matches.next() else {\n        return Err(anyhow!(\"no standalone light matches --device {query}\"));\n    };\n    if matches.next().is_some() {\n        return Err(anyhow!(","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/light.rs#L168-L204","documentation":"When no `--device` query is given and more than one supported standalone light is connected, `select` refuses to guess which one the command targets and fails with this message. The error exists to force explicit disambiguation rather than silently applying a command to an arbitrary device.","triggerScenarios":"Calling `set_power`, `set_brightness`, or `set_temperature` (or `selection_requires_disambiguation_and_supports_name_queries`) without `--device` while `select` receives a `devices` slice with two or more `StandaloneDevice` entries.","commonSituations":"Two Litra Glows (or a Glow plus a Litra Beam) are attached; a dock with multiple lights is connected; you intended to target one light but forgot the `--device` flag after adding a second unit.","solutions":["Re-run the command with `--device <name-or-serial-substring>` identifying the intended light.","Run `openlogi list` (or the light list command) to see the display names/identities available for `--device`.","Physically disconnect or power off the other lights if you prefer the auto-select convenience."],"exampleFix":"// before — two lights attached, no selector\n$ openlogi light set-brightness 40\nerror: multiple standalone lights found; select one with --device\n\n// after\n$ openlogi light set-brightness 40 --device \"Beam\"","handlingStrategy":"validation","validationCode":"let devices = /* enumerate */;\nif devices.len() > 1 && device_query.is_none() {\n    eprintln!(\"{} lights attached; pass --device\", devices.len());\n    // print names to pick from\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make --device a required parameter in scripts when more than one light may be attached.","List devices first and bake the chosen identity into automation configs.","Keep only one light attached on interactive machines if you rely on auto-select."],"tags":["cli","ambiguity","device-selection"],"backgroundTag":"missing-required-argument","analyzedSha":"e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8","analyzedAt":"2026-09-13T03:07:16.451Z","contentChangedAt":"2026-09-13T03:07:16.451Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}