diff --git a/lib/pages/device_managment/ac/bloc/ac_bloc.dart b/lib/pages/device_managment/ac/bloc/ac_bloc.dart index 3da6e848..501d29d8 100644 --- a/lib/pages/device_managment/ac/bloc/ac_bloc.dart +++ b/lib/pages/device_managment/ac/bloc/ac_bloc.dart @@ -331,13 +331,14 @@ class AcBloc extends Bloc { try { final scaledValue = totalMinutes ~/ 6; - Future.delayed(const Duration(seconds: 1), () async { - 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)); } catch (e) { @@ -345,12 +346,14 @@ class AcBloc extends Bloc { emit(AcsFailedState(error: e.toString())); } } else { - Future.delayed(const Duration(seconds: 1), () async { - 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; scheduledMinutes = 0;