voltage method

  1. @override
Future<Voltage> voltage({
  1. Map<String, dynamic>? extra,
})
override

Get the voltage in volts, and whether the power is AC (true) or DC (false).

var voltageObject = await myPowerSensor.voltage();
double voltageInVolts = voltageObject.volts;
bool isItAC = voltageObject.isAc;

For more information, see Power Sensor component.

Implementation

@override
Future<Voltage> voltage({Map<String, dynamic>? extra}) async {
  final request = GetVoltageRequest()
    ..name = name
    ..extra = extra?.toStruct() ?? Struct();
  return await client.getVoltage(request);
}