class DeviceLog {
  String? thingId;
  DateTime? from;
  DateTime? to;
  int? total;
  int? offset;
  List<SensorLogs>? sensors;

  DeviceLog({
    this.thingId,
    this.from,
    this.to,
    this.total,
    this.offset,
    this.sensors,
  });

  DeviceLog.fromJson(Map<String, dynamic> json) {
    thingId = json["thing_id"];
    from = DateTime.parse(json["from"]);
    to = DateTime.parse(json["to"]);
    total = json["total"];
    offset = json["offset"];
    if (json['sensors'] != null) {
      sensors = [];
      json['sensors'].forEach((v) {
        sensors!.add(SensorLogs.fromJson(v));
      });
    }
  }
}

class SensorLogs {
  String? name;
  int? value;
  int? time;
  LogDetail? detail;

  SensorLogs({
    this.name,
    this.value,
    this.time,
    this.detail,
  });
  SensorLogs.fromJson(Map<String, dynamic> json) {
    name = json["n"];
    value = json["v"];
    time = json["t"];
    detail = json["x"] != null ? LogDetail.fromJson(json["x"]) : null;
  }
}

class LogDetail {
  String? username;
  String? note;

  LogDetail({
    this.username,
    this.note,
  });

  LogDetail.fromJson(Map<String, dynamic> json) {
    username = json["username"];
    note = json["note"];
  }
}
