mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
class GatewayModel {
|
|
final String uuid;
|
|
final bool switchAlarmSound;
|
|
final String masterState;
|
|
final bool factoryReset;
|
|
final String alarmActive;
|
|
|
|
GatewayModel({
|
|
required this.uuid,
|
|
required this.switchAlarmSound,
|
|
required this.masterState,
|
|
required this.factoryReset,
|
|
required this.alarmActive,
|
|
});
|
|
|
|
factory GatewayModel.fromJson(Map<String, dynamic> json) {
|
|
final status = json['status'] as List<dynamic>? ?? <dynamic>[];
|
|
|
|
bool? switchAlarmSound;
|
|
String? masterState;
|
|
bool? factoryReset;
|
|
String? alarmActive;
|
|
|
|
for (final item in status) {
|
|
switch (item['code']) {
|
|
case 'switch_alarm_sound':
|
|
switchAlarmSound = item['value'] as bool;
|
|
break;
|
|
case 'master_state':
|
|
masterState = item['value'] as String;
|
|
break;
|
|
case 'factory_reset':
|
|
factoryReset = item['value'] as bool;
|
|
break;
|
|
case 'alarm_active':
|
|
alarmActive = item['value'] as String;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return GatewayModel(
|
|
uuid: json['uuid'] as String? ?? '',
|
|
switchAlarmSound: switchAlarmSound ?? false,
|
|
masterState: masterState ?? '',
|
|
factoryReset: factoryReset ?? false,
|
|
alarmActive: alarmActive ?? '',
|
|
);
|
|
}
|
|
}
|