mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-26 19:44:56 +00:00
Bug fixes
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||
|
||||
class LivingRoomStatusModel {
|
||||
final String uuid;
|
||||
final bool switch1;
|
||||
final bool switch2;
|
||||
final bool switch3;
|
||||
|
||||
LivingRoomStatusModel({
|
||||
required this.uuid,
|
||||
required this.switch1,
|
||||
required this.switch2,
|
||||
required this.switch3,
|
||||
});
|
||||
|
||||
factory LivingRoomStatusModel.fromJson(String id, List<Status> jsonList) {
|
||||
late bool switch1;
|
||||
late bool switch2;
|
||||
late bool switch3;
|
||||
|
||||
for (var status in jsonList) {
|
||||
switch (status.code) {
|
||||
case 'switch_1':
|
||||
switch1 = status.value ?? false; // default to false if null
|
||||
break;
|
||||
case 'switch_2':
|
||||
switch2 = status.value ?? false; // default to false if null
|
||||
break;
|
||||
case 'switch_3':
|
||||
switch3 = status.value ?? false; // default to false if null
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return LivingRoomStatusModel(
|
||||
uuid: id,
|
||||
switch1: switch1,
|
||||
switch2: switch2,
|
||||
switch3: switch3,
|
||||
);
|
||||
}
|
||||
|
||||
LivingRoomStatusModel copyWith({
|
||||
String? uuid,
|
||||
bool? switch1,
|
||||
bool? switch2,
|
||||
bool? switch3,
|
||||
}) {
|
||||
return LivingRoomStatusModel(
|
||||
uuid: uuid ?? this.uuid,
|
||||
switch1: switch1 ?? this.switch1,
|
||||
switch2: switch2 ?? this.switch2,
|
||||
switch3: switch3 ?? this.switch3,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user