diff --git a/assets/icons/device_tag_ic.svg b/assets/icons/device_tag_ic.svg
new file mode 100644
index 00000000..830b6129
--- /dev/null
+++ b/assets/icons/device_tag_ic.svg
@@ -0,0 +1,4 @@
+
diff --git a/lib/pages/device_managment/ac/bloc/ac_bloc.dart b/lib/pages/device_managment/ac/bloc/ac_bloc.dart
index 076e9050..501d29d8 100644
--- a/lib/pages/device_managment/ac/bloc/ac_bloc.dart
+++ b/lib/pages/device_managment/ac/bloc/ac_bloc.dart
@@ -331,9 +331,13 @@ class AcBloc extends Bloc {
try {
final scaledValue = totalMinutes ~/ 6;
- await DevicesManagementApi().deviceControl(
- deviceId,
- Status(code: 'countdown_time', value: scaledValue),
+ await _runDebounce(
+ isBatch: false,
+ deviceId: deviceId,
+ code: 'countdown_time',
+ value: scaledValue,
+ oldValue: scaledValue,
+ emit: emit,
);
_startCountdownTimer(emit);
emit(currentState.copyWith(isTimerActive: timerActive));
@@ -342,9 +346,13 @@ class AcBloc extends Bloc {
emit(AcsFailedState(error: e.toString()));
}
} else {
- await DevicesManagementApi().deviceControl(
- deviceId,
- Status(code: 'countdown_time', value: 0),
+ await _runDebounce(
+ isBatch: false,
+ deviceId: deviceId,
+ code: 'countdown_time',
+ value: 0,
+ oldValue: 0,
+ emit: emit,
);
_countdownTimer?.cancel();
scheduledHours = 0;
diff --git a/lib/pages/device_managment/all_devices/models/device_sub_space.dart b/lib/pages/device_managment/all_devices/models/device_sub_space.dart
new file mode 100644
index 00000000..96195f76
--- /dev/null
+++ b/lib/pages/device_managment/all_devices/models/device_sub_space.dart
@@ -0,0 +1,18 @@
+class DeviceSubSpace {
+ String? id;
+ String? createdAt;
+ String? updatedAt;
+ String? subspaceName;
+ bool? disabled;
+
+ DeviceSubSpace({this.id, this.createdAt, this.updatedAt, this.subspaceName, this.disabled});
+
+ DeviceSubSpace.fromJson(Map json) {
+ id = json['uuid']?.toString() ?? '';
+ createdAt = json['createdAt']?.toString() ?? '';
+ updatedAt = json['updatedAt']?.toString() ?? '';
+ subspaceName = json['subspaceName']?.toString() ?? '';
+ subspaceName = json['subspaceName']?.toString() ?? '';
+ disabled = json['disabled'] ?? false;
+ }
+}
diff --git a/lib/pages/device_managment/all_devices/models/device_tag_model.dart b/lib/pages/device_managment/all_devices/models/device_tag_model.dart
new file mode 100644
index 00000000..12580d3f
--- /dev/null
+++ b/lib/pages/device_managment/all_devices/models/device_tag_model.dart
@@ -0,0 +1,20 @@
+class DeviceTagModel {
+ String? id;
+ String? createdAt;
+ String? updatedAt;
+ String? name;
+
+ DeviceTagModel({
+ this.id,
+ this.createdAt,
+ this.updatedAt,
+ this.name,
+ });
+
+ DeviceTagModel.fromJson(Map json) {
+ id = json['uuid']?.toString() ?? '';
+ createdAt = json['createdAt']?.toString() ?? '';
+ updatedAt = json['updatedAt']?.toString() ?? '';
+ name = json['name']?.toString() ?? '';
+ }
+}
diff --git a/lib/pages/device_managment/all_devices/models/devices_model.dart b/lib/pages/device_managment/all_devices/models/devices_model.dart
index 9069f8a3..a13a1bb7 100644
--- a/lib/pages/device_managment/all_devices/models/devices_model.dart
+++ b/lib/pages/device_managment/all_devices/models/devices_model.dart
@@ -1,6 +1,8 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_community.model.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_space_model.dart';
+import 'package:syncrow_web/pages/device_managment/all_devices/models/device_sub_space.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_subspace.model.dart';
+import 'package:syncrow_web/pages/device_managment/all_devices/models/device_tag_model.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
@@ -79,38 +81,41 @@ class AllDevicesModel {
int? batteryLevel;
String? productName;
List? spaces;
+ List? deviceTags;
+ DeviceSubSpace? deviceSubSpace;
- AllDevicesModel({
- this.room,
- this.subspace,
- this.unit,
- this.community,
- 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,
- this.productName,
- this.spaces,
- });
+ AllDevicesModel(
+ {this.room,
+ this.subspace,
+ this.unit,
+ this.community,
+ 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,
+ this.productName,
+ this.spaces,
+ this.deviceTags,
+ this.deviceSubSpace});
AllDevicesModel.fromJson(Map json) {
room = (json['room'] != null && (json['room'] is Map))
@@ -148,12 +153,15 @@ class AllDevicesModel {
updateTime = int.tryParse(json['updateTime']?.toString() ?? '');
uuid = json['uuid']?.toString();
batteryLevel = int.tryParse(json['battery']?.toString() ?? '');
-
productName = json['productName']?.toString();
+ deviceTags = json['deviceTag'] != null && json['deviceTag'] is List
+ ? (json['deviceTag'] as List).map((tag) => DeviceTagModel.fromJson(tag)).toList()
+ : [];
+ deviceSubSpace = json['subspace'] != null
+ ? DeviceSubSpace.fromJson(json['subspace'])
+ : DeviceSubSpace(subspaceName: '');
if (json['spaces'] != null && json['spaces'] is List) {
- spaces = (json['spaces'] as List)
- .map((space) => DeviceSpaceModel.fromJson(space))
- .toList();
+ spaces = (json['spaces'] as List).map((space) => DeviceSpaceModel.fromJson(space)).toList();
}
}
@@ -201,8 +209,7 @@ SOS
String tempIcon = '';
if (type == DeviceType.LightBulb) {
tempIcon = Assets.lightBulb;
- } else if (type == DeviceType.CeilingSensor ||
- type == DeviceType.WallSensor) {
+ } else if (type == DeviceType.CeilingSensor || type == DeviceType.WallSensor) {
tempIcon = Assets.sensors;
} else if (type == DeviceType.AC) {
tempIcon = Assets.ac;
@@ -249,76 +256,51 @@ SOS
switch (productType) {
case 'AC':
return [
- SwitchFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ModeFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- TempSetFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- CurrentTempFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
- LevelFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ChildLockFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ModeFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
+ LevelFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
];
case '1G':
return [
OneGangSwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
- OneGangCountdownFunction(
- deviceId: uuid ?? '', deviceName: name ?? ''),
+ OneGangCountdownFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
];
case '2G':
return [
TwoGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
TwoGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
- TwoGangCountdown1Function(
- deviceId: uuid ?? '', deviceName: name ?? ''),
- TwoGangCountdown2Function(
- deviceId: uuid ?? '', deviceName: name ?? ''),
+ TwoGangCountdown1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
+ TwoGangCountdown2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
];
case '3G':
return [
- ThreeGangSwitch1Function(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ThreeGangSwitch2Function(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ThreeGangSwitch3Function(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ThreeGangCountdown1Function(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ThreeGangCountdown2Function(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- ThreeGangCountdown3Function(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ThreeGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ThreeGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ThreeGangSwitch3Function(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ThreeGangCountdown1Function(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ThreeGangCountdown2Function(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ ThreeGangCountdown3Function(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
];
case 'WPS':
return [
//IF Functions
- PresenceStateFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
- CurrentDistanceFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
- IlluminanceValueFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
- PresenceTimeFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
+ PresenceStateFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
+ CurrentDistanceFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
+ IlluminanceValueFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
+ PresenceTimeFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
//THEN Functions
- FarDetectionFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
- MotionSensitivityFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
- MotionLessSensitivityFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
- IndicatorFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
- NoOneTimeFunction(
- deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
-
+ FarDetectionFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
+ MotionSensitivityFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
+ MotionLessSensitivityFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
+ IndicatorFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
+ NoOneTimeFunction(deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
];
case 'GW':
return [
diff --git a/lib/pages/device_managment/shared/toggle_widget.dart b/lib/pages/device_managment/shared/toggle_widget.dart
index ad0ba8ad..4888572f 100644
--- a/lib/pages/device_managment/shared/toggle_widget.dart
+++ b/lib/pages/device_managment/shared/toggle_widget.dart
@@ -62,9 +62,6 @@ class ToggleWidget extends StatelessWidget {
)),
if (showToggle)
Container(
- height: 20,
- width: 35,
- padding: const EdgeInsets.only(right: 16, top: 10),
child: CupertinoSwitch(
value: value,
activeColor: ColorsManager.dialogBlueTitle,
diff --git a/lib/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart b/lib/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart
index a196ff27..bb4a7a1e 100644
--- a/lib/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart
+++ b/lib/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart
@@ -30,6 +30,7 @@ class FunctionBloc extends Bloc {
condition: event.functionData.condition ?? existingData.condition,
);
} else {
+ functions.clear();
functions.add(event.functionData);
}
diff --git a/lib/pages/routines/bloc/routine_bloc/routine_bloc.dart b/lib/pages/routines/bloc/routine_bloc/routine_bloc.dart
index 2664d026..b698c19e 100644
--- a/lib/pages/routines/bloc/routine_bloc/routine_bloc.dart
+++ b/lib/pages/routines/bloc/routine_bloc/routine_bloc.dart
@@ -64,8 +64,7 @@ class RoutineBloc extends Bloc {
TriggerSwitchTabsEvent event,
Emitter emit,
) {
- emit(state.copyWith(
- routineTab: event.isRoutineTab, createRoutineView: false));
+ emit(state.copyWith(routineTab: event.isRoutineTab, createRoutineView: false));
add(ResetRoutineState());
if (event.isRoutineTab) {
add(const LoadScenes());
@@ -91,8 +90,8 @@ class RoutineBloc extends Bloc {
final updatedIfItems = List