mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
41 lines
1.1 KiB
Dart
41 lines
1.1 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>;
|
|
|
|
final switchAlarmSound = status.firstWhere(
|
|
(item) => item['code'] == 'switch_alarm_sound',
|
|
)['value'] as bool;
|
|
final masterState = status.firstWhere(
|
|
(item) => item['code'] == 'master_state',
|
|
)['value'] as String;
|
|
final factoryReset = status.firstWhere(
|
|
(item) => item['code'] == 'factory_reset',
|
|
)['value'] as bool;
|
|
final alarmActive = status.firstWhere(
|
|
(item) => item['code'] == 'alarm_active',
|
|
)['value'] as String;
|
|
|
|
return GatewayModel(
|
|
uuid: json['uuid'] as String,
|
|
switchAlarmSound: switchAlarmSound,
|
|
masterState: masterState,
|
|
factoryReset: factoryReset,
|
|
alarmActive: alarmActive,
|
|
);
|
|
}
|
|
}
|