node client to connect to a JMRI xmlio webservice this allows basic control of a model railroad layout via DCC
"use strict";
import { JmriClient } from "jmri-client";
const client = new JmriClient('http', 'jmri.local', 12080);
get status of layout power (on or off)
await client.getPower().then((res) => {
console.log(res);
});
turn layout power on/off
await client.setPower(true).then((res) => {
console.log(res);
});
get full status data for a given address or array of addresses (eg [11, 38])
await client.getThrottle(addresses);
set speed for specified throttle address
await client.setThrottleSpeed(address, speed);
set direction for specified address use 'true' for forward, 'false' for backward
await client.setThrottleDirection(address, direction);
set function value specified address and function
await client.setThrottleFunction(address, functionNumber, value);
list all turnouts with current status
await client.getTurnouts();
set status of specific turnout by address
await client.setTurnout(address, value);