mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
push switch autoaomtion status update
This commit is contained in:
@ -32,11 +32,15 @@ class SceneDetailsModel {
|
||||
name: json["name"],
|
||||
status: json["status"],
|
||||
type: json["type"],
|
||||
actions:
|
||||
List<Action>.from(json["actions"].map((x) => Action.fromJson(x))),
|
||||
actions: (json["actions"] as List)
|
||||
.map((x) => Action.fromJson(x))
|
||||
.where((x) => x != null)
|
||||
.toList()
|
||||
.cast<Action>(),
|
||||
conditions: json["conditions"] != null
|
||||
? List<Condition>.from(
|
||||
json["conditions"].map((x) => Condition.fromJson(x)))
|
||||
? (json["conditions"] as List)
|
||||
.map((x) => Condition.fromJson(x))
|
||||
.toList()
|
||||
: null,
|
||||
decisionExpr: json["decisionExpr"],
|
||||
effectiveTime: json["effectiveTime"] != null
|
||||
@ -69,15 +73,19 @@ class Action {
|
||||
required this.executorProperty,
|
||||
});
|
||||
|
||||
factory Action.fromRawJson(String str) => Action.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Action.fromJson(Map<String, dynamic> json) => Action(
|
||||
actionExecutor: json["actionExecutor"],
|
||||
entityId: json["entityId"],
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
);
|
||||
static Action? fromJson(Map<String, dynamic> json) {
|
||||
if (json["executorProperty"] == null) {
|
||||
return null; // Return null if executorProperty is not present
|
||||
}
|
||||
|
||||
return Action(
|
||||
actionExecutor: json["actionExecutor"],
|
||||
entityId: json["entityId"],
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"actionExecutor": actionExecutor,
|
||||
|
38
lib/features/scene/model/update_automation.dart
Normal file
38
lib/features/scene/model/update_automation.dart
Normal file
@ -0,0 +1,38 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class AutomationStatusUpdate {
|
||||
final String unitUuid;
|
||||
final bool isEnable;
|
||||
|
||||
AutomationStatusUpdate({
|
||||
required this.unitUuid,
|
||||
required this.isEnable,
|
||||
});
|
||||
|
||||
factory AutomationStatusUpdate.fromRawJson(String str) =>
|
||||
AutomationStatusUpdate.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory AutomationStatusUpdate.fromJson(Map<String, dynamic> json) =>
|
||||
AutomationStatusUpdate(
|
||||
unitUuid: json["unitUuid"],
|
||||
isEnable: json["isEnable"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"unitUuid": unitUuid,
|
||||
"isEnable": isEnable,
|
||||
};
|
||||
|
||||
factory AutomationStatusUpdate.fromMap(Map<String, dynamic> map) =>
|
||||
AutomationStatusUpdate(
|
||||
unitUuid: map["unitUuid"],
|
||||
isEnable: map["isEnable"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"unitUuid": unitUuid,
|
||||
"isEnable": isEnable,
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user