@ledvance/ui-biz-bundle 1.0.13 → 1.0.15

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.
@@ -18,6 +18,12 @@ import { useReactive } from 'ahooks';
18
18
  import { dpItem } from "./TimeSchedulePage";
19
19
  import { differenceBy } from "lodash";
20
20
  import DeviceState from "./DeviceState";
21
+ import { JudgeTimeScheduleProps } from "./TimeScheduleBean";
22
+ import { getHSVByHex, getHexByHSV } from "@ledvance/base/src/utils";
23
+ import { Buffer } from 'buffer';
24
+ import { dp2Obj, obj2Dp } from './mix/MixLightActions'
25
+ import { COLOUR, SCENE, WHITE } from "@ledvance/ui-biz-bundle/src/hooks/DeviceDpStateHooks";
26
+ import { obj2Dp as senceObj2Dp, dp2Obj as sencePp2Obj } from "../scene/SceneAction";
21
27
 
22
28
  const { convertX: cx } = Utils.RatioUtils
23
29
 
@@ -26,11 +32,12 @@ export interface ScheduleItemDp extends dpItem {
26
32
  enable: boolean
27
33
  }
28
34
 
29
- interface TimeScheduleEditPageParams {
35
+ interface TimeScheduleEditPageParams extends JudgeTimeScheduleProps {
30
36
  scheduleItem: any,
31
37
  dps: ScheduleItemDp[]
32
38
  dpCodes: Record<any, any>
33
39
  reloadData: () => void
40
+ getDpValue?: (v:any) => any
34
41
  deleteDialog: (item: any) => Promise<void>
35
42
  }
36
43
 
@@ -38,18 +45,41 @@ const TimeScheduleEditPage = () => {
38
45
  const navigation = useNavigation()
39
46
  const devId = useDeviceId()
40
47
  const route = useRoute()
41
- const { scheduleItem, dps, reloadData, deleteDialog, dpCodes } = route.params as TimeScheduleEditPageParams
48
+ const props = route.params as TimeScheduleEditPageParams
49
+ const { scheduleItem, dps, reloadData, deleteDialog, dpCodes } = props
42
50
  const state = useReactive({
43
51
  hour: '00',
44
52
  minute: '00',
45
53
  loop: [0, 0, 0, 0, 0, 0, 0],
46
54
  isNotification: false,
47
- brightValue: 50,
48
55
  name: '',
49
56
  selectedSkill: [] as ScheduleItemDp[],
50
- skillList: [] as ScheduleItemDp[],
57
+ skillList: [] as ScheduleItemDp[],
51
58
  isManual: true,
52
- dpsValue: {} as Record<string,any>
59
+ singleActions: {
60
+ enable: true,
61
+ isColor: true,
62
+ h: 0,
63
+ s: 100,
64
+ v: 100,
65
+ temperature: 100,
66
+ brightness: 100,
67
+ fanEnable: true,
68
+ fanSpeed: 1,
69
+ fanMode: 'normal',
70
+ },
71
+ mixActions: {
72
+ whiteLightSwitch: true,
73
+ colorLightSwitch: false,
74
+ mixRgbcwEnabled: true,
75
+ hue: 360,
76
+ sat: 100,
77
+ lightness: 100,
78
+ brightness: 100,
79
+ colorTempPercent: 100,
80
+ },
81
+ actionScene: {} as any,
82
+ dpsValue: {} as Record<string, any>
53
83
  })
54
84
 
55
85
 
@@ -62,7 +92,6 @@ const TimeScheduleEditPage = () => {
62
92
  state.name = scheduleItem.aliasName;
63
93
  state.isNotification = scheduleItem.isAppPush;
64
94
  state.loop = scheduleItem.loops.split('').map(mItem => parseInt(mItem));
65
- state.brightValue = parseInt(scheduleItem.dps[dpCodes.bright_value]) / 10 || 50
66
95
  state.selectedSkill = dps.reduce((pre, cur) => {
67
96
  if (scheduleItem.dps[cur.dpId] !== undefined) {
68
97
  const result = { ...cur, enable: scheduleItem.dps[cur.dpId] }
@@ -71,14 +100,58 @@ const TimeScheduleEditPage = () => {
71
100
  return pre
72
101
  }, [] as ScheduleItemDp[])
73
102
  state.skillList = differenceBy(dps, state.selectedSkill, 'dpId')
103
+
104
+ // single
105
+ if (scheduleItem.dps[dpCodes.switch_led] !== undefined) {
106
+ state.singleActions.enable = scheduleItem.dps[dpCodes.switch_led]
107
+ }
108
+ if (scheduleItem.dps[dpCodes.work_mode] !== undefined) {
109
+ state.singleActions.isColor = scheduleItem.dps[dpCodes.work_mode] === COLOUR
110
+ }
111
+ if (scheduleItem.dps[dpCodes.fan_switch] !== undefined) {
112
+ state.singleActions.fanEnable = scheduleItem.dps[dpCodes.fan_switch]
113
+ }
114
+ state.singleActions.brightness = scheduleItem.dps[dpCodes.bright_value] / 10 || 100
115
+ state.singleActions.temperature = scheduleItem.dps[dpCodes.temp_value] / 10 || 100
116
+ state.singleActions.fanSpeed = scheduleItem.dps[dpCodes.fan_speed] || 1
117
+ state.singleActions.fanMode = scheduleItem.dps[dpCodes.fan_mode] || 'normal'
118
+ const hsv = getHSVByHex(scheduleItem.dps[dpCodes.colour_data] || '0000000003e8');
119
+ state.singleActions.h = hsv.h;
120
+ state.singleActions.s = Math.round(hsv.s / 10);
121
+ state.singleActions.v = Math.round(hsv.v / 10);
122
+
123
+ // mix
124
+ if (scheduleItem.dps[dpCodes.mix_rgbcw] !== undefined) {
125
+ const base64String = Buffer.from(scheduleItem.dps[dpCodes.mix_rgbcw], 'base64').toString('hex')
126
+ state.mixActions = dp2Obj(base64String)
127
+ }
128
+
129
+ if (scheduleItem.dps[dpCodes.scene_data] !== undefined) {
130
+ state.actionScene = sencePp2Obj(scheduleItem.dps[dpCodes.scene_data], !!props.isFanLamp)
131
+ state.isManual = false
132
+ }
133
+ if (scheduleItem.dps[dpCodes.mix_light_scene] !== undefined) {
134
+ const sceneDp = scheduleItem.dps[dpCodes.mix_light_scene]
135
+ state.actionScene = Buffer.from(sceneDp, 'base64').toString('hex')
136
+ state.isManual = false
137
+ }
138
+
74
139
  } else {
75
140
  const date = new Date();
76
141
  state.hour = toFixed(date.getHours(), 2);
77
142
  state.minute = toFixed(date.getMinutes(), 2);
78
- state.skillList = dps.map(item => ({
79
- ...item,
80
- enable: true
81
- }))
143
+ // dps长度只有1个的时候或者是mixLight灯时默认选中,
144
+ if(!showClearIcon()){
145
+ state.selectedSkill = dps.map(item => ({
146
+ ...item,
147
+ enable: true
148
+ }))
149
+ }else{
150
+ state.skillList = dps.map(item => ({
151
+ ...item,
152
+ enable: true
153
+ }))
154
+ }
82
155
  }
83
156
  }, [])
84
157
 
@@ -105,11 +178,12 @@ const TimeScheduleEditPage = () => {
105
178
  const params = {
106
179
  time: [state.hour, state.minute].join(':'),
107
180
  loops: state.loop.join(''),
108
- dps: getSendDps(),
181
+ dps: getAllDps(),
109
182
  aliasName: state.name,
110
183
  status: true,
111
184
  notification: state.isNotification,
112
185
  }
186
+
113
187
  if (scheduleItem) {
114
188
  NativeApi.editTimer(
115
189
  devId,
@@ -139,21 +213,148 @@ const TimeScheduleEditPage = () => {
139
213
  };
140
214
 
141
215
  const getSendDps = () => {
142
- let dp = {}
143
- state.selectedSkill.forEach(item => {
144
- dp = {
145
- ...dp,
146
- ...state.dpsValue[item.dpId],
147
- [item.dpId]: item.enable
216
+
217
+ if (state.isManual) {
218
+ if (props.isDIMLamp) {
219
+ return {
220
+ [dpCodes.bright_value]: state.singleActions.brightness * 10,
221
+ };
222
+ } else if (props.isFanLamp) {
223
+ let v = {}
224
+ const hasFan = !!state.selectedSkill.find(item => item.value.includes('fan'))
225
+ const hasLight = !!state.selectedSkill.find(item => item.value.includes('light'))
226
+ if (hasFan) {
227
+ v = {
228
+ ...v,
229
+ [dpCodes.fan_mode]: state.singleActions.fanMode,
230
+ [dpCodes.fan_speed]: state.singleActions.fanSpeed
231
+ }
232
+ }
233
+ if (hasLight) {
234
+ v = {
235
+ ...v,
236
+ [dpCodes.work_mode]: WHITE,
237
+ [dpCodes.bright_value]: state.singleActions.brightness * 10,
238
+ [dpCodes.temp_value]: state.singleActions.temperature * 10,
239
+ }
240
+ }
241
+ return v
242
+ } if (props.isTWLamp) {
243
+ return {
244
+ [dpCodes.work_mode]: WHITE,
245
+ [dpCodes.bright_value]: state.singleActions.brightness * 10,
246
+ [dpCodes.temp_value]: state.singleActions.temperature * 10,
247
+ };
248
+ } if (props.isRGBWLamp) {
249
+ if (state.singleActions.isColor) {
250
+ const colorString = getHexByHSV({
251
+ h: state.singleActions.h,
252
+ s: state.singleActions.s * 10,
253
+ v: state.singleActions.v * 10,
254
+ });
255
+ return {
256
+ [dpCodes.work_mode]: COLOUR,
257
+ [dpCodes.colour_data]: colorString,
258
+ };
259
+ }
260
+ return {
261
+ [dpCodes.work_mode]: WHITE,
262
+ [dpCodes.temp_value]: state.singleActions.temperature * 10,
263
+ [dpCodes.bright_value]: state.singleActions.brightness * 10,
264
+ };
265
+
266
+ } else if (props.isMixRGBWLamp) {
267
+ const dpsString = obj2Dp(state.mixActions);
268
+ return {
269
+ [dpCodes.switch_led]: true,
270
+ [dpCodes.mix_rgbcw]: Buffer.from(dpsString, 'hex').toString('base64'),
271
+ };
272
+ } else if (props.isGlassRGBWLamp) {
273
+ const colorString = getHexByHSV({
274
+ h: state.singleActions.h,
275
+ s: state.singleActions.s * 10,
276
+ v: state.singleActions.v * 10,
277
+ });
278
+ return {
279
+ [dpCodes.work_mode]: COLOUR,
280
+ [dpCodes.colour_data]: colorString,
281
+ };
282
+ } else if (props.isGARDOT) {
283
+ const colorString = getHexByHSV({
284
+ h: state.singleActions.h,
285
+ s: state.singleActions.s * 10,
286
+ v: state.singleActions.v * 10,
287
+ });
288
+ return {
289
+ [dpCodes.work_mode]: COLOUR,
290
+ [dpCodes.colour_data]: colorString,
291
+ };
292
+ } else {
293
+ const colorString = getHexByHSV({
294
+ h: state.singleActions.h,
295
+ s: state.singleActions.s * 10,
296
+ v: state.singleActions.v * 10,
297
+ });
298
+ return {
299
+ [dpCodes.switch_led]: true,
300
+ [dpCodes.colour_data]: colorString,
301
+ };
148
302
  }
149
- })
150
- return dp
303
+ } else {
304
+ if (props.isMixRGBWLamp) {
305
+ const v = {
306
+ [dpCodes.mix_light_scene]: Buffer.from(state.actionScene?.value, 'hex').toString('base64'),
307
+ [dpCodes.switch_led]: true,
308
+ [dpCodes.work_mode]: SCENE
309
+ }
310
+ return props.isFanLamp ? {
311
+ ...v,
312
+ [dpCodes.fan_switch]: state.actionScene.fanEnable,
313
+ [dpCodes.fan_speed]: state.actionScene.fanSpeed
314
+ } : v;
315
+ } else {
316
+ const v = {
317
+ [dpCodes.switch_led]: true,
318
+ [dpCodes.scene_data]: senceObj2Dp({ id: Number(state?.actionScene?.id), nodes: state?.actionScene?.nodes }, !!props.isFanLamp),
319
+ [dpCodes.work_mode]: SCENE,
320
+ }
321
+ return props.isFanLamp ? {
322
+ ...v,
323
+ [dpCodes.fan_switch]: state.actionScene.fanEnable,
324
+ [dpCodes.fan_speed]: state.actionScene.fanSpeed
325
+ } : v;
326
+ }
327
+ }
328
+
329
+ }
330
+
331
+ const getAllDps = () => {
332
+ const incommingValue = props.getDpValue ? props.getDpValue({
333
+ singleActions: state.singleActions,
334
+ mixActions: state.mixActions,
335
+ actionScene: state.actionScene,
336
+ isManual: state.isManual
337
+ }) : ''
338
+ const dpsValue = incommingValue || getSendDps()
339
+ if (state.isManual && !props.isMixRGBWLamp) {
340
+ let v = {}
341
+ state.selectedSkill.forEach(skill => {
342
+ v[skill.dpId] = skill.enable
343
+ })
344
+ return {
345
+ ...v,
346
+ ...dpsValue
347
+ }
348
+ } else {
349
+ return dpsValue
350
+ }
151
351
  }
152
352
 
153
- const setSendDps = useCallback((dp: string,dps: Record<string, any>) =>{
154
- state.dpsValue[dp] = dps
353
+ const setSendDps = useCallback((actions, type) => {
354
+ state[type] = actions
155
355
  }, [])
156
356
 
357
+ console.log(state?.actionScene, '< --- actionScenen')
157
358
  const renderItem = ({ item }) => {
158
359
  return (
159
360
  <View style={{
@@ -173,9 +374,9 @@ const TimeScheduleEditPage = () => {
173
374
  >
174
375
  {item.label}
175
376
  </Text>
176
- <TouchableOpacity onPress={() => handelSkill('lower', item)}>
377
+ {showClearIcon() && <TouchableOpacity onPress={() => handelSkill('lower', item)}>
177
378
  <Image style={{ width: cx(16), height: cx(16), marginRight: cx(5) }} source={res.ic_arrows_nav_clear} />
178
- </TouchableOpacity>
379
+ </TouchableOpacity>}
179
380
  </View>
180
381
  );
181
382
  };
@@ -194,16 +395,20 @@ const TimeScheduleEditPage = () => {
194
395
  return !!state.selectedSkill.length
195
396
  }
196
397
 
197
- const changeSkillEnable = (dpId:string, enable: boolean) =>{
398
+ const changeSkillEnable = (dpId: string, enable: boolean) => {
198
399
  state.selectedSkill = state.selectedSkill.map((skill) => {
199
- if(dpId === skill.dpId){
400
+ if (dpId === skill.dpId) {
200
401
  skill.enable = enable
201
402
  }
202
403
  return skill
203
404
  })
204
405
  }
205
-
206
406
 
407
+ const showClearIcon = () =>{
408
+ return dps.length > 1 && !props.isMixRGBWLamp
409
+ }
410
+
411
+ console.log(scheduleItem, '< --- scheduleItem')
207
412
  return (
208
413
  <Page
209
414
  backText={I18n.getLang('motion_detection_add_time_schedule_system_back_text')}
@@ -281,14 +486,30 @@ const TimeScheduleEditPage = () => {
281
486
  <View>
282
487
  <Text style={styles.itemTitle}>{I18n.getLang('timeschedule_add_schedule_subheadline2_text')}</Text>
283
488
  </View>
284
- <DeviceState
489
+ <DeviceState
490
+ singleActions={state.singleActions}
491
+ mixActions={state.mixActions}
492
+ actionScene={state.actionScene}
285
493
  dpCodes={dpCodes}
286
- dps={state.selectedSkill}
494
+ dps={state.skillList}
495
+ selectedDps={state.selectedSkill}
287
496
  scheduleItem={scheduleItem}
288
497
  isManual={state.isManual}
289
498
  setIsManual={(v) => state.isManual = v}
290
499
  setSendDps={setSendDps}
291
500
  changeSkillEnable={changeSkillEnable}
501
+ isDIMLamp={props.isDIMLamp}
502
+ isGARDOT={props.isGARDOT}
503
+ isGlassRGBWLamp={props.isGlassRGBWLamp}
504
+ isOnlyRGBLamp={props.isOnlyRGBLamp}
505
+ isRGBLamp={props.isRGBLamp}
506
+ isRGBWLamp={props.isRGBWLamp}
507
+ isMixRGBWLamp={props.isMixRGBWLamp}
508
+ isTWLamp={props.isTWLamp}
509
+ isFanLamp={props.isFanLamp}
510
+ isSupportMode={props.isSupportMode}
511
+ isSupportBrightness={props.isSupportBrightness}
512
+ isSupportTemperature={props.isSupportTemperature}
292
513
  />
293
514
  {!hasSelected() && <View style={{ flexDirection: 'row', alignItems: 'center' }}>
294
515
  <Image style={{ width: cx(16), height: cx(16), tintColor: '#FF9500' }} source={res.ic_warning_amber} />
@@ -1,7 +1,13 @@
1
+ import { JudgeTimeScheduleProps } from './TimeScheduleBean';
1
2
  export type dpItem = {
2
3
  label: string;
3
4
  value: string;
4
5
  dpId: string;
5
6
  };
7
+ export interface TimeSchedulePageRouteParams extends JudgeTimeScheduleProps {
8
+ dps: dpItem[];
9
+ dpCodes: Record<string, string>;
10
+ getDpValue: (v: any) => any;
11
+ }
6
12
  declare const TimeSchedulePage: () => any;
7
13
  export default TimeSchedulePage;
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useEffect } from 'react'
2
- import {RouteProp, useRoute} from '@react-navigation/core'
2
+ import { useRoute} from '@react-navigation/core'
3
3
  import Page from '@ledvance/base/src/components/Page'
4
4
  import Tag from '@ledvance/base/src/components/Tag'
5
5
  import { useDeviceInfo, useTimeSchedule } from '@ledvance/base/src/models/modules/NativePropsSlice'
@@ -15,6 +15,7 @@ import { showDialog } from '@ledvance/base/src/utils/common'
15
15
  import { useReactive } from 'ahooks'
16
16
  import { cloneDeep } from 'lodash'
17
17
  import { ui_biz_routerKey } from 'navigation/Routers'
18
+ import { JudgeTimeScheduleProps } from './TimeScheduleBean'
18
19
 
19
20
  const { convertX: cx } = Utils.RatioUtils
20
21
 
@@ -24,18 +25,19 @@ export type dpItem = {
24
25
  dpId: string
25
26
  }
26
27
 
27
- type TimeSchedulePageRouteParams = {
28
- params: { dps: dpItem[], dpCodes: Record<string,string>}
28
+ export interface TimeSchedulePageRouteParams extends JudgeTimeScheduleProps{
29
+ dps: dpItem[],
30
+ dpCodes: Record<string,string>
31
+ getDpValue: (v:any) => any
29
32
  }
30
33
 
31
- type Props = {
32
- route: RouteProp<TimeSchedulePageRouteParams, 'params'>
33
- }
34
34
 
35
35
  const TimeSchedulePage = () => {
36
36
  const deviceInfo = useDeviceInfo()
37
37
  const navigation = useNavigation()
38
- const { dps, dpCodes } = useRoute<Props['route']>().params
38
+ const props = useRoute().params as TimeSchedulePageRouteParams
39
+ console.log(props, '< --- propssss')
40
+ const { dps, dpCodes } = props
39
41
  const state = useReactive({
40
42
  timeScheduleList: [] as any[],
41
43
  filterScheduleList: [] as any[],
@@ -68,12 +70,11 @@ const TimeSchedulePage = () => {
68
70
  navigation.navigate(path, {
69
71
  name: path,
70
72
  scheduleItem: item,
71
- dpCodes,
72
- dps,
73
73
  reloadData: getTimerScheduleList,
74
74
  deleteDialog: (item:any) =>{
75
75
  return deleteDialog(item)
76
- }
76
+ },
77
+ ...props
77
78
  })
78
79
  }, [state.timeScheduleList])
79
80
 
@@ -0,0 +1,3 @@
1
+ import { MixLightBean } from "./MixLightBean";
2
+ export declare function obj2Dp(obj: MixLightBean): string;
3
+ export declare function dp2Obj(dp: string): MixLightBean;
@@ -0,0 +1,50 @@
1
+ import { spliceByStep } from "@ledvance/base/src/utils/common"
2
+ import { MixLightBean } from "./MixLightBean"
3
+
4
+ export function obj2Dp(obj: MixLightBean): string {
5
+ const powerSwitchDpValueArray = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
6
+ if (obj.whiteLightSwitch) {
7
+ powerSwitchDpValueArray[15] = '1'
8
+ }
9
+ if (obj.colorLightSwitch) {
10
+ powerSwitchDpValueArray[14] = '1'
11
+ }
12
+ if (obj.mixRgbcwEnabled) {
13
+ powerSwitchDpValueArray[13] = '1'
14
+ }
15
+ const powerSwitchDpValueBinary = powerSwitchDpValueArray.join('')
16
+ const powerSwitchDpValue = parseInt(powerSwitchDpValueBinary, 2).toString(16).padStart(4, '0')
17
+ const hueDpValue = obj.hue.toString(16).padStart(4, '0')
18
+ const satDpValue = (obj.sat * 10).toString(16).padStart(4, '0')
19
+ const lightnessDpValue = (obj.lightness * 10).toString(16).padStart(4, '0')
20
+ const brightnessDpValue = (obj.brightness * 10).toString(16).padStart(4, '0')
21
+ const colorTempDpValue = (obj.colorTempPercent * 10).toString(16).padStart(4, '0')
22
+ return powerSwitchDpValue + hueDpValue + satDpValue + lightnessDpValue + brightnessDpValue + colorTempDpValue
23
+ }
24
+
25
+ export function dp2Obj(dp: string): MixLightBean {
26
+ if (!dp) {
27
+ return {
28
+ whiteLightSwitch: true,
29
+ colorLightSwitch: true,
30
+ mixRgbcwEnabled: true,
31
+ hue: 360,
32
+ sat: 100,
33
+ lightness: 100,
34
+ brightness: 100,
35
+ colorTempPercent: 100,
36
+ }
37
+ }
38
+ const dpValueArray = spliceByStep(dp, 4)
39
+ const powerSwitch = parseInt(dpValueArray[0], 16).toString(2).padStart(16, '0')
40
+ return {
41
+ whiteLightSwitch: powerSwitch[15] === '1',
42
+ colorLightSwitch: powerSwitch[14] === '1',
43
+ mixRgbcwEnabled: powerSwitch[13] === '1',
44
+ hue: parseInt(dpValueArray[1], 16), // 色相 0-360
45
+ sat: parseInt(dpValueArray[2], 16) / 10, // 饱和度 0-100
46
+ lightness: parseInt(dpValueArray[3], 16) / 10, // 明度 0-100
47
+ brightness: parseInt(dpValueArray[4], 16) / 10, // 亮度 0-100
48
+ colorTempPercent: parseInt(dpValueArray[5], 16) / 10, // 色温 0-100
49
+ }
50
+ }
@@ -1,7 +1,8 @@
1
1
  interface MixLightViewProps {
2
+ mixActions: any;
2
3
  scheduleItem: any;
3
4
  dpCodes: Record<string, string>;
4
- setSendDps: (dpId: string, dp: Record<string, any>) => void;
5
+ setSendDps: (actions: any, type: string) => void;
5
6
  }
6
7
  export default function MixLightView(props: MixLightViewProps): any;
7
8
  export {};
@@ -14,44 +14,38 @@ import LdvSaturation from '@ledvance/base/src/components/ldvSaturation'
14
14
  import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
15
15
  import { mapFloatToRange } from '@ledvance/base/src/utils'
16
16
  import { Buffer } from 'buffer';
17
- import { dp2Obj, obj2Dp } from '../../scene/SceneAction'
17
+ import { dp2Obj, obj2Dp } from './MixLightActions'
18
18
 
19
19
  const { convertX: cx } = Utils.RatioUtils
20
20
 
21
21
  interface MixLightViewProps {
22
+ mixActions: any
22
23
  scheduleItem: any
23
24
  dpCodes: Record<string, string>
24
- setSendDps: (dpId: string, dp: Record<string,any>) => void
25
+ setSendDps: (actions:any, type:string) => void
25
26
  }
26
27
 
27
28
  export default function MixLightView(props: MixLightViewProps) {
28
29
  const { scheduleItem, dpCodes, setSendDps } = props
29
30
  const state = useReactive({
30
31
  actionMix: {
31
- whiteLightSwitch: true,
32
- colorLightSwitch: false,
33
- mixRgbcwEnabled: true,
34
- hue: 360,
35
- sat: 100,
36
- lightness: 100,
37
- brightness: 100,
38
- colorTempPercent: 100,
32
+ ...props.mixActions
39
33
  },
40
34
  flag: Symbol(),
41
35
  })
42
36
 
43
- useEffect(() => {
44
- if (scheduleItem) {
45
- if (scheduleItem.dps[dpCodes.mix_rgbcw] !== undefined) {
46
- const base64String = Buffer.from(scheduleItem.dps[dpCodes.mix_rgbcw], 'base64').toString('hex')
47
- state.actionMix = dp2Obj(base64String)
48
- }
49
- }
50
- }, [])
37
+ // useEffect(() => {
38
+ // if (scheduleItem) {
39
+ // if (scheduleItem.dps[dpCodes.mix_rgbcw] !== undefined) {
40
+ // const base64String = Buffer.from(scheduleItem.dps[dpCodes.mix_rgbcw], 'base64').toString('hex')
41
+ // state.actionMix = dp2Obj(base64String)
42
+ // }
43
+ // }
44
+ // }, [])
51
45
 
52
46
  useEffect(() =>{
53
- const dp = getSendDps()
54
- setSendDps('mix',dp)
47
+ // const dp = getSendDps()
48
+ setSendDps(state.actionMix, 'mixActions')
55
49
  }, [state.flag])
56
50
 
57
51
  const getSendDps = () =>{
@@ -73,6 +67,7 @@ export default function MixLightView(props: MixLightViewProps) {
73
67
  enable={state.actionMix.whiteLightSwitch}
74
68
  setEnable={async value => {
75
69
  state.actionMix.whiteLightSwitch = value
70
+ state.flag = Symbol()
76
71
  }} />
77
72
  {state.actionMix.whiteLightSwitch && (<View>
78
73
  <View style={[styles.shadeBg]}>
@@ -122,6 +117,7 @@ export default function MixLightView(props: MixLightViewProps) {
122
117
  enable={state.actionMix.colorLightSwitch}
123
118
  setEnable={value => {
124
119
  state.actionMix.colorLightSwitch = value
120
+ state.flag = Symbol()
125
121
  }} />
126
122
 
127
123
  {state.actionMix.colorLightSwitch && (