fixed automation

This commit is contained in:
hannathkadher
2024-11-02 23:10:24 +04:00
parent dcccc4db3a
commit 87a4a88417
13 changed files with 240 additions and 132 deletions

View File

@ -3,32 +3,40 @@ import 'dart:typed_data';
class ScenesModel {
final String id;
final String? sceneTuyaId;
final String name;
final String status;
final String type;
final String icon;
final String? icon;
ScenesModel(
{required this.id,
this.sceneTuyaId,
required this.name,
required this.status,
required this.type,
required this.icon});
this.icon});
factory ScenesModel.fromRawJson(String str) => ScenesModel.fromJson(json.decode(str));
factory ScenesModel.fromRawJson(String str) =>
ScenesModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
Uint8List get iconInBytes => base64Decode(icon);
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
id: json["uuid"],
name: json["name"] ?? '',
status: json["status"] ?? '',
type: json["type"] ?? '',
icon: json["icon"] ?? '');
Uint8List get iconInBytes => base64Decode(icon ?? '');
factory ScenesModel.fromJson(Map<String, dynamic> json) {
return ScenesModel(
id: json["id"] ?? json["uuid"] ?? '', // Fallback to empty string if id is null
sceneTuyaId: json["sceneTuyaId"] as String?, // Nullable
name: json["name"] ?? '', // Fallback to empty string if name is null
status:
json["status"] ?? '', // Fallback to empty string if status is null
type: json["type"] ?? '', // Fallback to empty string if type is null
icon: json["icon"] as String?, // Nullable
);
}
Map<String, dynamic> toJson() => {
"id": id,
"sceneTuyaId": sceneTuyaId ?? '',
"name": name,
"status": status,
"type": type,