mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
push living room status
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class DeviceStatus {
|
||||
final String productUuid;
|
||||
final String productType;
|
||||
final List<Status> status;
|
||||
|
||||
DeviceStatus({
|
||||
required this.productUuid,
|
||||
required this.productType,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory DeviceStatus.fromMap(Map<String, dynamic> map) {
|
||||
return DeviceStatus(
|
||||
productUuid: map['productUuid'] ?? '',
|
||||
productType: map['productType'] ?? '',
|
||||
status: List<Status>.from(
|
||||
map['status']?.map((x) => Status.fromMap(x)) ?? const []),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'productUuid': productUuid,
|
||||
'productType': productType,
|
||||
'status': status.map((x) => x.toMap()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
factory DeviceStatus.fromJson(Map<String, dynamic> json) =>
|
||||
DeviceStatus.fromMap(json);
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
||||
|
||||
class Status {
|
||||
final String code;
|
||||
final dynamic value;
|
||||
|
||||
Status({
|
||||
required this.code,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
factory Status.fromMap(Map<String, dynamic> map) {
|
||||
return Status(
|
||||
code: map['code'] ?? '',
|
||||
value: map['value'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'code': code,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
|
||||
factory Status.fromJson(String source) => Status.fromMap(json.decode(source));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
}
|
157
lib/pages/device_managment/all_devices/models/devices_model.dart
Normal file
157
lib/pages/device_managment/all_devices/models/devices_model.dart
Normal file
@ -0,0 +1,157 @@
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
|
||||
|
||||
class AllDevicesModel {
|
||||
/*
|
||||
{
|
||||
"room": {
|
||||
"uuid": "75ea7d60-5104-4726-b5f8-ea426c0c6a1b",
|
||||
"name": "Room 1"
|
||||
},
|
||||
"unit": {
|
||||
"uuid": "04fd1dcf-f24a-40db-970d-d0be884ed30f",
|
||||
"name": "unit 1"
|
||||
},
|
||||
"productUuid": "894aad5c-ce03-423a-9d61-2fd0c3f67ebf",
|
||||
"productType": "3G",
|
||||
"permissionType": "CONTROLLABLE",
|
||||
"activeTime": 1722173778,
|
||||
"category": "kg",
|
||||
"categoryName": "Switch",
|
||||
"createTime": 1722173778,
|
||||
"gatewayId": "bf0294123ed2c19067skrk",
|
||||
"icon": "smart/icon/bay1642572935385vcsA/2b1f5efbaa5bbf81c3164fa312cf2032.png",
|
||||
"ip": "",
|
||||
"lat": "31.97",
|
||||
"localKey": "T/39+<l/![iv>:9M",
|
||||
"lon": "35.89",
|
||||
"model": "S01ZLSWBSA3",
|
||||
"name": "3 Gang Button Switch L-L",
|
||||
"nodeId": "60a423fffed5a7f6",
|
||||
"online": true,
|
||||
"ownerId": "199200732",
|
||||
"sub": true,
|
||||
"timeZone": "+03:00",
|
||||
"updateTime": 1723626515,
|
||||
"uuid": "5b31dae4-ce9c-4c70-b52b-7e15011163bf"
|
||||
}
|
||||
*/
|
||||
|
||||
DevicesModelRoom? room;
|
||||
DevicesModelUnit? unit;
|
||||
String? productUuid;
|
||||
String? productType;
|
||||
String? permissionType;
|
||||
int? activeTime;
|
||||
String? category;
|
||||
String? categoryName;
|
||||
int? createTime;
|
||||
String? gatewayId;
|
||||
String? icon;
|
||||
String? ip;
|
||||
String? lat;
|
||||
String? localKey;
|
||||
String? lon;
|
||||
String? model;
|
||||
String? name;
|
||||
String? nodeId;
|
||||
bool? online;
|
||||
String? ownerId;
|
||||
bool? sub;
|
||||
String? timeZone;
|
||||
int? updateTime;
|
||||
String? uuid;
|
||||
int? batteryLevel;
|
||||
|
||||
AllDevicesModel({
|
||||
this.room,
|
||||
this.unit,
|
||||
this.productUuid,
|
||||
this.productType,
|
||||
this.permissionType,
|
||||
this.activeTime,
|
||||
this.category,
|
||||
this.categoryName,
|
||||
this.createTime,
|
||||
this.gatewayId,
|
||||
this.icon,
|
||||
this.ip,
|
||||
this.lat,
|
||||
this.localKey,
|
||||
this.lon,
|
||||
this.model,
|
||||
this.name,
|
||||
this.nodeId,
|
||||
this.online,
|
||||
this.ownerId,
|
||||
this.sub,
|
||||
this.timeZone,
|
||||
this.updateTime,
|
||||
this.uuid,
|
||||
this.batteryLevel,
|
||||
});
|
||||
AllDevicesModel.fromJson(Map<String, dynamic> json) {
|
||||
room = (json['room'] != null && (json['room'] is Map))
|
||||
? DevicesModelRoom.fromJson(json['room'])
|
||||
: null;
|
||||
unit = (json['unit'] != null && (json['unit'] is Map))
|
||||
? DevicesModelUnit.fromJson(json['unit'])
|
||||
: null;
|
||||
productUuid = json['productUuid']?.toString();
|
||||
productType = json['productType']?.toString();
|
||||
permissionType = json['permissionType']?.toString();
|
||||
activeTime = int.tryParse(json['activeTime']?.toString() ?? '');
|
||||
category = json['category']?.toString();
|
||||
categoryName = json['categoryName']?.toString();
|
||||
createTime = int.tryParse(json['createTime']?.toString() ?? '');
|
||||
gatewayId = json['gatewayId']?.toString();
|
||||
icon = json['icon']?.toString();
|
||||
ip = json['ip']?.toString();
|
||||
lat = json['lat']?.toString();
|
||||
localKey = json['localKey']?.toString();
|
||||
lon = json['lon']?.toString();
|
||||
model = json['model']?.toString();
|
||||
name = json['name']?.toString();
|
||||
nodeId = json['nodeId']?.toString();
|
||||
online = json['online'];
|
||||
ownerId = json['ownerId']?.toString();
|
||||
sub = json['sub'];
|
||||
timeZone = json['timeZone']?.toString();
|
||||
updateTime = int.tryParse(json['updateTime']?.toString() ?? '');
|
||||
uuid = json['uuid']?.toString();
|
||||
batteryLevel = int.tryParse(json['batteryLevel']?.toString() ?? '');
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (room != null) {
|
||||
data['room'] = room!.toJson();
|
||||
}
|
||||
if (unit != null) {
|
||||
data['unit'] = unit!.toJson();
|
||||
}
|
||||
data['productUuid'] = productUuid;
|
||||
data['productType'] = productType;
|
||||
data['permissionType'] = permissionType;
|
||||
data['activeTime'] = activeTime;
|
||||
data['category'] = category;
|
||||
data['categoryName'] = categoryName;
|
||||
data['createTime'] = createTime;
|
||||
data['gatewayId'] = gatewayId;
|
||||
data['icon'] = icon;
|
||||
data['ip'] = ip;
|
||||
data['lat'] = lat;
|
||||
data['localKey'] = localKey;
|
||||
data['lon'] = lon;
|
||||
data['model'] = model;
|
||||
data['name'] = name;
|
||||
data['nodeId'] = nodeId;
|
||||
data['online'] = online;
|
||||
data['ownerId'] = ownerId;
|
||||
data['sub'] = sub;
|
||||
data['timeZone'] = timeZone;
|
||||
data['updateTime'] = updateTime;
|
||||
data['uuid'] = uuid;
|
||||
data['batteryLevel'] = batteryLevel;
|
||||
return data;
|
||||
}
|
||||
}
|
26
lib/pages/device_managment/all_devices/models/room.dart
Normal file
26
lib/pages/device_managment/all_devices/models/room.dart
Normal file
@ -0,0 +1,26 @@
|
||||
class DevicesModelRoom {
|
||||
/*
|
||||
{
|
||||
"uuid": "75ea7d60-5104-4726-b5f8-ea426c0c6a1b",
|
||||
"name": "Room 1"
|
||||
}
|
||||
*/
|
||||
|
||||
String? uuid;
|
||||
String? name;
|
||||
|
||||
DevicesModelRoom({
|
||||
this.uuid,
|
||||
this.name,
|
||||
});
|
||||
DevicesModelRoom.fromJson(Map<String, dynamic> json) {
|
||||
uuid = json['uuid']?.toString();
|
||||
name = json['name']?.toString();
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['uuid'] = uuid;
|
||||
data['name'] = name;
|
||||
return data;
|
||||
}
|
||||
}
|
26
lib/pages/device_managment/all_devices/models/unit.dart
Normal file
26
lib/pages/device_managment/all_devices/models/unit.dart
Normal file
@ -0,0 +1,26 @@
|
||||
class DevicesModelUnit {
|
||||
/*
|
||||
{
|
||||
"uuid": "04fd1dcf-f24a-40db-970d-d0be884ed30f",
|
||||
"name": "unit 1"
|
||||
}
|
||||
*/
|
||||
|
||||
String? uuid;
|
||||
String? name;
|
||||
|
||||
DevicesModelUnit({
|
||||
this.uuid,
|
||||
this.name,
|
||||
});
|
||||
DevicesModelUnit.fromJson(Map<String, dynamic> json) {
|
||||
uuid = json['uuid']?.toString();
|
||||
name = json['name']?.toString();
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['uuid'] = uuid;
|
||||
data['name'] = name;
|
||||
return data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user