mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 06:17:55 +00:00
garage door
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class GarageDoorModel {
|
||||
bool switch1;
|
||||
bool doorContactState;
|
||||
int countdown1;
|
||||
int countdownAlarm;
|
||||
String doorControl1;
|
||||
bool voiceControl1;
|
||||
String doorState1;
|
||||
int batteryPercentage;
|
||||
int tr_timecon;
|
||||
|
||||
GarageDoorModel({
|
||||
required this.switch1,
|
||||
required this.doorContactState,
|
||||
required this.countdown1,
|
||||
required this.countdownAlarm,
|
||||
required this.doorControl1,
|
||||
required this.voiceControl1,
|
||||
required this.doorState1,
|
||||
required this.batteryPercentage,
|
||||
required this.tr_timecon,
|
||||
});
|
||||
|
||||
factory GarageDoorModel.fromJson(List<StatusModel> jsonList) {
|
||||
late bool _switch1 = false;
|
||||
late bool _doorContactState = false;
|
||||
late int _countdown1 = 0;
|
||||
late int _countdownAlarm = 0;
|
||||
late String _doorControl1 = "closed";
|
||||
late bool _voiceControl1 = false;
|
||||
late String _doorState1 = "closed";
|
||||
late int _batteryPercentage = 0;
|
||||
late int _tr_timecon = 0;
|
||||
|
||||
for (var status in jsonList) {
|
||||
switch (status.code) {
|
||||
case 'tr_timecon':
|
||||
_tr_timecon = status.value ?? "closed";
|
||||
break;
|
||||
case 'switch_1':
|
||||
_switch1 = status.value ?? false;
|
||||
break;
|
||||
case 'doorcontact_state':
|
||||
_doorContactState = status.value ?? false;
|
||||
break;
|
||||
case 'countdown_1':
|
||||
_countdown1 = status.value ?? 0;
|
||||
break;
|
||||
case 'countdown_alarm':
|
||||
_countdownAlarm = status.value ?? 0;
|
||||
break;
|
||||
case 'door_control_1':
|
||||
_doorControl1 = status.value ?? "closed";
|
||||
break;
|
||||
|
||||
case 'voice_control_1':
|
||||
_voiceControl1 = status.value ?? false;
|
||||
break;
|
||||
case 'door_state_1':
|
||||
_doorState1 = status.value ?? "closed";
|
||||
break;
|
||||
case 'battery_percentage':
|
||||
_batteryPercentage = status.value ?? 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return GarageDoorModel(
|
||||
switch1: _switch1,
|
||||
doorContactState: _doorContactState,
|
||||
countdown1: _countdown1,
|
||||
countdownAlarm: _countdownAlarm,
|
||||
doorControl1: _doorControl1,
|
||||
voiceControl1: _voiceControl1,
|
||||
doorState1: _doorState1,
|
||||
batteryPercentage: _batteryPercentage,
|
||||
tr_timecon: _tr_timecon);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user