Implemented ceiling, wall sensors functionality

This commit is contained in:
Abdullah Alassaf
2024-05-22 23:55:35 +03:00
parent 008ba8be32
commit 44b08c482d
26 changed files with 1296 additions and 493 deletions
@@ -0,0 +1,31 @@
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);
}
}
+116
View File
@@ -0,0 +1,116 @@
import 'package:syncrow_app/features/devices/model/status_model.dart';
class SmartDoorModel {
String unlockFingerprint;
int unlockPassword;
int unlockTemporary;
int unlockCard;
String unlockAlarm;
int unlockRequest;
int residualElectricity;
bool reverseLock;
int unlockApp;
bool hijack;
bool doorbell;
String unlockOfflinePd;
String unlockOfflineClear;
String unlockDoubleKit;
String remoteNoPdSetkey;
String remoteNoDpKey;
bool normalOpenSwitch;
SmartDoorModel(
{required this.unlockFingerprint,
required this.unlockPassword,
required this.unlockTemporary,
required this.unlockCard,
required this.unlockAlarm,
required this.unlockRequest,
required this.residualElectricity,
required this.reverseLock,
required this.unlockApp,
required this.hijack,
required this.doorbell,
required this.unlockOfflinePd,
required this.unlockOfflineClear,
required this.unlockDoubleKit,
required this.remoteNoPdSetkey,
required this.remoteNoDpKey,
required this.normalOpenSwitch});
factory SmartDoorModel.fromJson(List<StatusModel> jsonList) {
late String _unlockFingerprint;
late int _unlockPassword;
late int _unlockTemporary;
late int _unlockCard;
late String _unlockAlarm;
late int _unlockRequest;
late int _residualElectricity;
late bool _reverseLock;
late int _unlockApp;
late bool _hijack;
late bool _doorbell;
late String _unlockOfflinePd;
late String _unlockOfflineClear;
late String _unlockDoubleKit;
late String _remoteNoPdSetkey;
late String _remoteNoDpKey;
late bool _normalOpenSwitch;
for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'unlock_fingerprint') {
_unlockFingerprint = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'unlock_password') {
_unlockPassword = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'unlock_temporary') {
_unlockTemporary = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'unlock_card') {
_unlockCard = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'alarm_lock') {
_unlockAlarm = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'unlock_request') {
_unlockRequest = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'residual_electricity') {
_residualElectricity = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'reverse_lock') {
_reverseLock = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'unlock_app') {
_unlockApp = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'hijack') {
_hijack = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'doorbell') {
_doorbell = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'unlock_offline_pd') {
_unlockOfflinePd = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'unlock_offline_clear') {
_unlockOfflineClear = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'unlock_double_kit') {
_unlockDoubleKit = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'remote_no_pd_setkey') {
_remoteNoPdSetkey = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'remote_no_dp_key') {
_remoteNoDpKey = jsonList[i].value ?? '';
} else if (jsonList[i].code == 'normal_open_switch') {
_normalOpenSwitch = jsonList[i].value ?? false;
}
}
return SmartDoorModel(
unlockFingerprint: _unlockFingerprint,
unlockPassword: _unlockPassword,
unlockTemporary: _unlockTemporary,
unlockCard: _unlockCard,
unlockAlarm: _unlockAlarm,
unlockRequest: _unlockRequest,
residualElectricity: _residualElectricity,
reverseLock: _reverseLock,
unlockApp: _unlockApp,
hijack: _hijack,
doorbell: _doorbell,
unlockOfflinePd: _unlockOfflinePd,
unlockOfflineClear: _unlockOfflineClear,
unlockDoubleKit: _unlockDoubleKit,
remoteNoPdSetkey: _remoteNoPdSetkey,
remoteNoDpKey: _remoteNoDpKey,
normalOpenSwitch: _normalOpenSwitch);
}
}
@@ -0,0 +1,63 @@
import 'package:syncrow_app/features/devices/model/status_model.dart';
class WallSensorModel {
String presenceState;
int farDetection;
int presenceTime;
int motionSensitivity;
int motionlessSensitivity;
int currentDistance;
int illuminance;
bool indicator;
WallSensorModel({
required this.presenceState,
required this.farDetection,
required this.presenceTime,
required this.motionSensitivity,
required this.motionlessSensitivity,
required this.currentDistance,
required this.illuminance,
required this.indicator,
});
factory WallSensorModel.fromJson(List<StatusModel> jsonList) {
late String _presenceState;
late int _farDetection;
late int _presenceTime;
late int _motionSensitivity;
late int _motionlessSensitivity;
late int _currentDistance;
late int _illuminance;
late bool _indicator;
for (int i = 0; i < jsonList.length; i++) {
if (jsonList[i].code == 'presence_state') {
_presenceState = jsonList[i].value ?? 'none';
} else if (jsonList[i].code == 'far_detection') {
_farDetection = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'presence_time') {
_presenceTime = jsonList[i].value ?? false;
} else if (jsonList[i].code == 'motion_sensitivity_value') {
_motionSensitivity = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'motionless_sensitivity') {
_motionlessSensitivity = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'dis_current') {
_currentDistance = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'illuminance_value') {
_illuminance = jsonList[i].value ?? 0;
} else if (jsonList[i].code == 'indicator') {
_indicator = jsonList[i].value ?? 0;
}
}
return WallSensorModel(
presenceState: _presenceState,
farDetection: _farDetection,
presenceTime: _presenceTime,
motionSensitivity: _motionSensitivity,
motionlessSensitivity: _motionlessSensitivity,
currentDistance: _currentDistance,
illuminance: _illuminance,
indicator: _indicator);
}
}