mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
add water heater device to routine and fix device type in routine
This commit is contained in:
@ -10,6 +10,7 @@ import 'package:syncrow_app/features/scene/helper/functions_per_device/one_gang_
|
||||
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';
|
||||
@ -29,6 +30,7 @@ mixin SceneOperationsDataHelper {
|
||||
DeviceType.Gateway: gatewayFunctions,
|
||||
DeviceType.OneGang: oneGangFunctions,
|
||||
DeviceType.TwoGang: towGangFunctions,
|
||||
DeviceType.WH: waterHeaterFunctions,
|
||||
};
|
||||
|
||||
final Map<DeviceType, String> _titleMap = {
|
||||
@ -42,8 +44,23 @@ mixin SceneOperationsDataHelper {
|
||||
DeviceType.Gateway: 'Gateway Functions',
|
||||
DeviceType.OneGang: '1G Light Switch Conditions',
|
||||
DeviceType.TwoGang: '2G Light Switch Conditions',
|
||||
DeviceType.WH: 'Water Heater Conditions',
|
||||
};
|
||||
|
||||
static List<SceneStaticFunction> waterHeaterFunctions(
|
||||
List<FunctionModel> functions,
|
||||
String deviceId,
|
||||
String deviceName,
|
||||
dynamic functionValue,
|
||||
bool isAutomation) {
|
||||
if (isAutomation) {
|
||||
return WaterHeaterFunctionsHelper.waterHeaterAutomationFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
}
|
||||
return WaterHeaterFunctionsHelper.waterHeaterHelperFunctions(
|
||||
deviceId, deviceName, functionValue);
|
||||
}
|
||||
|
||||
//one gang functions
|
||||
static List<SceneStaticFunction> oneGangFunctions(
|
||||
List<FunctionModel> functions,
|
||||
@ -201,6 +218,7 @@ mixin SceneOperationsDataHelper {
|
||||
if (action.entityId == 'delay') {
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceType: action.productType,
|
||||
deviceId: action.entityId,
|
||||
deviceName: 'delay',
|
||||
deviceIcon: Assets.delay,
|
||||
@ -222,6 +240,7 @@ mixin SceneOperationsDataHelper {
|
||||
// Handle smart scenes
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceType: action.productType,
|
||||
deviceId: action.entityId,
|
||||
deviceName: action.name.toString(),
|
||||
deviceIcon: action.type == 'automation'
|
||||
@ -328,6 +347,8 @@ mixin SceneOperationsDataHelper {
|
||||
'switch_alarm_sound': _createSwitchAlarmSoundFunction,
|
||||
'master_state': _createMasterStateFunction,
|
||||
'factory_reset': _createFactoryResetFunction,
|
||||
'switch_backlight': _createSwitchFunction,
|
||||
'relay_status': _relayStatusSwitchFunction,
|
||||
};
|
||||
|
||||
final functionCode = executorProperty?.functionCode ?? '';
|
||||
@ -339,7 +360,7 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSceneFunction(
|
||||
static SceneStaticFunction _createSceneFunction(
|
||||
Action action,
|
||||
String deviceName,
|
||||
String icon,
|
||||
@ -350,8 +371,11 @@ mixin SceneOperationsDataHelper {
|
||||
String? comparator,
|
||||
String? uniqueCustomId,
|
||||
]) {
|
||||
final productType = action.productType;
|
||||
|
||||
final functionValue = action.executorProperty?.functionValue;
|
||||
return SceneStaticFunction(
|
||||
deviceType: productType,
|
||||
uniqueCustomId: uniqueCustomId,
|
||||
deviceId: action.entityId,
|
||||
deviceName: deviceName,
|
||||
@ -422,7 +446,7 @@ mixin SceneOperationsDataHelper {
|
||||
);
|
||||
}
|
||||
|
||||
List<SceneOperationalValue> _createOnOffOptions() {
|
||||
static List<SceneOperationalValue> _createOnOffOptions() {
|
||||
return [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -744,7 +768,7 @@ mixin SceneOperationsDataHelper {
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.assetsIconsAC,
|
||||
Assets.waterHeaterIcon,
|
||||
'Power',
|
||||
OperationDialogType.onOff,
|
||||
_createOnOffOptions(),
|
||||
@ -754,6 +778,21 @@ mixin SceneOperationsDataHelper {
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
@ -833,9 +872,22 @@ mixin SceneOperationsDataHelper {
|
||||
);
|
||||
}
|
||||
|
||||
SceneStaticFunction _createSwitch1Function(Action action, bool isAutomation,
|
||||
String? comparator, String? uniqueCustomId) {
|
||||
static SceneStaticFunction _createSwitch1Function(Action action,
|
||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||
switch (action.productType) {
|
||||
case "WH":
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
action.deviceName,
|
||||
Assets.waterHeaterIcon,
|
||||
'Switch',
|
||||
OperationDialogType.onOff,
|
||||
_createOnOffOptions(),
|
||||
isAutomation,
|
||||
comparator,
|
||||
uniqueCustomId,
|
||||
);
|
||||
|
||||
case "3G":
|
||||
return _createSceneFunction(
|
||||
action,
|
||||
@ -872,6 +924,30 @@ mixin SceneOperationsDataHelper {
|
||||
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,
|
||||
@ -914,6 +990,30 @@ mixin SceneOperationsDataHelper {
|
||||
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,
|
||||
@ -979,12 +1079,28 @@ mixin SceneOperationsDataHelper {
|
||||
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,
|
||||
'Light CountDown',
|
||||
'CountDown',
|
||||
isAutomation
|
||||
? OperationDialogType.integerSteps
|
||||
: OperationDialogType.countdown,
|
||||
@ -1033,6 +1149,22 @@ mixin SceneOperationsDataHelper {
|
||||
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,
|
||||
@ -1395,6 +1527,7 @@ mixin SceneOperationsDataHelper {
|
||||
if (deviceId.contains('delay')) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: taskItem.deviceType,
|
||||
uniqueCustomId: taskItem.uniqueCustomId,
|
||||
deviceId: taskItem.deviceId,
|
||||
deviceName: 'delay',
|
||||
@ -1417,6 +1550,7 @@ mixin SceneOperationsDataHelper {
|
||||
if (taskItem.code == CreateSceneEnum.smartSceneSelect.name) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceType: taskItem.deviceType,
|
||||
uniqueCustomId: taskItem.uniqueCustomId,
|
||||
deviceId: taskItem.deviceId,
|
||||
deviceName: taskItem.deviceName.toString(),
|
||||
@ -1449,7 +1583,7 @@ mixin SceneOperationsDataHelper {
|
||||
_mapExecutorPropertyToSceneFunction(
|
||||
Action(
|
||||
deviceName: taskItem.deviceName,
|
||||
productType: '',
|
||||
productType: taskItem.deviceType!,
|
||||
entityId: deviceId,
|
||||
executorProperty: ExecutorProperty(
|
||||
functionCode: taskItem.code,
|
||||
@ -1476,4 +1610,24 @@ mixin SceneOperationsDataHelper {
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
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',
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user