Viam SDK
    Preparing search index...

    Class PowerSensorClient

    A gRPC-web client for the PowerSensor component.

    Implements

    Index

    Constructors

    Properties

    callOptions: CallOptions = ...
    name: string

    The name of the resource.

    Methods

    • Send/Receive arbitrary commands to the resource.

      Parameters

      • command: Struct | Record<string, JsonValue>

        The command to execute. Accepts either a Struct or a plain object, which will be converted automatically.

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>

      // Plain object (recommended)
      const result = await resource.doCommand({
      myCommand: { key: 'value' },
      });

      // Struct (still supported)
      import { Struct } from '@viamrobotics/sdk';

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

      Parameters

      • extra: {} = {}
      • callOptions: CallOptions = ...

      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

      • extra: {} = {}
      • callOptions: CallOptions = ...

      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

      • extra: {} = {}
      • callOptions: CallOptions = ...

      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 the status of the resource.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>

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

      Parameters

      • extra: {} = {}
      • callOptions: CallOptions = ...

      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.