mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
51 lines
1.6 KiB
Dart
51 lines
1.6 KiB
Dart
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
|
|
|
class CeilingSensorModel {
|
|
String presenceState;
|
|
int sensitivity;
|
|
String checkingResult;
|
|
int presenceRange;
|
|
int sportsPara;
|
|
String bodyMovement;
|
|
|
|
CeilingSensorModel(
|
|
{required this.presenceState,
|
|
required this.sensitivity,
|
|
required this.checkingResult,
|
|
required this.presenceRange,
|
|
required this.sportsPara,
|
|
required this.bodyMovement});
|
|
|
|
factory CeilingSensorModel.fromJson(List<StatusModel> jsonList) {
|
|
late String _presenceState;
|
|
late int _sensitivity;
|
|
late String _checkingResult;
|
|
int _presenceRange = 1;
|
|
int _sportsPara = 1;
|
|
String _bodyMovement = 'none';
|
|
|
|
for (int i = 0; i < jsonList.length; i++) {
|
|
if (jsonList[i].code == 'presence_state') {
|
|
_presenceState = jsonList[i].value ?? 'none';
|
|
} else if (jsonList[i].code == 'sensitivity') {
|
|
_sensitivity = jsonList[i].value ?? 1;
|
|
} else if (jsonList[i].code == 'checking_result') {
|
|
_checkingResult = jsonList[i].value ?? '';
|
|
} else if (jsonList[i].code == 'presence_range') {
|
|
_presenceRange = jsonList[i].value ?? 0;
|
|
} else if (jsonList[i].code == 'sports_para') {
|
|
_sportsPara = jsonList[i].value ?? 0;
|
|
} else if (jsonList[i].code == 'body_movement') {
|
|
_bodyMovement = jsonList[i].value ?? '';
|
|
}
|
|
}
|
|
return CeilingSensorModel(
|
|
presenceState: _presenceState,
|
|
sensitivity: _sensitivity,
|
|
checkingResult: _checkingResult,
|
|
presenceRange: _presenceRange,
|
|
sportsPara: _sportsPara,
|
|
bodyMovement: _bodyMovement);
|
|
}
|
|
}
|