sendUserSensorData method

Future<bool> sendUserSensorData(
  1. String sensorId,
  2. String value, {
  3. List<MultilingualValues>? description,
  4. String? urgency,
})

Send some user sensor data to GeigerToolbox

Implementation

Future<bool> sendUserSensorData(String sensorId, String value,
    {List<MultilingualValues>? description, String? urgency}) async {
  String nodePath = '$userSensorDataRootPath:$sensorId';
  try {
    Node node = await storageController!.get(nodePath);
    node.addOrUpdateValue(NodeValueImpl('GEIGERvalue', value));
    if (description != null && description.isNotEmpty) {
      await updateMultilingualValues(node, 'description', description);
    }
    if (urgency != null) {
      node.addOrUpdateValue(NodeValueImpl('urgency', urgency));
    }

    // if (recommendationId != null) {
    //   node.addOrUpdateValue(
    //     NodeValueImpl('currentRecommendationId', recommendationId),
    //   );
    // }
    await storageController!.addOrUpdate(node);
    log('Updated node: ');
    log(node.toString());
    return true;
  } catch (e, trace) {
    log('Failed to send a data node $nodePath');
    log(e.toString());
    if (exceptionHandler != null) {
      exceptionHandler!(e, trace);
    }
    return false;
  }
}