push switch autoaomtion status update

This commit is contained in:
ashrafzarkanisala
2024-07-28 06:57:33 +03:00
parent 50b455b4ae
commit eb8ad90dcb
12 changed files with 280 additions and 104 deletions

View File

@ -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,

View 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,
};
}