mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
push gatway devices
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/constants/const.dart';
|
||||
import 'package:syncrow_web/utils/enum/device_types.dart';
|
||||
|
||||
class DeviceModel {
|
||||
dynamic productUuid;
|
||||
@ -47,6 +49,27 @@ class DeviceModel {
|
||||
|
||||
// Deserialize from JSON
|
||||
factory DeviceModel.fromJson(Map<String, dynamic> json) {
|
||||
String tempIcon = '';
|
||||
DeviceType type = devicesTypesMap[json['productType']] ?? DeviceType.Other;
|
||||
|
||||
if (type == DeviceType.LightBulb) {
|
||||
tempIcon = Assets.lightBulb;
|
||||
} else if (type == DeviceType.CeilingSensor ||
|
||||
type == DeviceType.WallSensor) {
|
||||
tempIcon = Assets.sensors;
|
||||
} else if (type == DeviceType.AC) {
|
||||
tempIcon = Assets.ac;
|
||||
} else if (type == DeviceType.DoorLock) {
|
||||
tempIcon = Assets.doorLock;
|
||||
} else if (type == DeviceType.Curtain) {
|
||||
tempIcon = Assets.curtain;
|
||||
} else if (type == DeviceType.ThreeGang) {
|
||||
tempIcon = Assets.gangSwitch;
|
||||
} else if (type == DeviceType.Gateway) {
|
||||
tempIcon = Assets.gateway;
|
||||
} else {
|
||||
tempIcon = Assets.logo;
|
||||
}
|
||||
return DeviceModel(
|
||||
productUuid: json['productUuid'],
|
||||
productType: json['productType'],
|
||||
@ -55,7 +78,7 @@ class DeviceModel {
|
||||
categoryName: json['categoryName'],
|
||||
createTime: json['createTime'],
|
||||
gatewayId: json['gatewayId'],
|
||||
icon: json['icon'],
|
||||
icon: tempIcon,
|
||||
ip: json['ip'],
|
||||
lat: json['lat'],
|
||||
localKey: json['localKey'],
|
||||
|
Reference in New Issue
Block a user