set_power
Control DCC power by switching it on or off, then verify the actual state. Avoids redundant commands and handles exhibition-mode restrictions honestly.
Instructions
Turn a DCC system's power ON or OFF, and report the state actually observed.
Args: system: System name, prefix, or fragment (e.g. "ohara", "O"). Case-insensitive. Omit to use JMRI's default system. turn_on: True to turn power ON, False to turn it OFF.
This writes to JMRI. The reported state is re-read ~1s after the command (JMRI's immediate POST response is transient/unreliable) — if the observed state doesn't match the request, "confirmed" will be false and the caller should say so honestly rather than assume success.
Safe to call repeatedly with the same turn_on value, including right after another call already set that state: current state is always checked first, and nothing is sent to JMRI if it already matches the request — re-POSTing a state JMRI already reports is a real bug (JMRI/JMRI#15279) that knocks the system into UNKNOWN. JMRI 5.17.1+ self-recovers from that within seconds; older JMRI doesn't, so this result may include "outdated_jmri_version" — tell the user to upgrade JMRI rather than expect this to self-heal.
In exhibition mode, turn_on=True is REFUSED (returns an error, power stays off) — turn_on=False (an emergency power cut) always still works. See enter_exhibition_mode.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| system | Yes | ||
| turn_on | Yes |