mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 08:41:44 +00:00
Compare commits
4 Commits
fix-back-b
...
Fix-Flush-
| Author | SHA1 | Date | |
|---|---|---|---|
| c2bf32af1c | |||
| b7a42af223 | |||
| e8e5ddd102 | |||
| fca69cef73 |
@ -171,6 +171,7 @@ class FlushSensorBloc extends Bloc<FlushSensorEvent, FlushSensorState> {
|
||||
deviceInfo = DeviceInfoModel.fromJson(response);
|
||||
deviceName = deviceInfo.name;
|
||||
emit(FlushSensorLoadingDeviceInfo(deviceInfo: deviceInfo));
|
||||
emit(FlushSensorUpdateState(flushSensorModel: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(FlushSensorFailedState(error: e.toString()));
|
||||
}
|
||||
|
||||
@ -55,31 +55,33 @@ class DeviceInfoModel {
|
||||
|
||||
factory DeviceInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceInfoModel(
|
||||
activeTime: json['activeTime'],
|
||||
category: json['category'],
|
||||
categoryName: json['categoryName'],
|
||||
createTime: json['createTime'],
|
||||
gatewayId: json['gatewayId'],
|
||||
icon: json['icon'],
|
||||
activeTime: json['activeTime'] ?? '',
|
||||
category: json['category'] ?? '',
|
||||
categoryName: json['categoryName'] ?? '',
|
||||
createTime: json['createTime'] ?? '',
|
||||
gatewayId: json['gatewayId'] ?? '',
|
||||
icon: json['icon'] ?? '',
|
||||
ip: json['ip'] ?? "",
|
||||
lat: json['lat'],
|
||||
localKey: json['localKey'],
|
||||
lon: json['lon'],
|
||||
model: json['model'],
|
||||
name: json['name'],
|
||||
nodeId: json['nodeId'],
|
||||
online: json['online'],
|
||||
ownerId: json['ownerId'],
|
||||
productName: json['productName'],
|
||||
sub: json['sub'],
|
||||
timeZone: json['timeZone'],
|
||||
updateTime: json['updateTime'],
|
||||
uuid: json['uuid'],
|
||||
productUuid: json['productUuid'],
|
||||
productType: json['productType'],
|
||||
lat: json['lat'] ?? '',
|
||||
localKey: json['localKey'] ?? '',
|
||||
lon: json['lon'] ?? '',
|
||||
model: json['model'] ?? '',
|
||||
name: json['name'] ?? '',
|
||||
nodeId: json['nodeId'] ?? '',
|
||||
online: json['online'] ?? '',
|
||||
ownerId: json['ownerId'] ?? '',
|
||||
productName: json['productName'] ?? '',
|
||||
sub: json['sub'] ?? '',
|
||||
timeZone: json['timeZone'] ?? '',
|
||||
updateTime: json['updateTime'] ?? '',
|
||||
uuid: json['uuid'] ?? '',
|
||||
productUuid: json['productUuid'] ?? '',
|
||||
productType: json['productType'] ?? '',
|
||||
permissionType: json['permissionType'] ?? '',
|
||||
macAddress: json['macAddress'],
|
||||
subspace: Subspace.fromJson(json['subspace']),
|
||||
macAddress: json['macAddress'] ?? '',
|
||||
subspace: json['subspace'] != null
|
||||
? Subspace.fromJson(json['subspace'])
|
||||
: throw ArgumentError('subspace cannot be null'),
|
||||
);
|
||||
}
|
||||
|
||||
@ -129,10 +131,10 @@ class Subspace {
|
||||
|
||||
factory Subspace.fromJson(Map<String, dynamic> json) {
|
||||
return Subspace(
|
||||
uuid: json['uuid'],
|
||||
createdAt: json['createdAt'],
|
||||
updatedAt: json['updatedAt'],
|
||||
subspaceName: json['subspaceName'],
|
||||
uuid: json['uuid'] ?? '',
|
||||
createdAt: json['createdAt'] ?? '',
|
||||
updatedAt: json['updatedAt'] ?? '',
|
||||
subspaceName: json['subspaceName'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -90,44 +90,25 @@ class Action {
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
static Action? fromJson(Map<String, dynamic> json) {
|
||||
// Safely extract required fields with null checks
|
||||
final String? actionExecutor = json["actionExecutor"] as String?;
|
||||
final String? entityId = json["entityId"] as String?;
|
||||
final String? productType = json['productType'] as String?;
|
||||
final String? deviceName = json['deviceName'] as String?;
|
||||
|
||||
// Skip invalid actions with missing required fields
|
||||
if (actionExecutor == null ||
|
||||
entityId == null ||
|
||||
productType == null ||
|
||||
deviceName == null) {
|
||||
|
||||
if (actionExecutor == null || entityId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Handle actions with 'name' and 'type'
|
||||
if (json['name'] != null && json['type'] != null) {
|
||||
return Action(
|
||||
actionExecutor: actionExecutor,
|
||||
entityId: entityId,
|
||||
name: json['name'] as String?,
|
||||
type: json['type'] as String?,
|
||||
productType: productType,
|
||||
deviceName: deviceName,
|
||||
);
|
||||
}
|
||||
|
||||
// Handle actions with 'executorProperty'
|
||||
if (json["executorProperty"] != null) {
|
||||
return Action(
|
||||
actionExecutor: actionExecutor,
|
||||
entityId: entityId,
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
productType: productType,
|
||||
deviceName: deviceName,
|
||||
);
|
||||
}
|
||||
|
||||
return null; // Skip invalid actions
|
||||
return Action(
|
||||
actionExecutor: actionExecutor,
|
||||
entityId: entityId,
|
||||
executorProperty: json["executorProperty"] != null
|
||||
? ExecutorProperty.fromJson(json["executorProperty"])
|
||||
: null,
|
||||
name: json['name'] as String?,
|
||||
type: json['type'] as String?,
|
||||
productType: json['productType'] as String? ?? 'unknown',
|
||||
deviceName: json['deviceName'] as String? ?? 'Delay Action',
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
||||
Reference in New Issue
Block a user