@ledvance/ui-biz-bundle 1.0.55 → 1.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/ui-biz-bundle",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.0.55",
7
+ "version": "1.0.56",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@ledvance/base": "^1.x",
@@ -18,7 +18,7 @@ import LampAdjustView from '@ledvance/base/src/components/LampAdjustView'
18
18
  import {Utils} from 'tuya-panel-kit'
19
19
  import LdvSlider from '@ledvance/base/src/components/ldvSlider'
20
20
  import {saveScene, useScene} from '../scene/SceneAction'
21
- import {useDeviceId, useFanMaxSpeed} from '@ledvance/base/src/models/modules/NativePropsSlice'
21
+ import {isUVCFanDevice, useDeviceId, useFanMaxSpeed} from '@ledvance/base/src/models/modules/NativePropsSlice'
22
22
  import TextButton from '@ledvance/base/src/components/TextButton'
23
23
  import {SceneNodeInfo, SceneNodeTransitionMode} from '../scene/SceneInfo'
24
24
  import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton'
@@ -39,6 +39,7 @@ const DynamicMoodEditorPage = () => {
39
39
  const deviceId = useDeviceId()
40
40
  const [moodId, setScene] = useScene(moduleParams.sceneDpCode)
41
41
  const [, setWorkMode] = useWorkMode(moduleParams.workModeDpCode)
42
+ const isUVCFan = isUVCFanDevice()
42
43
  const state = useReactive<DynamicMoodEditorPageState>({
43
44
  headline: '',
44
45
  mood: params.currentMood,
@@ -94,6 +95,7 @@ const DynamicMoodEditorPage = () => {
94
95
  state.currentNode.transitionTime,
95
96
  list,
96
97
  moduleParams.isFanLamp!!,
98
+ isUVCFan
97
99
  )
98
100
  if (saveRes.success) {
99
101
  if (list.length > 0) {
@@ -104,7 +106,8 @@ const DynamicMoodEditorPage = () => {
104
106
  moduleParams.sceneDpCode,
105
107
  moduleParams.workModeDpCode,
106
108
  moduleParams.switchLedDpCode,
107
- !!moduleParams.isFanLamp
109
+ !!moduleParams.isFanLamp,
110
+ isUVCFan
108
111
  )
109
112
  console.log('设置修改后的场景结果', setSceneRes)
110
113
  } else if (!isDelete) {
@@ -114,7 +117,8 @@ const DynamicMoodEditorPage = () => {
114
117
  moduleParams.sceneDpCode,
115
118
  moduleParams.workModeDpCode,
116
119
  moduleParams.switchLedDpCode,
117
- !!moduleParams.isFanLamp
120
+ !!moduleParams.isFanLamp,
121
+ isUVCFan
118
122
  )
119
123
  console.log('设置修改后的场景结果', setSceneRes)
120
124
  }
@@ -4,7 +4,7 @@ import {Utils} from 'tuya-panel-kit'
4
4
  import {ScenePageUIState, SceneUIState} from '../scene/SceneInfo'
5
5
  import {getRemoteSceneList, useScene} from '../scene/SceneAction'
6
6
  import {SCENE, useWorkMode} from '../../hooks/DeviceDpStateHooks'
7
- import {useDeviceInfo} from '@ledvance/base/src/models/modules/NativePropsSlice'
7
+ import {isUVCFanDevice, useDeviceInfo} from '@ledvance/base/src/models/modules/NativePropsSlice'
8
8
  import {useReactive, useUpdateEffect} from 'ahooks'
9
9
  import Strings from '@ledvance/base/src/i18n'
10
10
  import res from '@ledvance/base/src/res'
@@ -60,6 +60,7 @@ const MoodPage = () => {
60
60
  const [workMode] = useWorkMode(params.workModeDpCode)
61
61
  const deviceInfo = useDeviceInfo()
62
62
  const navigation = useNavigation()
63
+ const isUVCFan = isUVCFanDevice()
63
64
 
64
65
  const state = useReactive<MoodPageUIState>({
65
66
  currentScene: undefined,
@@ -83,6 +84,7 @@ const MoodPage = () => {
83
84
  params.isFanLamp,
84
85
  params.isTWLamp,
85
86
  params.isDIMLamp,
87
+ isUVCFan
86
88
  )
87
89
  if (res.success) {
88
90
  state.scenes = res.data || []
@@ -42,6 +42,7 @@ export async function getRemoteSceneList(
42
42
  isFanLamp: boolean = false,
43
43
  isTWLamp: boolean = false,
44
44
  isDIMLamp: boolean = false,
45
+ isUVCFan?: boolean
45
46
  ): Promise<Result<SceneUIState[]>> {
46
47
  const res: NativeResult<RemoteSceneInfo[]> = await getFeature(deviceId, SceneFeatureId)
47
48
  if (!res.result) {
@@ -63,7 +64,7 @@ export async function getRemoteSceneList(
63
64
  }
64
65
  return {
65
66
  success: true,
66
- data: res.data.map((item, index) => remoteSceneInfo2SceneUIState(item, index, isFanLamp)),
67
+ data: res.data.map((item, index) => remoteSceneInfo2SceneUIState(item, index, isFanLamp, isUVCFan)),
67
68
  }
68
69
  }
69
70
 
@@ -71,8 +72,9 @@ function remoteSceneInfo2SceneUIState(
71
72
  remoteSceneInfo: RemoteSceneInfo,
72
73
  index: number,
73
74
  isFanLamp: boolean,
75
+ isUVCFan?: boolean
74
76
  ): SceneUIState {
75
- const sceneInfo = dp2Obj(remoteSceneInfo.i, isFanLamp)
77
+ const sceneInfo = dp2Obj(remoteSceneInfo.i, isFanLamp, isUVCFan)
76
78
  return {
77
79
  id: sceneInfo.id,
78
80
  fanEnable: sceneInfo.fanEnable,
@@ -83,7 +85,7 @@ function remoteSceneInfo2SceneUIState(
83
85
  }
84
86
  }
85
87
 
86
- export function dp2Obj(dp: string, isFan: boolean = false): SceneInfo {
88
+ export function dp2Obj(dp: string, isFan: boolean = false, isUVCFan?: boolean): SceneInfo {
87
89
  let dpCopy = dp
88
90
  let fanEnable = false
89
91
  let fanSpeed = 0
@@ -97,9 +99,10 @@ export function dp2Obj(dp: string, isFan: boolean = false): SceneInfo {
97
99
  }
98
100
  const nodes: SceneNodeInfo[] = spliceByStep(dpCopy, 26).map(nodeHex => {
99
101
  let hex = nodeHex
100
- const switchingInterval = hex2Int(hex.slice(0, 2))
102
+ const switchingInterval = isUVCFan ? 101 - hex2Int(hex.slice(0, 2)) : hex2Int(hex.slice(0, 2))
101
103
  hex = hex.slice(2)
102
- const transitionTime = hex2Int(hex.slice(0, 2))
104
+ const transitionTime = isUVCFan ? 101 - hex2Int(hex.slice(0, 2)) : hex2Int(hex.slice(0, 2))
105
+ console.log(transitionTime, '< --- transitionTime')
103
106
  hex = hex.slice(2)
104
107
  const transitionMode = hex2Int(hex.slice(0, 2))
105
108
  hex = hex.slice(2)
@@ -162,7 +165,8 @@ export function useScene(sceneDpCode: string): [
162
165
  sceneDpCode: string,
163
166
  workModeDpKey: string,
164
167
  switchDpCode: string,
165
- isFanLamp: boolean
168
+ isFanLamp: boolean,
169
+ isUVCFan?: boolean
166
170
  ) => Promise<Result<any>>
167
171
  ] {
168
172
  const [dp] = useDp<string, any>(sceneDpCode)
@@ -179,10 +183,11 @@ const setScene = (dispatch: Dispatch<any>) => (
179
183
  sceneDpCode: string,
180
184
  workModeDpKey: string,
181
185
  switchDpCode: string,
182
- isFanLamp: boolean
186
+ isFanLamp: boolean,
187
+ isUVCFan?: boolean
183
188
  ) =>
184
189
  asyncSetDps(dispatch, async () => {
185
- const dpValue = obj2Dp(scene, isFanLamp)
190
+ const dpValue = obj2Dp(scene, isFanLamp, isUVCFan)
186
191
  const controlResult: any = await setSceneDp(
187
192
  deviceId,
188
193
  dpValue,
@@ -197,7 +202,7 @@ const setScene = (dispatch: Dispatch<any>) => (
197
202
  })
198
203
 
199
204
 
200
- export function obj2Dp(scene: SceneInfo, isFan: boolean = false): string {
205
+ export function obj2Dp(scene: SceneInfo, isFan: boolean = false, isUVCFan?: boolean): string {
201
206
  let fanEnableHex = ''
202
207
  let fanSpeedHex = ''
203
208
  const idHex = scene.id.toString(16).padStart(2, '0')
@@ -206,8 +211,8 @@ export function obj2Dp(scene: SceneInfo, isFan: boolean = false): string {
206
211
  fanSpeedHex = (scene.fanSpeed || 1).toString(16).padStart(2, '0')
207
212
  }
208
213
  const hex = idHex + fanEnableHex + fanSpeedHex + scene.nodes.map(node => {
209
- const switchingIntervalHex = node.switchingInterval.toString(16).padStart(2, '0')
210
- const transitionTimeHex = node.transitionTime.toString(16).padStart(2, '0')
214
+ const switchingIntervalHex = (isUVCFan ? 101 - node.switchingInterval : node.switchingInterval).toString(16).padStart(2, '0')
215
+ const transitionTimeHex = (isUVCFan ? 101 - node.transitionTime : node.transitionTime).toString(16).padStart(2, '0')
211
216
  const transitionModeHex = node.transitionMode.toString(16).padStart(2, '0')
212
217
  const hHex = node.h.toString(16).padStart(4, '0')
213
218
  const sHex = (node.s * 10).toString(16).padStart(4, '0')
@@ -227,6 +232,7 @@ export async function saveScene(
227
232
  transitionTime: number,
228
233
  scenes: SceneUIState[],
229
234
  isFanLamp: boolean,
235
+ isUVCFan?: boolean
230
236
  ) {
231
237
  if (transitionMode === SceneNodeTransitionMode.Static) {
232
238
  scene.nodes = [scene.nodes[0]]
@@ -248,7 +254,7 @@ export async function saveScene(
248
254
  const sceneTemp = s.id === scene.id ? scene : s
249
255
  return {
250
256
  n: sceneTemp.name,
251
- i: obj2Dp(sceneTemp, isFanLamp),
257
+ i: obj2Dp(sceneTemp, isFanLamp, isUVCFan),
252
258
  s: '',
253
259
  t: 0,
254
260
  e: false,