mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
91 lines
1.8 KiB
Dart
91 lines
1.8 KiB
Dart
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
|
|
|
class ACModel extends DeviceModel {
|
|
late double temperature;
|
|
|
|
late int fanSpeed;
|
|
|
|
late int tempMode;
|
|
|
|
late double coolTo;
|
|
|
|
late Bounds bounds;
|
|
|
|
ACModel({
|
|
required this.temperature,
|
|
required this.fanSpeed,
|
|
required this.tempMode,
|
|
required this.coolTo,
|
|
required this.bounds,
|
|
required super.id,
|
|
required super.name,
|
|
required super.type,
|
|
required super.status,
|
|
required super.image,
|
|
required super.timer,
|
|
required super.functions,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'temperature': temperature,
|
|
'fanSpeed': fanSpeed,
|
|
'tempMode': tempMode,
|
|
'coolTo': coolTo,
|
|
'id': id,
|
|
'name': name,
|
|
'status': status,
|
|
'type': type,
|
|
'image': image,
|
|
};
|
|
}
|
|
|
|
factory ACModel.fromJson(Map<String, dynamic> json) {
|
|
List<FunctionModel> func = [];
|
|
if (json['functions'] != null) {
|
|
json['functions'].forEach((v) {
|
|
func.add(FunctionModel.fromJson(v));
|
|
});
|
|
}
|
|
return ACModel(
|
|
id: json['id'],
|
|
name: json['name'],
|
|
status: json['status'],
|
|
temperature: json['temperature'],
|
|
fanSpeed: json['fanSpeed'],
|
|
tempMode: json['tempMode'],
|
|
type: json['type'],
|
|
image: json['image'],
|
|
timer: json['timer'],
|
|
coolTo: json['coolTo'],
|
|
bounds: Bounds.fromJson(json['bounds']),
|
|
functions: func,
|
|
);
|
|
}
|
|
}
|
|
|
|
class Bounds {
|
|
late double min;
|
|
late double max;
|
|
|
|
Bounds({
|
|
required this.min,
|
|
required this.max,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'min': min,
|
|
'max': max,
|
|
};
|
|
}
|
|
|
|
factory Bounds.fromJson(Map<String, dynamic> json) {
|
|
return Bounds(
|
|
min: json['min'],
|
|
max: json['max'],
|
|
);
|
|
}
|
|
}
|