mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-10 15:17:21 +00:00
2022 lines
56 KiB
Dart
2022 lines
56 KiB
Dart
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
|
import 'package:syncrow_app/features/scene/enum/ac_values.dart';
|
|
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
|
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/ac_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/door_lock_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/flush_functions_helper.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/gateway_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/human_presence_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/one_gang_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/presence_sensor.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/three_gang_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/tow_gang_helper_functions.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/water_heater_functions.dart';
|
|
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
|
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
|
import 'package:syncrow_app/generated/assets.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
mixin SceneOperationsDataHelper {
|
|
final Map<DeviceType,
|
|
Function(List<FunctionModel>, String, String, dynamic, bool, String)>
|
|
_functionMap = {
|
|
DeviceType.LightBulb: lightBulbFunctions,
|
|
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
|
DeviceType.WallSensor: wallSensorFunctions,
|
|
DeviceType.AC: acFunctions,
|
|
DeviceType.DoorLock: doorLockFunctions,
|
|
DeviceType.Curtain: curtainFunctions,
|
|
DeviceType.ThreeGang: threeGangFunctions,
|
|
DeviceType.Gateway: gatewayFunctions,
|
|
DeviceType.OneGang: oneGangFunctions,
|
|
DeviceType.TwoGang: towGangFunctions,
|
|
DeviceType.WH: waterHeaterFunctions,
|
|
DeviceType.FlushMountedSensor: flushFunctions
|
|
};
|
|
|
|
final Map<DeviceType, String> _titleMap = {
|
|
DeviceType.LightBulb: 'Light Bulb Functions',
|
|
DeviceType.CeilingSensor: 'Presence Sensor Functions',
|
|
DeviceType.WallSensor: 'Human Presence Sensor Functions',
|
|
DeviceType.AC: 'AC Functions',
|
|
DeviceType.DoorLock: 'Door Lock Functions',
|
|
DeviceType.Curtain: 'Curtain Functions',
|
|
DeviceType.ThreeGang: '3G Light Switch Functions',
|
|
DeviceType.Gateway: 'Gateway Functions',
|
|
DeviceType.OneGang: '1G Light Switch Conditions',
|
|
DeviceType.TwoGang: '2G Light Switch Conditions',
|
|
DeviceType.WH: 'Water Heater Conditions',
|
|
DeviceType.FlushMountedSensor: 'Flush Presence Sensor Functions'
|
|
};
|
|
|
|
static List<SceneStaticFunction> flushFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return FlushFunctionsHelper.flushSceneHelperFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return FlushFunctionsHelper.flushAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> waterHeaterFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return WaterHeaterFunctionsHelper.waterHeaterAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return WaterHeaterFunctionsHelper.waterHeaterHelperFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
//one gang functions
|
|
static List<SceneStaticFunction> oneGangFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return OneGangHelperFunctions.oneGangAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return OneGangHelperFunctions.oneGangHelperFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> towGangFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return TowGangHelperFunctions.towGangAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return TowGangHelperFunctions.towGangHelperFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> getFunctionsWithIcons({
|
|
DeviceType? type,
|
|
required List<FunctionModel> functions,
|
|
required String deviceId,
|
|
required String deviceName,
|
|
required String productType,
|
|
required bool isAutomation,
|
|
}) {
|
|
final functionValue = null;
|
|
return _functionMap[type]?.call(functions, deviceId, deviceName,
|
|
functionValue, isAutomation, productType) ??
|
|
lightBulbFunctions(functions, deviceId, deviceName, functionValue,
|
|
isAutomation, productType);
|
|
}
|
|
|
|
String getTitle({DeviceType? type}) {
|
|
return _titleMap[type] ?? '';
|
|
}
|
|
|
|
static List<SceneStaticFunction> ceilingSensorFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return PresenceSensorHelperFunctions.tabToRunPresenceSensorFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> curtainFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
return [];
|
|
}
|
|
|
|
static List<SceneStaticFunction> doorLockFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return DoorLockHelperFunctions.doorLockTapToRunFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> wallSensorFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return HumanPresenceHelperFunctions.tabToRunHumanPresenceFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> lightBulbFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType) {
|
|
return [];
|
|
}
|
|
|
|
static List<SceneStaticFunction> gatewayFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
return GatewayHelperFunctions.tabToRunGatewayFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> threeGangFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return ThreeGangHelperFunctions.threeGangHelperFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
static List<SceneStaticFunction> acFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation,
|
|
String productType,
|
|
) {
|
|
if (isAutomation) {
|
|
return ACFunctionsHelper.automationAcFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return ACFunctionsHelper.tabToRunAcFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
|
required List<Action> actions,
|
|
required bool isAutomation,
|
|
List<Condition>? conditions,
|
|
}) {
|
|
List<SceneStaticFunction> functions = [];
|
|
for (var action in actions) {
|
|
if (action.productType == "NCPS") {
|
|
if (action.executorProperty!.functionCode == 'near_detection' ||
|
|
action.executorProperty!.functionCode == 'far_detection') {
|
|
action.executorProperty!.functionValue =
|
|
action.executorProperty!.functionValue / 100;
|
|
} else if (action.executorProperty!.functionCode == 'presence_delay' ||
|
|
action.executorProperty!.functionCode == 'none_delay') {
|
|
action.executorProperty!.functionValue =
|
|
(action.executorProperty!.functionValue / 10);
|
|
}
|
|
}
|
|
}
|
|
// Handle actions
|
|
for (var action in actions) {
|
|
if (action.entityId == 'delay') {
|
|
functions.add(
|
|
SceneStaticFunction(
|
|
deviceType: action.productType,
|
|
deviceId: action.entityId,
|
|
deviceName: 'delay',
|
|
deviceIcon: Assets.delay,
|
|
icon: Assets.delay,
|
|
operationName: 'delay',
|
|
operationDialogType: OperationDialogType.delay,
|
|
functionValue: action.executorProperty?.delaySeconds,
|
|
code: '',
|
|
operationalValues: [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: action.executorProperty?.delaySeconds,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else if (action.name != null && action.type != null) {
|
|
// Handle smart scenes
|
|
functions.add(
|
|
SceneStaticFunction(
|
|
deviceType: action.productType,
|
|
deviceId: action.entityId,
|
|
deviceName: action.name.toString(),
|
|
deviceIcon: action.type == 'automation'
|
|
? Assets.player
|
|
: Assets.handClickIcon,
|
|
icon: action.type == 'automation'
|
|
? Assets.player
|
|
: Assets.handClickIcon,
|
|
operationName: action.type.toString(),
|
|
operationDialogType: OperationDialogType.onOff,
|
|
functionValue: action.actionExecutor,
|
|
code: CreateSceneEnum.smartSceneSelect.name,
|
|
operationalValues: [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPower,
|
|
description: "Enable",
|
|
value: 'rule_enable',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPowerOFF,
|
|
description: "Disable",
|
|
value: 'rule_disable',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
functions
|
|
.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
|
}
|
|
}
|
|
|
|
// Handle conditions
|
|
if (conditions != null) {
|
|
for (var condition in conditions) {
|
|
// Create a dummy Action from Condition to reuse _mapExecutorPropertyToSceneFunction
|
|
Action dummyAction = Action(
|
|
deviceName: condition.deviceName,
|
|
productType: condition.productType,
|
|
actionExecutor: 'device_report',
|
|
entityId: condition.entityId,
|
|
executorProperty: ExecutorProperty(
|
|
functionCode: condition.expr.statusCode,
|
|
functionValue: condition.expr.statusValue,
|
|
),
|
|
);
|
|
var conditionFunction = _mapExecutorPropertyToSceneFunction(
|
|
dummyAction,
|
|
isAutomation,
|
|
comparator: condition.expr.comparator,
|
|
);
|
|
functions.add(conditionFunction);
|
|
}
|
|
}
|
|
|
|
return functions;
|
|
}
|
|
|
|
SceneStaticFunction _mapExecutorPropertyToSceneFunction(
|
|
Action action,
|
|
bool isAutomation, {
|
|
String? comparator,
|
|
String? uniqueCustomId,
|
|
}) {
|
|
final executorProperty = action.executorProperty;
|
|
final Map<String,
|
|
SceneStaticFunction Function(Action, bool, String?, String?)>
|
|
functionMap = {
|
|
'normal_open_switch': _createNormalOpenSwitchFunction,
|
|
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
|
'unlock_password': _createUnlockPasswordFunction,
|
|
'unlock_card': _createUnlockCardFunction,
|
|
'alarm_lock': _createAlarmLockFunction,
|
|
'unlock_request': _createUnlockRequestFunction,
|
|
'residual_electricity': _createResidualElectricityFunction,
|
|
'reverse_lock': _createReverseLockFunction,
|
|
'unlock_app': _createUnlockAppFunction,
|
|
'hijack': _createHijackFunction,
|
|
'doorbell': _createDoorbellFunction,
|
|
'unlock_temporary': _createUnlockTemporaryFunction,
|
|
'near_detection': _createNearDetectionOptions,
|
|
if (action.productType == 'NCPS') ...{
|
|
'far_detection': _createFarDetectionOptionsFlush,
|
|
'presence_state': _createPresenceStateFunctionFlush,
|
|
'illum_value': _createIlluminanceValueFunctionFlush,
|
|
'sensitivity': _createSensitivityFunctionFlush,
|
|
} else ...{
|
|
'far_detection': _createFarDetectionFunction,
|
|
'presence_state': _createPresenceStateFunction,
|
|
'sensitivity': _createSensitivityFunction,
|
|
},
|
|
'motion_sensitivity_value': _createMotionSensitivityFunction,
|
|
'motionless_sensitivity': _createMotionlessSensitivityFunction,
|
|
'indicator': _createIndicatorFunction,
|
|
'presence_time': _createPresenceTimeFunction,
|
|
'dis_current': _createDisCurrentFunction,
|
|
'illuminance_value': _createIlluminanceValueFunction,
|
|
'checking_result': _createCheckingResultFunction,
|
|
'switch': _createSwitchFunction,
|
|
'temp_set': _createTempSetFunction,
|
|
'temp_current': _createTempCurrentFunction,
|
|
'mode': _createModeFunction,
|
|
'level': _createLevelFunction,
|
|
'child_lock': _createChildLockFunction,
|
|
'switch_1': _createSwitch1Function,
|
|
'switch_2': _createSwitch2Function,
|
|
'switch_3': _createSwitch3Function,
|
|
'countdown_1': _createCountdown1Function,
|
|
'countdown_2': _createCountdown2Function,
|
|
'countdown_3': _createCountdown3Function,
|
|
'switch_alarm_sound': _createSwitchAlarmSoundFunction,
|
|
'master_state': _createMasterStateFunction,
|
|
'factory_reset': _createFactoryResetFunction,
|
|
'switch_backlight': _createSwitchFunction,
|
|
'relay_status': _relayStatusSwitchFunction,
|
|
'sensi_reduce': _createTriggerLevelOptions,
|
|
'occur_dist_reduce': _createIndentLevelOptions,
|
|
'presence_delay': _createTargetConfirmTime,
|
|
'none_delay': _createDisappeDelay
|
|
};
|
|
|
|
final functionCode = executorProperty?.functionCode ?? '';
|
|
final createFunction = functionMap[functionCode];
|
|
if (createFunction != null) {
|
|
return createFunction(action, isAutomation, comparator, uniqueCustomId);
|
|
} else {
|
|
throw ArgumentError('Unsupported function code: $functionCode');
|
|
}
|
|
}
|
|
|
|
static SceneStaticFunction _createSceneFunction(
|
|
Action action,
|
|
String deviceName,
|
|
String icon,
|
|
String operationName,
|
|
OperationDialogType operationDialogType,
|
|
List<SceneOperationalValue> operationalValues,
|
|
bool isAutomation, [
|
|
String? comparator,
|
|
String? uniqueCustomId,
|
|
]) {
|
|
final productType = action.productType;
|
|
final functionValue = action.executorProperty?.functionValue;
|
|
return SceneStaticFunction(
|
|
deviceType: productType,
|
|
uniqueCustomId: uniqueCustomId,
|
|
deviceId: action.entityId,
|
|
deviceName: deviceName,
|
|
deviceIcon: icon,
|
|
icon: icon,
|
|
operationName: operationName,
|
|
functionValue: functionValue,
|
|
code: action.executorProperty?.functionCode ?? '',
|
|
operationDialogType: operationDialogType,
|
|
operationalValues: operationalValues,
|
|
comparator: comparator ?? '==',
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createSensitivityFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Sensitivity',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.listOfOptions,
|
|
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createNormalOpenSwitchFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Set Door lock Normal Open',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createIntegerStepsOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
value: 0.0,
|
|
description: "CM",
|
|
minValue: 1,
|
|
maxValue: 600,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createSensitivityOptions() {
|
|
return List.generate(
|
|
10,
|
|
(index) => SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: index + 1,
|
|
description: (index + 1).toString(),
|
|
),
|
|
);
|
|
}
|
|
|
|
static List<SceneOperationalValue> _createOnOffOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPower,
|
|
description: "ON",
|
|
value: true,
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPowerOFF,
|
|
description: "OFF",
|
|
value: false,
|
|
),
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createUnlockFingerprintFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Fingerprint Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createFingerprintUnlockOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createUnlockPasswordFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Password Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createPasswordUnlockOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createUnlockCardFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Card Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createCardUnlockOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createAlarmLockFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Lock Alarm',
|
|
OperationDialogType.listOfOptions,
|
|
_createLockAlarmOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createUnlockRequestFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Remote Unlock Request',
|
|
OperationDialogType.integerSteps,
|
|
_createUnlockRequestOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createResidualElectricityFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Residual Electricity',
|
|
OperationDialogType.integerSteps,
|
|
_createResidualElectricityOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createReverseLockFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Double Lock',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createUnlockAppFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Remote Unlock Via App',
|
|
OperationDialogType.integerSteps,
|
|
_createUnlockAppOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createHijackFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Hijack Alarm',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createDoorbellFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Doorbell',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createUnlockTemporaryFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsDoorLock,
|
|
'Temporary Password Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createTemporaryPasswordUnlockOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createFarDetectionFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Far Detection',
|
|
OperationDialogType.listOfOptions,
|
|
_createFarDetectionOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createMotionSensitivityFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Motion Detection Sensitivity',
|
|
OperationDialogType.listOfOptions,
|
|
_createSensitivityOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createMotionlessSensitivityFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Motionless Detection Sensitivity',
|
|
OperationDialogType.listOfOptions,
|
|
_createSensitivityOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createIndicatorFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Indicator',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createPresenceTimeFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Nobody Time',
|
|
OperationDialogType.countdown,
|
|
_createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createPresenceStateFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Presence State',
|
|
OperationDialogType.listOfOptions,
|
|
_createPresenceStateOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createDisCurrentFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Current Distance',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
_createCurrentDistanceOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createIlluminanceValueFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Illuminance Value',
|
|
OperationDialogType.integerSteps,
|
|
_createIlluminanceValueOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createCheckingResultFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsSensors,
|
|
'Self-Test Result',
|
|
OperationDialogType.listOfOptions,
|
|
_createSelfTestResultOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createSwitchFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
switch (action.productType) {
|
|
case "AC":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsAC,
|
|
'Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
|
|
case "WH":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.waterHeaterIcon,
|
|
'Power',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
|
|
default:
|
|
throw ArgumentError('Unsupported product type: ${action.productType}');
|
|
}
|
|
}
|
|
|
|
SceneStaticFunction _relayStatusSwitchFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.waterHeaterIcon,
|
|
'Restart Status',
|
|
OperationDialogType.none,
|
|
_createRelayStatusOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createTempSetFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsAC,
|
|
'Set Temperature',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.temperature,
|
|
isAutomation
|
|
? _createAutomationTemperatureOptions()
|
|
: _createTemperatureOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createTempCurrentFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsAC,
|
|
'Current Temperature',
|
|
OperationDialogType.integerSteps,
|
|
_createCurrentTemperatureOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createModeFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsAC,
|
|
'Mode',
|
|
OperationDialogType.listOfOptions,
|
|
_createAcModeOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createLevelFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsAC,
|
|
'Fan Speed',
|
|
OperationDialogType.listOfOptions,
|
|
_createFanSpeedOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createChildLockFunction(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsAC,
|
|
'Child Lock',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
static SceneStaticFunction _createSwitch1Function(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
switch (action.productType) {
|
|
case "AC":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.acSwitchIcon,
|
|
'Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
|
|
case "WH":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.waterHeaterIcon,
|
|
'Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
|
|
case "3G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIcons3GangSwitch,
|
|
'L - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "2G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'L - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "1G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.oneGang,
|
|
'Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "TwoGang":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'L - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "ThreeGang":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'L - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
default:
|
|
return _createSceneFunction(
|
|
action,
|
|
'None',
|
|
Assets.assetsRemoteUnlockReq,
|
|
'None',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
}
|
|
|
|
SceneStaticFunction _createSwitch2Function(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
switch (action.productType) {
|
|
case "3G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIcons3GangSwitch,
|
|
'M - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "2G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'R - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "TwoGang":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'R - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "ThreeGang":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'M - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
default:
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.oneGang,
|
|
'Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
}
|
|
|
|
SceneStaticFunction _createSwitch3Function(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIcons3GangSwitch,
|
|
'R - Light Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createCountdown1Function(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
switch (action.productType) {
|
|
case "3G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIcons3GangSwitch,
|
|
'L - Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "2G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'L - Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "WH":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.waterHeaterIcon,
|
|
'CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
default:
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.oneGang,
|
|
'CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
}
|
|
|
|
SceneStaticFunction _createCountdown2Function(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
switch (action.productType) {
|
|
case "3G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIcons3GangSwitch,
|
|
'M - Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "2G":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'R - Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
case "ThreeGang":
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.twoGang,
|
|
'R - Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
default:
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.oneGang,
|
|
'Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
}
|
|
|
|
SceneStaticFunction _createCountdown3Function(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIcons3GangSwitch,
|
|
'R - Light CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createSwitchAlarmSoundFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsGateway,
|
|
'Switch Alarm Sound',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createMasterStateFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsGateway,
|
|
'Master State',
|
|
OperationDialogType.listOfOptions,
|
|
_createMasterStateOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createFactoryResetFunction(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.assetsIconsGateway,
|
|
'Factory Reset',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createFingerprintUnlockOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0.0,
|
|
maxValue: 999,
|
|
stepValue: 1.0,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createPasswordUnlockOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0.0,
|
|
maxValue: 999,
|
|
stepValue: 1.0,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createCardUnlockOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0.0,
|
|
maxValue: 999,
|
|
stepValue: 1.0,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createLockAlarmOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsFingerprintUnlock,
|
|
description: "Fingerprint Mismatch",
|
|
value: 'wrong_finger',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createUnlockRequestOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0,
|
|
maxValue: 90,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createResidualElectricityOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0,
|
|
maxValue: 100,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createUnlockAppOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0,
|
|
maxValue: 999,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createTemporaryPasswordUnlockOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0.0,
|
|
minValue: 0,
|
|
maxValue: 999,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createPresenceStateOptionsFlush() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsIconsPresenceSensorAssetsEmpty,
|
|
value: 'none',
|
|
description: 'None',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsPresence,
|
|
value: 'presence',
|
|
description: 'Presence',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createPresenceStateOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsIconsPresenceSensorAssetsEmpty,
|
|
value: 'none',
|
|
description: 'None',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsPresence,
|
|
value: 'presence',
|
|
description: 'Presence',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createCurrentDistanceOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
value: 0.0,
|
|
description: "CM",
|
|
minValue: 1,
|
|
maxValue: 600,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createIlluminanceValueOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
value: 0.0,
|
|
description: "Lux",
|
|
minValue: 0,
|
|
maxValue: 10000,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createSelfTestResultOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSelfTestResult,
|
|
value: 'check_success',
|
|
description: 'Self Testing Success',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createAutomationTemperatureOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0.0,
|
|
description: '°C',
|
|
minValue: 20,
|
|
maxValue: 30,
|
|
stepValue: 0.5,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createAutomationCountDownOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "sec",
|
|
value: 0.0,
|
|
minValue: 0,
|
|
maxValue: 43200,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createFarDetectionOptions() {
|
|
final distances = [75, 150, 225, 300, 375, 450, 525, 600];
|
|
return distances
|
|
.map(
|
|
(distance) => SceneOperationalValue(
|
|
icon: Assets.assetsFarDetectionFunction,
|
|
value: distance,
|
|
description: '${distance}cm',
|
|
iconValue: distance.toString(),
|
|
),
|
|
)
|
|
.toList();
|
|
}
|
|
|
|
List<SceneOperationalValue> _createTemperatureOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0,
|
|
description: 'COOL TO',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createMasterStateOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPower,
|
|
description: "Alarm",
|
|
value: 'alarm',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPowerOFF,
|
|
description: "Normal",
|
|
value: 'normal',
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createAcModeOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcCooling,
|
|
description: AcValuesEnums.Cooling.name,
|
|
value: TempModes.cold.name,
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcHeating,
|
|
description: AcValuesEnums.Heating.name,
|
|
value: TempModes.hot.name,
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsFanSpeed,
|
|
description: AcValuesEnums.Ventilation.name,
|
|
value: TempModes.wind.name,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createFanSpeedOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcFanLow,
|
|
description: ValueACRange.LOW.name,
|
|
value: FanSpeeds.low.name,
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcFanMiddle,
|
|
description: ValueACRange.MIDDLE.name,
|
|
value: FanSpeeds.middle.name,
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcFanHigh,
|
|
description: ValueACRange.HIGH.name,
|
|
value: FanSpeeds.high.name,
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcFanAuto,
|
|
description: ValueACRange.AUTO.name,
|
|
value: FanSpeeds.auto.name,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createCountdownOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
value: 0,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneStaticFunction> getOperationsForOneFunction({
|
|
required String deviceId,
|
|
required SceneStaticFunction taskItem,
|
|
required bool isAutomation,
|
|
}) {
|
|
if (deviceId.contains('delay')) {
|
|
return [
|
|
SceneStaticFunction(
|
|
deviceType: taskItem.deviceType,
|
|
uniqueCustomId: taskItem.uniqueCustomId,
|
|
deviceId: taskItem.deviceId,
|
|
deviceName: 'delay',
|
|
deviceIcon: Assets.delay,
|
|
icon: Assets.delay,
|
|
operationName: 'delay',
|
|
functionValue: taskItem.functionValue,
|
|
code: '',
|
|
operationDialogType: OperationDialogType.delay,
|
|
operationalValues: [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "",
|
|
value: 0,
|
|
),
|
|
],
|
|
),
|
|
];
|
|
}
|
|
if (taskItem.code == CreateSceneEnum.smartSceneSelect.name) {
|
|
return [
|
|
SceneStaticFunction(
|
|
deviceType: taskItem.deviceType,
|
|
uniqueCustomId: taskItem.uniqueCustomId,
|
|
deviceId: taskItem.deviceId,
|
|
deviceName: taskItem.deviceName.toString(),
|
|
deviceIcon: taskItem.operationName == 'automation'
|
|
? Assets.player
|
|
: Assets.handClickIcon,
|
|
icon: taskItem.operationName == 'automation'
|
|
? Assets.player
|
|
: Assets.handClickIcon,
|
|
operationName: taskItem.operationName,
|
|
operationDialogType: OperationDialogType.onOff,
|
|
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
|
code: CreateSceneEnum.smartSceneSelect.name,
|
|
operationalValues: [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPower,
|
|
description: "Enable",
|
|
value: 'rule_enable',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPowerOFF,
|
|
description: "Disable",
|
|
value: 'rule_disable',
|
|
),
|
|
],
|
|
),
|
|
];
|
|
}
|
|
return [
|
|
_mapExecutorPropertyToSceneFunction(
|
|
Action(
|
|
deviceName: taskItem.deviceName!,
|
|
productType: taskItem.deviceType!,
|
|
entityId: deviceId,
|
|
executorProperty: ExecutorProperty(
|
|
functionCode: taskItem.code,
|
|
functionValue: taskItem.functionValue,
|
|
),
|
|
actionExecutor: '',
|
|
),
|
|
isAutomation,
|
|
comparator: taskItem.comparator,
|
|
uniqueCustomId: taskItem.uniqueCustomId,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createCurrentTemperatureOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0.0,
|
|
description: '°C',
|
|
minValue: -9.9,
|
|
maxValue: 99.9,
|
|
stepValue: 0.1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createRelayStatusOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPower,
|
|
description: "Power ON",
|
|
value: 'on',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPowerOFF,
|
|
description: "Power OFF",
|
|
value: 'off',
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.refreshStatusIcon,
|
|
description: "Restart Memory",
|
|
value: 'memory',
|
|
),
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createNearDetectionOptions(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Min Detection distance',
|
|
OperationDialogType.counterSteps,
|
|
_createMinDetection(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createFarDetectionOptionsFlush(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Max Detection distance',
|
|
OperationDialogType.counterSteps,
|
|
_createFarDetection(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createTriggerLevelOptions(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
"Trigger Level",
|
|
OperationDialogType.counterSteps,
|
|
_createTriggerLevelFunction(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createTriggerLevelFunction() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0,
|
|
description: '',
|
|
minValue: 0,
|
|
maxValue: 3,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createIndentLevelOptions(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Indent Level',
|
|
OperationDialogType.counterSteps,
|
|
_createIndentLevelFunction(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createIndentLevelFunction() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0,
|
|
description: '',
|
|
minValue: 0,
|
|
maxValue: 3,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createTargetConfirmTime(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Target Confirm Time',
|
|
OperationDialogType.counterSteps,
|
|
_targetConfirmTimeFun(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createDisappeDelay(Action action, bool isAutomation,
|
|
String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Disappe Delay',
|
|
OperationDialogType.integerSteps,
|
|
_targetDisappeDelayFun(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _targetDisappeDelayFun() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.flushIcon,
|
|
value: 0.0,
|
|
description: 'sec',
|
|
minValue: 20,
|
|
maxValue: 300,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createFarDetection() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "m",
|
|
value: 0.0,
|
|
minValue: 0.0,
|
|
maxValue: 9.5,
|
|
stepValue: 0.10,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createMinDetection() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "m",
|
|
value: 0.0,
|
|
minValue: 0.0,
|
|
maxValue: 9.5,
|
|
stepValue: 0.10,
|
|
),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _targetConfirmTimeFun() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0.0,
|
|
description: 'sec',
|
|
minValue: 0.0,
|
|
maxValue: 0.5,
|
|
stepValue: 0.1,
|
|
),
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createPresenceStateFunctionFlush(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Presence State',
|
|
OperationDialogType.listOfOptions,
|
|
_createPresenceStateOptionsFlush(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
SceneStaticFunction _createIlluminanceValueFunctionFlush(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Illuminance Value',
|
|
OperationDialogType.integerSteps,
|
|
_createIlluminanceValueOptionsFlush(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createIlluminanceValueOptionsFlush() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
value: 0.0,
|
|
description: "Lux",
|
|
minValue: 0,
|
|
maxValue: 10000,
|
|
stepValue: 1,
|
|
),
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createSensitivityFunctionFlush(Action action,
|
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
|
return _createSceneFunction(
|
|
action,
|
|
action.deviceName,
|
|
Assets.flushIcon,
|
|
'Sensitivity',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.listOfOptions,
|
|
_createIntegerStepsOptionsFlush(),
|
|
isAutomation,
|
|
comparator,
|
|
uniqueCustomId,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createIntegerStepsOptionsFlush() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 1,
|
|
description: 1.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 2,
|
|
description: 2.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 3,
|
|
description: 3.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 4,
|
|
description: 4.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 5,
|
|
description: 5.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 6,
|
|
description: 6.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 7,
|
|
description: 7.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 8,
|
|
description: 8.toString(),
|
|
),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: 9,
|
|
description: 9.toString(),
|
|
),
|
|
];
|
|
}
|
|
}
|