mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 01:35:25 +00:00
Implemented WPS device
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.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<Status> 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 ?? 0;
|
||||
} else if (jsonList[i].code == 'presence_time') {
|
||||
_presenceTime = jsonList[i].value ?? 0;
|
||||
} 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 ?? false;
|
||||
}
|
||||
}
|
||||
return WallSensorModel(
|
||||
presenceState: _presenceState,
|
||||
farDetection: _farDetection,
|
||||
presenceTime: _presenceTime,
|
||||
motionSensitivity: _motionSensitivity,
|
||||
motionlessSensitivity: _motionlessSensitivity,
|
||||
currentDistance: _currentDistance,
|
||||
illuminance: _illuminance,
|
||||
indicator: _indicator);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user