mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 17:25:47 +00:00
964 lines
29 KiB
Dart
964 lines
29 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/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/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/presence_sensor.dart';
|
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/three_gang_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 {
|
|
List<SceneStaticFunction> getFunctionsWithIcons({
|
|
DeviceType? type,
|
|
required List<FunctionModel> functions,
|
|
required String deviceId,
|
|
required String deviceName,
|
|
required bool isAutomation,
|
|
}) {
|
|
const functionValue = null;
|
|
|
|
switch (type) {
|
|
case DeviceType.LightBulb:
|
|
return lightBulbFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.CeilingSensor:
|
|
return ceilingSensorFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.WallSensor:
|
|
return wallSensorFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.AC:
|
|
return acFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.DoorLock:
|
|
return doorLockFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.Curtain:
|
|
return curtainFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.ThreeGang:
|
|
return threeGangFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
case DeviceType.Gateway:
|
|
return gatewayFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
default:
|
|
return lightBulbFunctions(
|
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
|
}
|
|
}
|
|
|
|
String getTitle({DeviceType? type}) {
|
|
switch (type) {
|
|
case DeviceType.LightBulb:
|
|
return 'Light Bulb Functions';
|
|
case DeviceType.CeilingSensor:
|
|
return 'Presence Sensor Functions';
|
|
case DeviceType.WallSensor:
|
|
return 'Human Presence Sensor Functions';
|
|
case DeviceType.AC:
|
|
return 'AC Functions';
|
|
case DeviceType.DoorLock:
|
|
return 'Door Lock Functions';
|
|
case DeviceType.Curtain:
|
|
return 'Curtain Functions';
|
|
case DeviceType.ThreeGang:
|
|
return '3G Light Switch Functions';
|
|
case DeviceType.Gateway:
|
|
return 'Gateway Functions';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
|
|
List<SceneStaticFunction> ceilingSensorFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
if (isAutomation) {
|
|
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return PresenceSensorHelperFunctions.tabToRunPresenceSensorFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> curtainFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
return [];
|
|
}
|
|
|
|
List<SceneStaticFunction> doorLockFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
if (isAutomation) {
|
|
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return DoorLockHelperFunctions.doorLockTapToRunFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> wallSensorFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
if (isAutomation) {
|
|
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return HumanPresenceHelperFunctions.tabToRunHumanPresenceFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> lightBulbFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
return [];
|
|
}
|
|
|
|
List<SceneStaticFunction> gatewayFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
return GatewayHelperFunctions.tabToRunGatewayFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> threeGangFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
if (isAutomation) {
|
|
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
return ThreeGangHelperFunctions.threeGangHelperFunctions(
|
|
deviceId, deviceName, functionValue);
|
|
}
|
|
|
|
List<SceneStaticFunction> acFunctions(
|
|
List<FunctionModel> functions,
|
|
String deviceId,
|
|
String deviceName,
|
|
dynamic functionValue,
|
|
bool isAutomation) {
|
|
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<SceneStaticFunction> functions = [];
|
|
for (var action in actions) {
|
|
if (action.entityId == 'delay') {
|
|
functions.add(
|
|
SceneStaticFunction(
|
|
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 {
|
|
functions
|
|
.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
|
}
|
|
}
|
|
return functions;
|
|
}
|
|
|
|
SceneStaticFunction _mapExecutorPropertyToSceneFunction(
|
|
Action action, bool isAutomation,
|
|
{String? comparator}) {
|
|
ExecutorProperty executorProperty = action.executorProperty;
|
|
|
|
switch (executorProperty.functionCode) {
|
|
case 'sensitivity':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Sensitivity',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.listOfOptions,
|
|
isAutomation
|
|
? _createIntegerStepsOptions()
|
|
: _createSensitivityOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'normal_open_switch':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Set Door lock Normal Open',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'unlock_fingerprint':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Fingerprint Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createFingerprintUnlockOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'unlock_password':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Password Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createPasswordUnlockOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'unlock_card':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Card Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createCardUnlockOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'alarm_lock':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Lock Alarm',
|
|
OperationDialogType.listOfOptions,
|
|
_createLockAlarmOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'unlock_request':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Remote Unlock Request',
|
|
OperationDialogType.integerSteps,
|
|
_createUnlockRequestOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'residual_electricity':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Residual Electricity',
|
|
OperationDialogType.integerSteps,
|
|
_createResidualElectricityOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'reverse_lock':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Double Lock',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'unlock_app':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Remote Unlock Via App',
|
|
OperationDialogType.integerSteps,
|
|
_createUnlockAppOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'hijack':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Hijack Alarm',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'doorbell':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Doorbell',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'unlock_temporary':
|
|
return _createSceneFunction(
|
|
action,
|
|
'WIFI LOCK PRO',
|
|
Assets.assetsIconsDoorLock,
|
|
'Temporary Password Unlock',
|
|
OperationDialogType.integerSteps,
|
|
_createTemporaryPasswordUnlockOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'far_detection':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Far Detection',
|
|
OperationDialogType.listOfOptions,
|
|
_createFarDetectionOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'motion_sensitivity_value':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Motion Detection Sensitivity',
|
|
OperationDialogType.listOfOptions,
|
|
_createSensitivityOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'motionless_sensitivity':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Motionless Detection Sensitivity',
|
|
OperationDialogType.listOfOptions,
|
|
_createSensitivityOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'indicator':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Indicator',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'presence_time':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Nobody Time',
|
|
OperationDialogType.countdown,
|
|
_createCountdownOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'presence_state':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Presence State',
|
|
OperationDialogType.listOfOptions,
|
|
_createPresenceStateOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'dis_current':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Current Distance',
|
|
OperationDialogType.integerSteps,
|
|
_createCurrentDistanceOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'illuminance_value':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Illuminance Value',
|
|
OperationDialogType.integerSteps,
|
|
_createIlluminanceValueOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'checking_result':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Human Presence Sensor',
|
|
Assets.assetsIconsSensors,
|
|
'Self-Test Result',
|
|
OperationDialogType.listOfOptions,
|
|
_createSelfTestResultOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'switch':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Smart AC Thermostat - Grey - Model A',
|
|
Assets.assetsIconsAC,
|
|
'Power',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'temp_set':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Smart AC Thermostat - Grey - Model A',
|
|
Assets.assetsIconsAC,
|
|
'Set Temperature',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.temperature,
|
|
isAutomation
|
|
? _createAutomationTemperatureOptions()
|
|
: _createTemperatureOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'temp_current':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Smart AC Thermostat - Grey - Model A',
|
|
Assets.assetsIconsAC,
|
|
'Current Temperature',
|
|
OperationDialogType.integerSteps,
|
|
_createCurrentTemperatureOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
|
|
case 'mode':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Smart AC Thermostat - Grey - Model A',
|
|
Assets.assetsIconsAC,
|
|
'Mode',
|
|
OperationDialogType.listOfOptions,
|
|
_createAcModeOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'level':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Smart AC Thermostat - Grey - Model A',
|
|
Assets.assetsIconsAC,
|
|
'Fan Speed',
|
|
OperationDialogType.listOfOptions,
|
|
_createFanSpeedOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'child_lock':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Smart AC Thermostat - Grey - Model A',
|
|
Assets.assetsIconsAC,
|
|
'Child Lock',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'switch_1':
|
|
return _createSceneFunction(
|
|
action,
|
|
'3 Gang Button Switch L-L',
|
|
Assets.assetsIcons3GangSwitch,
|
|
'Light 1 Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'switch_2':
|
|
return _createSceneFunction(
|
|
action,
|
|
'3 Gang Button Switch L-L',
|
|
Assets.assetsIcons3GangSwitch,
|
|
'Light 2 Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'switch_3':
|
|
return _createSceneFunction(
|
|
action,
|
|
'3 Gang Button Switch L-L',
|
|
Assets.assetsIcons3GangSwitch,
|
|
'Light 3 Switch',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
|
|
case 'countdown_1':
|
|
return _createSceneFunction(
|
|
action,
|
|
'3 Gang Button Switch L-L',
|
|
Assets.assetsIcons3GangSwitch,
|
|
'Light 1 CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'countdown_2':
|
|
return _createSceneFunction(
|
|
action,
|
|
'3 Gang Button Switch L-L',
|
|
Assets.assetsIcons3GangSwitch,
|
|
'Light 2 CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'countdown_3':
|
|
return _createSceneFunction(
|
|
action,
|
|
'3 Gang Button Switch L-L',
|
|
Assets.assetsIcons3GangSwitch,
|
|
'Light 3 CountDown',
|
|
isAutomation
|
|
? OperationDialogType.integerSteps
|
|
: OperationDialogType.countdown,
|
|
isAutomation
|
|
? _createAutomationCountDownOptions()
|
|
: _createCountdownOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'switch_alarm_sound':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Gateway',
|
|
Assets.assetsIconsGateway,
|
|
'Switch Alarm Sound',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'master_state':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Gateway',
|
|
Assets.assetsIconsGateway,
|
|
'Master State',
|
|
OperationDialogType.listOfOptions,
|
|
_createMasterStateOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
case 'factory_reset':
|
|
return _createSceneFunction(
|
|
action,
|
|
'Gateway',
|
|
Assets.assetsIconsGateway,
|
|
'Factory Reset',
|
|
OperationDialogType.onOff,
|
|
_createOnOffOptions(),
|
|
isAutomation,
|
|
comparator ?? '==');
|
|
default:
|
|
throw ArgumentError(
|
|
'Unsupported function code: ${executorProperty.functionCode}');
|
|
}
|
|
}
|
|
|
|
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: 0,
|
|
),
|
|
];
|
|
}
|
|
|
|
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> _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> _createIntegerStepsOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
value: 0.0,
|
|
description: "CM",
|
|
minValue: 1,
|
|
maxValue: 600,
|
|
stepValue: 1)
|
|
];
|
|
}
|
|
|
|
_createAutomationCountDownOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: '',
|
|
description: "sec",
|
|
value: 0.0,
|
|
minValue: 0,
|
|
maxValue: 43200,
|
|
stepValue: 1,
|
|
)
|
|
];
|
|
}
|
|
|
|
SceneStaticFunction _createSceneFunction(
|
|
Action action,
|
|
String deviceName,
|
|
String icon,
|
|
String operationName,
|
|
OperationDialogType operationDialogType,
|
|
List<SceneOperationalValue> operationalValues,
|
|
bool isAutomation,
|
|
String comparator) {
|
|
final functionValue = action.executorProperty.functionValue;
|
|
return SceneStaticFunction(
|
|
deviceId: action.entityId,
|
|
deviceName: deviceName,
|
|
deviceIcon: icon,
|
|
icon: icon,
|
|
operationName: operationName,
|
|
functionValue: functionValue,
|
|
code: action.executorProperty.functionCode ?? '',
|
|
operationDialogType: operationDialogType,
|
|
operationalValues: operationalValues,
|
|
comparator: comparator,
|
|
);
|
|
}
|
|
|
|
List<SceneOperationalValue> _createOnOffOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createSensitivityOptions() {
|
|
return List.generate(
|
|
10,
|
|
(index) => SceneOperationalValue(
|
|
icon: Assets.assetsSensitivityOperationIcon,
|
|
value: index + 1,
|
|
description: (index + 1).toString()));
|
|
}
|
|
|
|
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(
|
|
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)
|
|
],
|
|
),
|
|
];
|
|
}
|
|
|
|
return [
|
|
_mapExecutorPropertyToSceneFunction(
|
|
Action(
|
|
entityId: deviceId,
|
|
executorProperty: ExecutorProperty(
|
|
functionCode: taskItem.code,
|
|
functionValue: taskItem.functionValue),
|
|
actionExecutor: ''),
|
|
isAutomation,
|
|
comparator: taskItem.comparator,
|
|
)
|
|
];
|
|
}
|
|
|
|
List<SceneOperationalValue> _createCurrentTemperatureOptions() {
|
|
return [
|
|
SceneOperationalValue(
|
|
icon: Assets.assetsCelsiusDegrees,
|
|
value: 0.0,
|
|
description: '°C',
|
|
minValue: -9.9,
|
|
maxValue: 99.9,
|
|
stepValue: 0.1,
|
|
),
|
|
];
|
|
}
|
|
}
|