Implement Flush Mounted Presence Sensor Routine Control and change the device type logic

This commit is contained in:
mohammad
2025-05-11 16:33:11 +03:00
parent 2651de71e4
commit adb42f95e8
26 changed files with 1071 additions and 180 deletions

View File

@ -88,6 +88,7 @@ mixin SceneLogicHelper {
final task = actions[index];
if (task.deviceId == 'delay') {
return CreateSceneAction(
productType: task.deviceType,
entityId: actions[index].deviceId,
actionExecutor: 'delay',
executorProperty: CreateSceneExecutorProperty(
@ -99,6 +100,7 @@ mixin SceneLogicHelper {
}
if (task.code == CreateSceneEnum.smartSceneSelect.name) {
return CreateSceneAction(
productType: task.deviceType,
actionType: task.operationName.toLowerCase() == 'automation'
? 'automation'
: 'scene',
@ -107,6 +109,7 @@ mixin SceneLogicHelper {
executorProperty: null);
}
return CreateSceneAction(
productType: task.deviceType,
entityId: task.deviceId,
actionExecutor: 'device_issue',
executorProperty: CreateSceneExecutorProperty(
@ -119,6 +122,20 @@ mixin SceneLogicHelper {
),
],
);
for (var action in createAutomationModel.actions) {
if (action.productType == 'NCPS') {
if (action.executorProperty!.functionCode == 'near_detection' ||
action.executorProperty!.functionCode == 'far_detection') {
action.executorProperty!.functionValue =
(action.executorProperty!.functionValue * 100).round();
} else if (action.executorProperty!.functionCode ==
'presence_delay' ||
action.executorProperty!.functionCode == 'none_delay') {
action.executorProperty!.functionValue =
action.executorProperty!.functionValue * 10;
}
}
}
sceneBloc.add(CreateSceneWithTasksEvent(
createSceneModel: null,
updateScene: updateScene,
@ -139,6 +156,7 @@ mixin SceneLogicHelper {
final task = actions[index];
if (task.deviceId == 'delay') {
return CreateSceneAction(
productType: task.deviceType,
entityId: actions[index].deviceId,
actionExecutor: 'delay',
executorProperty: CreateSceneExecutorProperty(
@ -150,11 +168,14 @@ mixin SceneLogicHelper {
}
if (task.code == CreateSceneEnum.smartSceneSelect.name) {
return CreateSceneAction(
productType: task.deviceType,
entityId: actions[index].deviceId,
actionExecutor: actions[index].functionValue,
executorProperty: null);
}
return CreateSceneAction(
productType: task.deviceType,
entityId: task.deviceId,
actionExecutor: 'device_issue',
executorProperty: CreateSceneExecutorProperty(
@ -167,6 +188,20 @@ mixin SceneLogicHelper {
),
],
);
for (var action in createSceneModel.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;
}
}
}
sceneBloc.add(CreateSceneWithTasksEvent(
createSceneModel: createSceneModel,
createAutomationModel: null,