mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 08:27:56 +00:00
Added ac bounds in model
implemented bounds in AC Temp controls
This commit is contained in:
@@ -31,7 +31,9 @@ class AcCubit extends Cubit<AcState> {
|
||||
}
|
||||
|
||||
void setACTemp(ACModel model, double temp) {
|
||||
model.temperature = temp;
|
||||
if (model.bounds.min <= temp && temp <= model.bounds.max) {
|
||||
model.temperature = temp;
|
||||
}
|
||||
emit(ACsTempChanged(temp));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
location: '',
|
||||
image: '',
|
||||
timer: null,
|
||||
bounds: Bounds(
|
||||
min: 20,
|
||||
max: 30,
|
||||
),
|
||||
),
|
||||
ACModel(
|
||||
name: "Master Bedroom AC",
|
||||
@@ -48,6 +52,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
location: '',
|
||||
image: '',
|
||||
timer: null,
|
||||
bounds: Bounds(
|
||||
min: 20,
|
||||
max: 30,
|
||||
),
|
||||
),
|
||||
ACModel(
|
||||
name: "Kitchen AC",
|
||||
@@ -61,6 +69,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
location: '',
|
||||
image: '',
|
||||
timer: null,
|
||||
bounds: Bounds(
|
||||
min: 20,
|
||||
max: 30,
|
||||
),
|
||||
),
|
||||
ACModel(
|
||||
name: "Bathroom AC",
|
||||
@@ -74,6 +86,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
location: '',
|
||||
image: '',
|
||||
timer: null,
|
||||
bounds: Bounds(
|
||||
min: 20,
|
||||
max: 30,
|
||||
),
|
||||
),
|
||||
],
|
||||
icon: Assets.iconsAC,
|
||||
|
||||
@@ -9,11 +9,14 @@ class ACModel extends DeviceModel {
|
||||
|
||||
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,
|
||||
@@ -51,6 +54,31 @@ class ACModel extends DeviceModel {
|
||||
image: json['image'],
|
||||
timer: json['timer'],
|
||||
coolTo: json['coolTo'],
|
||||
bounds: Bounds.fromJson(json['bounds']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user