readings method

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

Get the measurements or readings from this PowerSensor. If a sensor is not configured correctly or fails to read a piece of data, it will not appear in the readings dictionary.

var readings = await myPowerSensor.readings();

For more information, see Power Sensor component.

Implementation

@override
Future<Map<String, dynamic>> readings({Map<String, dynamic>? extra}) async {
  final request = GetReadingsRequest()
    ..name = name
    ..extra = extra?.toStruct() ?? Struct();
  final response = await client.getReadings(request);
  return response.readings.map((key, value) => MapEntry(key, value.toPrimitive()));
}