Interface PowerSensor

Represents any sensor that reports voltage, current, and/or power

interface PowerSensor {
    name: string;
    doCommand(command: Struct): Promise<JsonValue>;
    getCurrent(extra?: Struct): Promise<readonly [number, boolean]>;
    getPower(extra?: Struct): Promise<number>;
    getReadings(extra?: Struct): Promise<Record<string, JsonValue>>;
    getVoltage(extra?: Struct): Promise<readonly [number, boolean]>;
}

Hierarchy (View Summary, Expand)

Implemented by

Properties

name: string

The name of the resource.

Methods

  • Send/Receive arbitrary commands to the resource.

    Parameters

    • command: Struct

      The command to execute.

    Returns Promise<JsonValue>

    const result = await resource.doCommand({
    name: 'myCommand',
    args: { key: 'value' },
    });
  • Get Current in amps and a boolean indicating whether the voltage is AC (true) or DC (false).

    Parameters

    Returns Promise<readonly [number, boolean]>

    const powerSensor = new VIAM.PowerSensorClient(
    machine,
    'my_power_sensor'
    );
    const [current, isAc] = await powerSensor.getCurrent();

    For more information, see Power Sensor API.

  • Get power in watts.

    Parameters

    Returns Promise<number>

    const powerSensor = new VIAM.PowerSensorClient(
    machine,
    'my_power_sensor'
    );
    const power = await powerSensor.getPower();

    For more information, see Power Sensor API.

  • Return the readings of a sensor.

    Parameters

    Returns Promise<Record<string, JsonValue>>

    const powerSensor = new VIAM.PowerSensorClient(
    machine,
    'my_power_sensor'
    );
    const readings = await powerSensor.getReadings();

    For more information, see Power Sensor API.

  • Get voltage in volts and a boolean indicating whether the voltage is AC (true) or DC (false).

    Parameters

    Returns Promise<readonly [number, boolean]>

    const powerSensor = new VIAM.PowerSensorClient(
    machine,
    'my_power_sensor'
    );
    const [voltage, isAc] = await powerSensor.getVoltage();

    For more information, see Power Sensor API.

MMNEPVFCICPMFPCPTTAAATR