mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
32 lines
977 B
Dart
32 lines
977 B
Dart
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
|
|
|
class CeilingSensorModel {
|
|
String presenceState;
|
|
int sensitivity;
|
|
String checkingResult;
|
|
|
|
CeilingSensorModel({
|
|
required this.presenceState,
|
|
required this.sensitivity,
|
|
required this.checkingResult,
|
|
});
|
|
|
|
factory CeilingSensorModel.fromJson(List<StatusModel> jsonList) {
|
|
late String _presenceState;
|
|
late int _sensitivity;
|
|
late String _checkingResult;
|
|
|
|
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 ?? false;
|
|
} else if (jsonList[i].code == 'checking_result') {
|
|
_checkingResult = jsonList[i].value ?? false;
|
|
}
|
|
}
|
|
return CeilingSensorModel(
|
|
presenceState: _presenceState, sensitivity: _sensitivity, checkingResult: _checkingResult);
|
|
}
|
|
}
|