mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 20:44:54 +00:00
push door lock automation functions
This commit is contained in:
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
@ -68,11 +69,30 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
if (!updated) {
|
||||
// Add new function if not found
|
||||
OperationDialogType getOperationDialogType(String? code, [value]) {
|
||||
if (code == null) {
|
||||
return OperationDialogType.none;
|
||||
}
|
||||
if (code.contains('delay')) {
|
||||
return OperationDialogType.delay;
|
||||
} else if (code.contains('countdown')) {
|
||||
return OperationDialogType.countdown;
|
||||
} else if (code.contains('set_temp')) {
|
||||
return OperationDialogType.temperature;
|
||||
} else if (value.toString().toLowerCase().trim() == 'on' ||
|
||||
value.toString().toLowerCase().trim() == 'off') {
|
||||
return OperationDialogType.onOff;
|
||||
}
|
||||
return OperationDialogType.listOfOptions;
|
||||
}
|
||||
|
||||
var newElement = SceneStaticFunction(
|
||||
operationName: event.operation,
|
||||
deviceName: event.deviceName,
|
||||
icon: event.icon,
|
||||
code: event.deviceControlModel.code ?? '',
|
||||
operationDialogType: getOperationDialogType(
|
||||
event.deviceControlModel.code, event.deviceControlModel.value),
|
||||
deviceId: event.deviceId,
|
||||
functionValue: event.deviceControlModel.value,
|
||||
operationalValues: [
|
||||
|
||||
Reference in New Issue
Block a user