set_loco_lights
Turn on or off all light-related functions of a DCC locomotive's address. Uses JMRI roster function labels to identify and toggle lights like headlights or cab lights.
Instructions
Turn ON/OFF EVERY light-related function of ONE locomotive in a single call.
Args: address: DCC address. Auto-acquires the throttle if needed. state: True to turn every light-related function on, False off.
Different from lights_on/lights_off (F0 only). Reads the roster function LABELS (set by the user in JMRI's roster editor — see get_locomotive_functions) and switches every function whose label names a light: "light"/"lamp"/"headlight" (EN) or "lumière"/"feu"/ "lampe"/"phare" (FR), case/accent-insensitive. Example: Autorail has F0="Lumières avant", F1="Lumières cabine", F2="Lumières arrières" — all three light-labeled, so "all lights" must flip all three, not just F0. Use for "all"/"every"/"toutes les lumières" with a named locomotive — never loop set_function yourself.
No light-labeled functions is NOT an error: returns an empty "applied" list with a "note". Only ask for an explicit F-number as a fallback then.
For "all locos" (no locomotive named), use set_all_locos_lights. For layout/scenery lighting (JMRI Light objects), use set_layout_lights instead.
Returns {"address", "applied": [{"function", "label", "state"}...], "failed": [...]} — catch-and-continue per function.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| state | Yes | ||
| address | Yes |