{"record":{"id":"1ff7f5f63bdd5d06","repo":"AprilNEA/OpenLogi","slug":"lumens-must-be-in-the-supported-range-with-step","errorCode":null,"errorMessage":"lumens must be in the supported range {}..={} with step {}","messagePattern":"lumens must be in the supported range (.+?)\\.\\.=(.+?) with step (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/light.rs","lineNumber":131,"sourceCode":"    let devices = standalone().await?;\n    let device = select(&devices, query)?;\n    apply(device, LightCommand::Power(enabled)).await\n}\n\nasync fn set_brightness(args: BrightnessArgs) -> Result<()> {\n    let devices = standalone().await?;\n    let device = select(&devices, args.device.device.as_deref())?;\n    let caps = device\n        .light_capabilities\n        .ok_or_else(|| anyhow!(\"selected light did not advertise capabilities\"))?;\n    let range = caps\n        .brightness\n        .ok_or_else(|| anyhow!(\"selected light does not support brightness\"))?;\n    let command = match (args.percent, args.lumens) {\n        (Some(percent), None) => LightCommand::BrightnessPercent(percent),\n        (None, Some(lumens)) => {\n            if range.unit() != LightValueUnit::Lumens || !range.contains(lumens) {\n                return Err(anyhow!(\n                    \"lumens must be in the supported range {}..={} with step {}\",\n                    range.min(),\n                    range.max(),\n                    range.step()\n                ));\n            }\n            LightCommand::BrightnessNative(lumens)\n        }\n        (None, None) => return Err(anyhow!(\"pass either --percent or --lumens\")),\n        (Some(_), Some(_)) => unreachable!(\"clap enforces the argument conflict\"),\n    };\n    apply(device, command).await\n}\n\nasync fn set_temperature(args: TemperatureArgs) -> Result<()> {\n    let devices = standalone().await?;\n    let device = select(&devices, args.device.device.as_deref())?;\n    apply(device, LightCommand::TemperatureKelvin(args.kelvin)).await","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/light.rs#L113-L149","documentation":"Raised in `set_brightness` when `--lumens` is given but the value is outside the device's advertised brightness range or the device's range is not expressed in lumens. The CLI validates against `range.contains(lumens)` and `range.unit() == Lumens` before sending a BrightnessNative command, embedding min/max/step in the message.","triggerScenarios":"`openlogi light ... brightness --lumens N` where N < range.min(), N > range.max(), N violates range.step(), or the device's brightness range uses a different unit than lumens.","commonSituations":"Guessing lumen values instead of reading the device's advertised range from the error message; confusing percent vs native lumen interfaces; typos like 1000 instead of 100.","solutions":["Read the supported range from the error text and pass a value within min..=max honoring step","Use `--percent` instead of `--lumens` for unit-independent brightness control","Check `openlogi list`/device docs for the actual native range before scripting values"],"exampleFix":"// before\nopenlogi light brightness --lumens 500\n// after\nopenlogi light brightness --percent 50\n# or use a value inside the advertised range, e.g. min=20 max=200 step=10:\nopenlogi light brightness --lumens 200","handlingStrategy":"validation","validationCode":"let range = &caps.brightness.expect(\"checked earlier\");\nif !range.contains(lumens) || range.unit() != LightValueUnit::Lumens {\n    anyhow::bail!(\"lumens {} outside {}..={} step {}\", lumens, range.min(), range.max(), range.step());\n}","typeGuard":"fn lumens_in_range(range: &BrightnessRange, v: u32) -> bool {\n    range.unit() == LightValueUnit::Lumens && range.contains(v)\n}","tryCatchPattern":"match set_brightness(args).await {\n    Ok(()) => (),\n    Err(e) if e.to_string().contains(\"supported range\") => {\n        eprintln!(\"{}\\nUse --percent instead for unit-safe control.\", e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Prefer `--percent` over `--lumens` unless you need native precision","Parse min/max/step from the error or `openlogi list` before sending values","Clamp and step-align scripted lumen values to the advertised range"],"tags":["cli","validation","lighting","range"],"backgroundTag":"value-out-of-range","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"}