@ledvance/ui-biz-bundle 1.0.74 → 1.0.75
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
|
@@ -109,29 +109,59 @@ export const musicDefalutDatasource = [
|
|
|
109
109
|
},
|
|
110
110
|
]
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
export type DreamMusicDataType = {
|
|
113
|
+
id: number
|
|
114
|
+
mode: number
|
|
115
|
+
title: string
|
|
116
|
+
value: string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const dreamMusicData: DreamMusicDataType[] = [
|
|
113
120
|
{
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
id: 0,
|
|
122
|
+
mode: 3,
|
|
123
|
+
title: Strings.getLang('devicemusic_music_text'),
|
|
124
|
+
value: '0101000364320000006400006400786400f064003c6400b464012c64000000'
|
|
116
125
|
},
|
|
117
126
|
{
|
|
118
|
-
|
|
127
|
+
id: 1,
|
|
128
|
+
mode: 2,
|
|
129
|
+
title: Strings.getLang('devicemusic_ball_game_text'),
|
|
119
130
|
value: '0101000264320000006400005000785000f050003c5000b450012c50000000'
|
|
120
131
|
},
|
|
121
132
|
{
|
|
122
|
-
|
|
133
|
+
id: 2,
|
|
134
|
+
mode: 2,
|
|
135
|
+
title: Strings.getLang('devicemusic_game_text'),
|
|
123
136
|
value: '0101001264320000006400006400786400f064003c6400b464012c64000000'
|
|
124
137
|
},
|
|
125
138
|
{
|
|
126
|
-
|
|
139
|
+
id: 3,
|
|
140
|
+
mode: 2,
|
|
141
|
+
title: Strings.getLang('devicemusic_romantic_text'),
|
|
127
142
|
value: '0101010264320100006400006400786400f064003c6400b464012c64000000'
|
|
128
143
|
},
|
|
129
144
|
{
|
|
130
|
-
|
|
145
|
+
id: 4,
|
|
146
|
+
mode: 0,
|
|
147
|
+
title: "Genre 5",
|
|
131
148
|
value: '0101020064320100006400006400786400f064003c6400b464012c64'
|
|
132
149
|
},
|
|
133
150
|
{
|
|
134
|
-
|
|
151
|
+
id: 5,
|
|
152
|
+
mode: 0,
|
|
153
|
+
title: "Genre 6",
|
|
135
154
|
value: '0101031064320100006400006400786400f064003c6400b464012c64000000'
|
|
136
155
|
}
|
|
137
156
|
]
|
|
157
|
+
|
|
158
|
+
export const musicTabs = [
|
|
159
|
+
{
|
|
160
|
+
key: 0,
|
|
161
|
+
title: Strings.getLang('devicemusic_switch_tab_device')
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
key: 1,
|
|
165
|
+
title: Strings.getLang('devicemusic_switch_tab_smartphone')
|
|
166
|
+
}
|
|
167
|
+
]
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import React, { useEffect } from 'react'
|
|
1
|
+
import React, { useCallback, useEffect } from 'react'
|
|
2
2
|
import { StyleSheet, View, Text, Image } from 'react-native'
|
|
3
|
-
import { useRoute } from '@react-navigation/core'
|
|
3
|
+
import { useRoute, useNavigation } from '@react-navigation/core'
|
|
4
4
|
import Page from '@ledvance/base/src/components/Page'
|
|
5
5
|
import { useDeviceId, useDeviceInfo } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
6
6
|
import Strings from '@ledvance/base/src/i18n'
|
|
7
7
|
import Img from './res'
|
|
8
|
-
import { useEnable, useWorkMode, useMixRgbcw, useMixScene, useMusicData } from './MusicPageActions'
|
|
8
|
+
import { useEnable, useWorkMode, useMixRgbcw, useMixScene, useMusicData, useDreamMusic, DreamLightMicMusicData, getRemoteDreamMusic, DreamLightMicMusicUIState, saveRemoteDreamMusic } from './MusicPageActions'
|
|
9
9
|
import { useReactive, useUpdateEffect } from 'ahooks'
|
|
10
10
|
import { NativeApi } from '@ledvance/base/src/api/native'
|
|
11
|
-
import { AppleMusicDataType,
|
|
11
|
+
import { AppleMusicDataType, musicDefalutDatasource, musicTabs } from './MusicDataBean'
|
|
12
12
|
import { Dialog, SwitchButton, TabBar, Utils } from 'tuya-panel-kit'
|
|
13
13
|
import * as MusicManager from './MusicManager'
|
|
14
|
-
import { ShowSelectView } from '@ledvance/base/src/components/ShowSelect'
|
|
15
|
-
import SelecetGenre from './SelecetGenre'
|
|
16
14
|
import { JudgeTimeScheduleProps } from "../timeSchedule/TimeScheduleBean"
|
|
17
15
|
import Spacer from '@ledvance/base/src/components/Spacer'
|
|
18
16
|
import LdvSlider from '@ledvance/base/src/components/ldvSlider'
|
|
19
|
-
import
|
|
20
|
-
|
|
17
|
+
import TextFieldStyleButton from '@ledvance/base/src/components/TextFieldStyleButton'
|
|
18
|
+
import { SelectPageParams } from '@ledvance/ui-biz-bundle/src/modules/select/SelectPage'
|
|
19
|
+
import { ui_biz_routerKey } from '@ledvance/ui-biz-bundle/src/navigation/Routers'
|
|
20
|
+
import { cloneDeep } from 'lodash'
|
|
21
21
|
const { convertX: cx } = Utils.RatioUtils
|
|
22
22
|
|
|
23
23
|
export interface MusicPageRouterParams extends JudgeTimeScheduleProps {
|
|
@@ -32,86 +32,143 @@ export interface MusicPageRouterParams extends JudgeTimeScheduleProps {
|
|
|
32
32
|
const MusicPage = () => {
|
|
33
33
|
const deviceInfo = useDeviceInfo()
|
|
34
34
|
const deviceId = useDeviceId()
|
|
35
|
+
const navigation = useNavigation()
|
|
35
36
|
const props = useRoute().params as MusicPageRouterParams
|
|
36
37
|
const [workMode, setWorkMode] = useWorkMode(props.work_mode)
|
|
37
38
|
const [mixLight] = useMixRgbcw(props.mix_rgbcw, props.switch_led)
|
|
38
39
|
const [, setMixScene] = useMixScene(props.mix_light_scene, props.work_mode)
|
|
39
40
|
const [, setMusicData] = useMusicData(props.music_data)
|
|
41
|
+
const [dreamMusic, setDreamMusic] = props.dreamMusicDp ? useDreamMusic(props.dreamMusicDp) : []
|
|
40
42
|
const [switchLed, setSwitchLed] = useEnable(props.switch_led)
|
|
41
43
|
|
|
42
44
|
const state = useReactive({
|
|
43
45
|
musicEnable: false,
|
|
44
|
-
|
|
45
|
-
musicType: 1, // 0 设备麦克风, 1 手机麦克风
|
|
46
|
-
sensitivity: 100,
|
|
46
|
+
musicType: props.dreamMusicDp ? 0 : 1, // 0 设备麦克风, 1 手机麦克风
|
|
47
47
|
isColourExist: true,
|
|
48
48
|
isTempExist: true,
|
|
49
|
-
|
|
49
|
+
deviceGenreMode: dreamMusic ? dreamMusic.id : 0,
|
|
50
|
+
phoneGenreMode: 0,
|
|
51
|
+
genreMode: 0,
|
|
52
|
+
currentMusic: cloneDeep(dreamMusic) as DreamLightMicMusicData,
|
|
53
|
+
musicModeData: [] as DreamLightMicMusicUIState[],
|
|
54
|
+
musicSelect: 0
|
|
50
55
|
})
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (props.dreamMusicDp) {
|
|
59
|
+
getRemoteDreamMusic(deviceId).then(res => {
|
|
60
|
+
if (res.success) {
|
|
61
|
+
state.musicModeData = res.data
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}, [])
|
|
66
|
+
|
|
67
|
+
useUpdateEffect(() => {
|
|
68
|
+
// 设备麦克风
|
|
69
|
+
if (!state.musicEnable) return
|
|
70
|
+
if (props.dreamMusicDp && state.musicType === 0) {
|
|
71
|
+
openMusic()
|
|
72
|
+
} else {
|
|
73
|
+
changeMusic(state.phoneGenreMode)
|
|
74
|
+
}
|
|
75
|
+
}, [state.deviceGenreMode, state.phoneGenreMode, state.musicModeData])
|
|
76
|
+
|
|
77
|
+
useUpdateEffect(() => {
|
|
78
|
+
if (!state.musicEnable) return
|
|
79
|
+
if (state.musicType === 0) MusicManager.close()
|
|
80
|
+
openMusic()
|
|
81
|
+
}, [state.musicType])
|
|
82
|
+
|
|
83
|
+
const updateRemoteDreamMusic = useCallback(() => {
|
|
84
|
+
const newMusicData = cloneDeep(state.musicModeData).map(music => {
|
|
85
|
+
return music.id === state.currentMusic.id ? {
|
|
86
|
+
...state.currentMusic,
|
|
87
|
+
title: music.title
|
|
88
|
+
} : music
|
|
89
|
+
})
|
|
90
|
+
setDreamMusic && setDreamMusic({
|
|
91
|
+
...state.currentMusic,
|
|
92
|
+
power: true
|
|
93
|
+
}, {}).then()
|
|
94
|
+
saveRemoteDreamMusic(deviceId, newMusicData).then()
|
|
95
|
+
}, [state.currentMusic, state.musicModeData])
|
|
65
96
|
|
|
66
|
-
const
|
|
97
|
+
const openMusic = useCallback(async () => {
|
|
98
|
+
if (workMode !== 'music') {
|
|
99
|
+
savePreWorkmode().then()
|
|
100
|
+
}
|
|
101
|
+
const extraDp = {}
|
|
102
|
+
if (!switchLed) extraDp[props.switch_led] = true
|
|
103
|
+
if (workMode !== 'music') extraDp[props.work_mode] = 'music'
|
|
104
|
+
if (props.dreamMusicDp && state.musicType === 0) {
|
|
105
|
+
setDreamMusic && setDreamMusic({
|
|
106
|
+
...state.currentMusic,
|
|
107
|
+
power: true
|
|
108
|
+
}, extraDp).then()
|
|
109
|
+
} else {
|
|
110
|
+
if (workMode !== 'music') await setWorkMode('music')
|
|
111
|
+
if (!switchLed) setSwitchLed(true)
|
|
112
|
+
await MusicManager.open(
|
|
113
|
+
musicDefalutDatasource[state.phoneGenreMode],
|
|
114
|
+
() => { },
|
|
115
|
+
(data) => {
|
|
116
|
+
putMusicDataFn(data, {})
|
|
117
|
+
},
|
|
118
|
+
{ isColourExist: true, isTempExist: true }
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}, [state.musicType, state.phoneGenreMode, props.dreamMusicDp, state.currentMusic, switchLed, workMode])
|
|
122
|
+
|
|
123
|
+
const closeMusic = useCallback(async () => {
|
|
67
124
|
await MusicManager.close()
|
|
68
|
-
await saveSelect('')
|
|
69
|
-
await NativeApi.putJson(deviceId, 'musicSelect', JSON.stringify({ type: '' }));
|
|
70
125
|
const res: any = await NativeApi.getJson(deviceId, 'musicPreWorkMode')
|
|
71
126
|
const workMode = res?.data && JSON.parse(res?.data)?.workMode
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
127
|
+
if (state.musicType === 1) {
|
|
128
|
+
if (props.isMixRGBWLamp) {
|
|
129
|
+
const mixRes: any = await NativeApi.getJson(deviceId, 'musicPreMixLight')
|
|
130
|
+
const getLight = mixRes?.data && JSON.parse(mixRes?.data)?.mixLight
|
|
131
|
+
await setMixScene({
|
|
132
|
+
version: 0,
|
|
133
|
+
id: 0,
|
|
134
|
+
lamps: [
|
|
135
|
+
{
|
|
136
|
+
enable: getLight?.whiteLightSwitch,
|
|
137
|
+
nodes: [{
|
|
138
|
+
brightness: getLight?.brightness,
|
|
139
|
+
changeTime: 0,
|
|
140
|
+
changeType: 0,
|
|
141
|
+
colorTemp: getLight?.colorTempPercent,
|
|
142
|
+
intervalTime: 0,
|
|
143
|
+
hue: 0,
|
|
144
|
+
sat: 0,
|
|
145
|
+
lightness: 0
|
|
146
|
+
}],
|
|
147
|
+
type: 2
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
enable: getLight?.colorLightSwitch,
|
|
151
|
+
nodes: [{
|
|
152
|
+
intervalTime: 0,
|
|
153
|
+
changeTime: 0,
|
|
154
|
+
changeType: 0,
|
|
155
|
+
hue: getLight?.hue,
|
|
156
|
+
sat: getLight?.sat,
|
|
157
|
+
lightness: getLight?.lightness,
|
|
158
|
+
brightness: 0,
|
|
159
|
+
colorTemp: 0,
|
|
160
|
+
}],
|
|
161
|
+
type: 3
|
|
162
|
+
},
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
}
|
|
109
166
|
}
|
|
110
167
|
await setWorkMode(workMode)
|
|
111
|
-
}
|
|
168
|
+
}, [state.musicType])
|
|
112
169
|
|
|
113
170
|
const saveSelect = async (id: string | number) => {
|
|
114
|
-
await NativeApi.putJson(deviceId, 'musicSelect', JSON.stringify({ type: id }));
|
|
171
|
+
await NativeApi.putJson(deviceId, 'musicSelect', JSON.stringify({ type: id, musicType: state.musicType }));
|
|
115
172
|
}
|
|
116
173
|
|
|
117
174
|
const savePreWorkmode = async () => {
|
|
@@ -123,52 +180,52 @@ const MusicPage = () => {
|
|
|
123
180
|
|
|
124
181
|
const getSelect = async () => {
|
|
125
182
|
const res: any = await NativeApi.getJson(deviceId, 'musicSelect')
|
|
126
|
-
const type = JSON.parse(res?.data)?.type
|
|
127
|
-
state.
|
|
128
|
-
state.
|
|
129
|
-
|
|
130
|
-
|
|
183
|
+
const type = res?.data ? JSON.parse(res?.data)?.type : 0
|
|
184
|
+
state.musicType = res?.data ? JSON.parse(res?.data)?.musicType : props.dreamMusicDp ? 0 : 1
|
|
185
|
+
state.phoneGenreMode = musicDefalutDatasource[type !== '' && type]?.id
|
|
186
|
+
state.musicEnable = workMode === 'music' && !!switchLed
|
|
187
|
+
if (type !== '' && state.musicType === 1 && state.musicEnable) {
|
|
188
|
+
openMusic()
|
|
131
189
|
}
|
|
132
190
|
}
|
|
133
191
|
|
|
134
192
|
const changeMusic = async (id: number) => {
|
|
135
|
-
await setWorkMode('music')
|
|
136
|
-
|
|
137
|
-
await saveSelect(
|
|
193
|
+
if (workMode !== 'music') await setWorkMode('music')
|
|
194
|
+
if (!switchLed) setSwitchLed(true)
|
|
195
|
+
await saveSelect(id)
|
|
196
|
+
await MusicManager.close()
|
|
138
197
|
await MusicManager.open(
|
|
139
|
-
musicDefalutDatasource[
|
|
140
|
-
(_: AppleMusicDataType
|
|
141
|
-
|
|
198
|
+
musicDefalutDatasource[id],
|
|
199
|
+
(_: AppleMusicDataType) => {
|
|
200
|
+
},
|
|
201
|
+
(data) => {
|
|
202
|
+
putMusicDataFn(data, {})
|
|
142
203
|
},
|
|
143
|
-
putMusicDataFn,
|
|
144
204
|
{ isColourExist: true, isTempExist: true }
|
|
145
205
|
)
|
|
146
206
|
}
|
|
147
207
|
|
|
148
|
-
const putMusicDataFn = (data: any) => {
|
|
149
|
-
setMusicData(data).then()
|
|
208
|
+
const putMusicDataFn = (data: any, extraDp = {}) => {
|
|
209
|
+
setMusicData(data, extraDp).then()
|
|
150
210
|
}
|
|
151
211
|
|
|
152
|
-
useUpdateEffect(() => {
|
|
153
|
-
if (workMode !== 'music' && state.musicEnable) {
|
|
154
|
-
savePreWorkmode().then()
|
|
155
|
-
}
|
|
156
|
-
state.musicEnable ? openMusic(0) : closeMusic()
|
|
157
|
-
}, [state.musicEnable])
|
|
158
|
-
|
|
159
212
|
useEffect(() => {
|
|
160
213
|
getSelect().then()
|
|
161
214
|
}, [])
|
|
162
215
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
216
|
+
const getSelectModeData = useCallback((): [string | undefined, any[]] => {
|
|
217
|
+
const genreModeData = props.dreamMusicDp && state.musicType === 0 ? state.musicModeData : musicDefalutDatasource
|
|
218
|
+
const genreMode = props.dreamMusicDp && state.musicType === 0 ? state.deviceGenreMode : state.phoneGenreMode
|
|
219
|
+
const title = genreModeData.find(mode => mode.id === genreMode)?.title
|
|
220
|
+
const selectModeData = genreModeData.map(music => {
|
|
221
|
+
return {
|
|
222
|
+
text: music.title,
|
|
223
|
+
selected: music.id === genreMode,
|
|
224
|
+
value: music.id,
|
|
225
|
+
}
|
|
166
226
|
})
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const tabRadios = Array.from(Array(2), (v, k) => k + 1).map((v) => {
|
|
170
|
-
return { key: `${v}`, title: `Tab${v}` };
|
|
171
|
-
});
|
|
227
|
+
return [title, selectModeData]
|
|
228
|
+
}, [state.deviceGenreMode, state.phoneGenreMode, state.musicModeData, state.musicType, props.dreamMusicDp])
|
|
172
229
|
|
|
173
230
|
return (
|
|
174
231
|
<Page
|
|
@@ -181,7 +238,7 @@ const MusicPage = () => {
|
|
|
181
238
|
value={state.musicEnable}
|
|
182
239
|
thumbStyle={{ elevation: 0 }}
|
|
183
240
|
onValueChange={async v => {
|
|
184
|
-
if (!switchLed) {
|
|
241
|
+
if (!switchLed && v) {
|
|
185
242
|
Dialog.confirm({
|
|
186
243
|
title: Strings.getLang('feature_activate_dialog_text'),
|
|
187
244
|
subTitle: Strings.getLang('music_reactivate_dialog_text'),
|
|
@@ -189,23 +246,33 @@ const MusicPage = () => {
|
|
|
189
246
|
confirmText: Strings.getLang('cancel_dialog_delete_item_sleepschedule_answer_yes_text'),
|
|
190
247
|
onConfirm: async (_, { close }) => {
|
|
191
248
|
close()
|
|
192
|
-
await setSwitchLed(true)
|
|
193
249
|
state.musicEnable = v
|
|
250
|
+
await openMusic()
|
|
194
251
|
},
|
|
195
252
|
})
|
|
196
253
|
} else {
|
|
197
254
|
state.musicEnable = v
|
|
255
|
+
if (v) {
|
|
256
|
+
await openMusic()
|
|
257
|
+
} else {
|
|
258
|
+
await closeMusic()
|
|
259
|
+
}
|
|
198
260
|
}
|
|
199
261
|
}} />
|
|
200
|
-
<TabBar
|
|
262
|
+
{props.dreamMusicDp && <TabBar
|
|
201
263
|
type='radio'
|
|
202
|
-
tabs={
|
|
203
|
-
style={{ borderRadius: cx(8), backgroundColor: '#f6f6f6' }}
|
|
264
|
+
tabs={musicTabs}
|
|
265
|
+
style={{ borderRadius: cx(8), backgroundColor: '#f6f6f6', height: cx(36) }}
|
|
204
266
|
tabTextStyle={{ color: '#000' }}
|
|
205
267
|
tabActiveTextStyle={{ color: '#000', fontWeight: 'bold' }}
|
|
206
|
-
|
|
268
|
+
activeKey={state.musicType}
|
|
269
|
+
onChange={async (v) => {
|
|
270
|
+
state.musicType = Number(v)
|
|
271
|
+
await saveSelect(state.phoneGenreMode)
|
|
272
|
+
}}
|
|
273
|
+
/>}
|
|
207
274
|
<Spacer />
|
|
208
|
-
<Text style={styles.tiptext}>{Strings.getLang(state.musicType ===
|
|
275
|
+
<Text style={styles.tiptext}>{Strings.getLang(state.musicType === 0 ? 'devicemusic_devicemic_description_text' : 'devicemusic_description_text')}</Text>
|
|
209
276
|
<View style={{ alignItems: 'center', marginVertical: cx(38) }}>
|
|
210
277
|
<Image
|
|
211
278
|
style={{ width: cx(200), height: cx(204) }}
|
|
@@ -216,27 +283,39 @@ const MusicPage = () => {
|
|
|
216
283
|
{
|
|
217
284
|
state.musicEnable &&
|
|
218
285
|
<>
|
|
219
|
-
{props.dreamMusicDp &&
|
|
286
|
+
{props.dreamMusicDp && state.musicType === 0 &&
|
|
220
287
|
<LdvSlider
|
|
221
288
|
title={Strings.getLang('devicemusic_switch_tab_device_sensitivity')}
|
|
222
|
-
value={state.sensitivity}
|
|
289
|
+
value={state.currentMusic?.sensitivity || 50}
|
|
223
290
|
min={1}
|
|
224
291
|
max={100}
|
|
225
292
|
onValueChange={() => { }}
|
|
226
|
-
onSlidingComplete={() => {
|
|
293
|
+
onSlidingComplete={(v: number) => {
|
|
294
|
+
if (state.currentMusic) {
|
|
295
|
+
state.currentMusic.sensitivity = v
|
|
296
|
+
updateRemoteDreamMusic()
|
|
297
|
+
}
|
|
298
|
+
}}
|
|
227
299
|
subTitleStr={''} />
|
|
228
300
|
}
|
|
229
|
-
<
|
|
230
|
-
|
|
301
|
+
<TextFieldStyleButton
|
|
302
|
+
text={getSelectModeData()[0] || Strings.getLang('devicemusic_music_text')}
|
|
231
303
|
placeholder={Strings.getLang('devicemusic_subheadline_text')}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
304
|
+
onPress={() => {
|
|
305
|
+
const paramsSelect: SelectPageParams<number> = {
|
|
306
|
+
title: Strings.getLang('devicemusic_subheadline_text'),
|
|
307
|
+
data: getSelectModeData()[1],
|
|
308
|
+
onSelect: selectPageData => {
|
|
309
|
+
if (props.dreamMusicDp && state.musicType === 0) {
|
|
310
|
+
state.deviceGenreMode = selectPageData.value
|
|
311
|
+
state.currentMusic = state.musicModeData.find(music => music.id === selectPageData.value) as DreamLightMicMusicData
|
|
312
|
+
} else {
|
|
313
|
+
state.phoneGenreMode = selectPageData.value
|
|
314
|
+
}
|
|
315
|
+
},
|
|
238
316
|
}
|
|
239
|
-
|
|
317
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_select_page, paramsSelect)
|
|
318
|
+
}}
|
|
240
319
|
/>
|
|
241
320
|
</>
|
|
242
321
|
}
|
|
@@ -1,106 +1,192 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
|
-
import { useUpdateEffect} from "ahooks"
|
|
3
|
-
import { useDp } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
2
|
+
import { useUpdateEffect } from "ahooks"
|
|
3
|
+
import { useDp, useDps } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
4
4
|
import { ColorParser } from '@ledvance/base/src/utils/ColorParser'
|
|
5
|
-
import { dp2Obj, obj2Dp} from '@ledvance/ui-biz-bundle/src/modules/timeSchedule/mix/MixLightActions'
|
|
5
|
+
import { dp2Obj, obj2Dp } from '@ledvance/ui-biz-bundle/src/modules/timeSchedule/mix/MixLightActions'
|
|
6
6
|
import { MixLightBean } from '@ledvance/ui-biz-bundle/src/modules/timeSchedule/mix/MixLightBean'
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { Formatter } from '@tuya/tuya-panel-lamp-sdk'
|
|
8
|
+
import { DreamMusicDataType, dreamMusicData } from './MusicDataBean'
|
|
9
|
+
import { Result } from '@ledvance/base/src/models/modules/Result'
|
|
10
|
+
import { NativeApi } from '@ledvance/base/src/api/native'
|
|
11
|
+
const DreamMusicFormatter = new Formatter.DreamLightMicMusicFormatter()
|
|
12
|
+
export const useEnable = (dpKey: string) => {
|
|
13
|
+
return useDp(dpKey)
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
export const useWorkMode = (dpKey:string) =>{
|
|
12
|
-
|
|
16
|
+
export const useWorkMode = (dpKey: string) => {
|
|
17
|
+
return useDp(dpKey)
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
export const useMixRgbcw = (mixRgbcwDp:string, mixSwitchDp:string) =>{
|
|
20
|
+
export const useMixRgbcw = (mixRgbcwDp: string, mixSwitchDp: string) => {
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const [mixRgbcw, setMixRgbcw]: [string, (v: any) => void] = useDp(mixRgbcwDp)
|
|
23
|
+
const [mixLightState, setMixLightState] = useState(mixRgbcwDp ? dp2Obj(mixRgbcw) : undefined)
|
|
24
|
+
useUpdateEffect(() => {
|
|
25
|
+
const newMixLIghtState = mixRgbcwDp ? dp2Obj(mixRgbcw) : undefined
|
|
26
|
+
setMixLightState(newMixLIghtState)
|
|
27
|
+
}, [mixRgbcw])
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
const setMixRgbcwDp = async (mixLightBean: MixLightBean) => {
|
|
30
|
+
const dpValue = obj2Dp(mixLightBean)
|
|
31
|
+
const enable = mixLightBean.whiteLightSwitch === mixLightBean.colorLightSwitch ? mixLightBean.whiteLightSwitch : undefined
|
|
32
|
+
const dps: { [p: string]: any } = {
|
|
33
|
+
[mixRgbcwDp]: dpValue
|
|
34
|
+
}
|
|
35
|
+
if (enable !== undefined) {
|
|
36
|
+
dps[mixSwitchDp] = enable
|
|
37
|
+
}
|
|
38
|
+
const controlResult: any = await setMixRgbcw(dps)
|
|
39
|
+
return {
|
|
40
|
+
result: { success: controlResult.result },
|
|
41
|
+
dps: { [mixRgbcwDp]: dpValue },
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return [mixLightState, setMixRgbcwDp]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const useMixScene = (mixSceneDp: string, mixWorkMode: string): any[] => {
|
|
48
|
+
const [mixScene, setMixScene]: [string, (v: any) => void] = useDp(mixSceneDp)
|
|
49
|
+
const [mixSceneState, setMixSceneState] = useState(mixSceneDp ? mixSceneDp2Obj(mixScene) : undefined)
|
|
50
|
+
useUpdateEffect(() => {
|
|
51
|
+
const newMixLIghtState = mixSceneDp ? mixSceneDp2Obj(mixScene) : undefined
|
|
52
|
+
setMixSceneState(newMixLIghtState)
|
|
53
|
+
}, [mixScene])
|
|
54
|
+
|
|
55
|
+
const setMixRgbcwDp = async (mixScene: MixSceneInfo) => {
|
|
56
|
+
const dpValue = mixSceneObj2Dp(mixScene)
|
|
57
|
+
const controlResult: any = await setMixScene(dpValue)
|
|
58
|
+
return {
|
|
59
|
+
result: { success: controlResult.result },
|
|
60
|
+
dps: { [mixWorkMode]: 'scene', [mixSceneDp]: dpValue },
|
|
38
61
|
}
|
|
39
|
-
|
|
62
|
+
}
|
|
63
|
+
return [mixSceneState, setMixRgbcwDp]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const useMusicData = (dpKey: string): any[] => {
|
|
67
|
+
const [dps, setDps] = useDps()
|
|
68
|
+
const musicData = dps[dpKey]
|
|
69
|
+
const setMusicDp = async (data, extraDp = {}) => {
|
|
70
|
+
const musicDpData = ColorParser.encodeControlData(
|
|
71
|
+
data.mode,
|
|
72
|
+
data.hue,
|
|
73
|
+
data.saturation,
|
|
74
|
+
data.value,
|
|
75
|
+
data.brightness,
|
|
76
|
+
data.temperature
|
|
77
|
+
);
|
|
78
|
+
const sendData = {
|
|
79
|
+
[dpKey]: musicDpData,
|
|
80
|
+
...extraDp
|
|
81
|
+
}
|
|
82
|
+
const controlResult: any = await setDps(sendData)
|
|
83
|
+
return {
|
|
84
|
+
result: { success: controlResult.result },
|
|
85
|
+
dps: { [dpKey]: musicDpData },
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [musicData, setMusicDp]
|
|
89
|
+
}
|
|
90
|
+
interface DreamLightMicMusicColor {
|
|
91
|
+
hue: number;
|
|
92
|
+
saturation: number;
|
|
93
|
+
}
|
|
94
|
+
export interface DreamLightMicMusicData {
|
|
95
|
+
v: number;
|
|
96
|
+
power: boolean;
|
|
97
|
+
id: number;
|
|
98
|
+
isLight: number;
|
|
99
|
+
mode: number;
|
|
100
|
+
speed: number;
|
|
101
|
+
sensitivity: number;
|
|
102
|
+
a: number;
|
|
103
|
+
b: number;
|
|
104
|
+
c: number;
|
|
105
|
+
brightness: number;
|
|
106
|
+
colors: DreamLightMicMusicColor[];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface DreamLightMicMusicUIState extends DreamLightMicMusicData {
|
|
110
|
+
title: string
|
|
40
111
|
}
|
|
41
112
|
|
|
42
|
-
export const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
113
|
+
export const useDreamMusic = (dpKey: string): [DreamLightMicMusicData | "", (music: DreamLightMicMusicData, extraDp: Record<any,any>) => Promise<Result<any>>] => {
|
|
114
|
+
const [dps, setDps]: [any, (v: any) => Promise<Result<any>>] = useDps()
|
|
115
|
+
const dreamMusicDp: string = dps[dpKey]
|
|
116
|
+
const dreamMusic = dreamMusicDp && DreamMusicFormatter.parse(dreamMusicDp)
|
|
117
|
+
const setDreamMusicFn = (music: DreamLightMicMusicData, extraDp: Record<any,any> = {}) => {
|
|
118
|
+
const musicHex = DreamMusicFormatter.format(music)
|
|
119
|
+
return setDps({
|
|
120
|
+
[dpKey]: musicHex,
|
|
121
|
+
...extraDp
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
return [dreamMusic, setDreamMusicFn]
|
|
125
|
+
}
|
|
49
126
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
127
|
+
export const getRemoteDreamMusic = async (devId: string) => {
|
|
128
|
+
const res = await NativeApi.getJson(devId, 'dreamlightmic_music_data')
|
|
129
|
+
if (res.success && res.data) {
|
|
130
|
+
return {
|
|
131
|
+
success: true,
|
|
132
|
+
data: JSON.parse(res.data)?.map(item => remoteDreamMusicUIState(item)),
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
if (res.msg?.includes('资源未找到')) {
|
|
136
|
+
const res = await NativeApi.putJson(devId, 'dreamlightmic_music_data', JSON.stringify(dreamMusicData))
|
|
137
|
+
if (res.success) {
|
|
53
138
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
139
|
+
success: true,
|
|
140
|
+
data: dreamMusicData.map(item => remoteDreamMusicUIState(item))
|
|
56
141
|
}
|
|
142
|
+
}
|
|
143
|
+
return { success: false }
|
|
57
144
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
dps: { [dpKey]: musicDpData},
|
|
76
|
-
}
|
|
145
|
+
return { success: false }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const remoteDreamMusicUIState = (remoteMusic: DreamMusicDataType) => {
|
|
150
|
+
const musicInfo = DreamMusicFormatter.parse(remoteMusic.value)
|
|
151
|
+
return {
|
|
152
|
+
...musicInfo,
|
|
153
|
+
title: remoteMusic.title
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function saveRemoteDreamMusic(devId: string, musics: DreamLightMicMusicData[]) {
|
|
158
|
+
const newMusic = musics.map(music => {
|
|
159
|
+
return {
|
|
160
|
+
...music,
|
|
161
|
+
value: DreamMusicFormatter.format(music)
|
|
77
162
|
}
|
|
78
|
-
|
|
163
|
+
})
|
|
164
|
+
return NativeApi.putJson(devId, 'dreamlightmic_music_data', JSON.stringify(newMusic))
|
|
79
165
|
}
|
|
80
166
|
|
|
81
167
|
|
|
82
168
|
export interface MixSceneInfo {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
169
|
+
version: number
|
|
170
|
+
id: any
|
|
171
|
+
lamps: MixSceneLampInfo[]
|
|
86
172
|
}
|
|
87
173
|
|
|
88
174
|
export interface MixSceneLampInfo {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
175
|
+
enable: boolean
|
|
176
|
+
// 1:W 只有亮度,2:CW 亮度+色温,3:RGB HSV,4:RGBC HSV+色温,5:RGBCW HSV+色温+亮度
|
|
177
|
+
type: number
|
|
178
|
+
nodes: MixSceneNodeInfo[]
|
|
93
179
|
}
|
|
94
180
|
|
|
95
181
|
export interface MixSceneNodeInfo {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
182
|
+
intervalTime: number
|
|
183
|
+
changeTime: number
|
|
184
|
+
changeType: number
|
|
185
|
+
hue: number
|
|
186
|
+
sat: number
|
|
187
|
+
lightness: number
|
|
188
|
+
brightness: number
|
|
189
|
+
colorTemp: number
|
|
104
190
|
}
|
|
105
191
|
|
|
106
192
|
/**
|
|
@@ -108,69 +194,69 @@ export interface MixSceneNodeInfo {
|
|
|
108
194
|
* @returns MixSceneInfo
|
|
109
195
|
*/
|
|
110
196
|
export function mixSceneDp2Obj(dp: string): MixSceneInfo | undefined {
|
|
111
|
-
|
|
112
|
-
|
|
197
|
+
if (!(!!dp)) {
|
|
198
|
+
return undefined
|
|
199
|
+
}
|
|
200
|
+
const result = {} as MixSceneInfo
|
|
201
|
+
result.version = parseInt(dp.slice(0, 2), 16)
|
|
202
|
+
result.id = parseInt(dp.slice(2, 4), 16)
|
|
203
|
+
result.lamps = []
|
|
204
|
+
let lampsHex = dp.slice(4)
|
|
205
|
+
while (lampsHex.length != 0) {
|
|
206
|
+
const lamp = { nodes: [] as MixSceneNodeInfo[] } as MixSceneLampInfo
|
|
207
|
+
lamp.enable = parseInt(lampsHex.slice(0, 2), 16) === 1
|
|
208
|
+
lampsHex = lampsHex.slice(2)
|
|
209
|
+
const nodeCount = parseInt(lampsHex.slice(0, 2), 16)
|
|
210
|
+
lampsHex = lampsHex.slice(2)
|
|
211
|
+
if (nodeCount === 0) {
|
|
212
|
+
result.lamps.push(lamp)
|
|
213
|
+
continue
|
|
113
214
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
node.sat = parseInt(lampsHex.slice(4, 8), 16) / 10
|
|
156
|
-
node.lightness = parseInt(lampsHex.slice(8, 12), 16) / 10
|
|
157
|
-
node.colorTemp = parseInt(lampsHex.slice(12, 16), 16) / 10
|
|
158
|
-
lampsHex = lampsHex.slice(16)
|
|
159
|
-
break
|
|
160
|
-
case 5:
|
|
161
|
-
node.hue = parseInt(lampsHex.slice(0, 4), 16)
|
|
162
|
-
node.sat = parseInt(lampsHex.slice(4, 8), 16) / 10
|
|
163
|
-
node.lightness = parseInt(lampsHex.slice(8, 12), 16) / 10
|
|
164
|
-
node.brightness = parseInt(lampsHex.slice(12, 16), 16) / 10
|
|
165
|
-
node.colorTemp = parseInt(lampsHex.slice(16, 20), 16) / 10
|
|
166
|
-
lampsHex = lampsHex.slice(20)
|
|
167
|
-
break
|
|
168
|
-
}
|
|
169
|
-
lamp.nodes.push(node)
|
|
170
|
-
}
|
|
171
|
-
result.lamps.push(lamp)
|
|
215
|
+
lamp.type = parseInt(lampsHex.slice(0, 2), 16)
|
|
216
|
+
lampsHex = lampsHex.slice(2)
|
|
217
|
+
for (let i = 0; i < nodeCount; i++) {
|
|
218
|
+
const node = {} as MixSceneNodeInfo
|
|
219
|
+
node.intervalTime = parseInt(lampsHex.slice(0, 2), 16)
|
|
220
|
+
node.changeTime = parseInt(lampsHex.slice(2, 4), 16)
|
|
221
|
+
node.changeType = parseInt(lampsHex.slice(4, 6), 16)
|
|
222
|
+
lampsHex = lampsHex.slice(6)
|
|
223
|
+
switch (lamp.type) {
|
|
224
|
+
case 1:
|
|
225
|
+
node.brightness = parseInt(lampsHex.slice(0, 4), 16) / 10
|
|
226
|
+
lampsHex = lampsHex.slice(4)
|
|
227
|
+
break
|
|
228
|
+
case 2:
|
|
229
|
+
node.brightness = parseInt(lampsHex.slice(0, 4), 16) / 10
|
|
230
|
+
node.colorTemp = parseInt(lampsHex.slice(4, 8), 16) / 10
|
|
231
|
+
lampsHex = lampsHex.slice(8)
|
|
232
|
+
break
|
|
233
|
+
case 3:
|
|
234
|
+
node.hue = parseInt(lampsHex.slice(0, 4), 16)
|
|
235
|
+
node.sat = parseInt(lampsHex.slice(4, 8), 16) / 10
|
|
236
|
+
node.lightness = parseInt(lampsHex.slice(8, 12), 16) / 10
|
|
237
|
+
lampsHex = lampsHex.slice(12)
|
|
238
|
+
break
|
|
239
|
+
case 4:
|
|
240
|
+
node.hue = parseInt(lampsHex.slice(0, 4), 16)
|
|
241
|
+
node.sat = parseInt(lampsHex.slice(4, 8), 16) / 10
|
|
242
|
+
node.lightness = parseInt(lampsHex.slice(8, 12), 16) / 10
|
|
243
|
+
node.colorTemp = parseInt(lampsHex.slice(12, 16), 16) / 10
|
|
244
|
+
lampsHex = lampsHex.slice(16)
|
|
245
|
+
break
|
|
246
|
+
case 5:
|
|
247
|
+
node.hue = parseInt(lampsHex.slice(0, 4), 16)
|
|
248
|
+
node.sat = parseInt(lampsHex.slice(4, 8), 16) / 10
|
|
249
|
+
node.lightness = parseInt(lampsHex.slice(8, 12), 16) / 10
|
|
250
|
+
node.brightness = parseInt(lampsHex.slice(12, 16), 16) / 10
|
|
251
|
+
node.colorTemp = parseInt(lampsHex.slice(16, 20), 16) / 10
|
|
252
|
+
lampsHex = lampsHex.slice(20)
|
|
253
|
+
break
|
|
254
|
+
}
|
|
255
|
+
lamp.nodes.push(node)
|
|
172
256
|
}
|
|
173
|
-
|
|
257
|
+
result.lamps.push(lamp)
|
|
258
|
+
}
|
|
259
|
+
return result
|
|
174
260
|
}
|
|
175
261
|
|
|
176
262
|
/**
|
|
@@ -178,52 +264,52 @@ export function mixSceneDp2Obj(dp: string): MixSceneInfo | undefined {
|
|
|
178
264
|
* @param obj
|
|
179
265
|
*/
|
|
180
266
|
export function mixSceneObj2Dp(obj: MixSceneInfo) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}).join('')
|
|
225
|
-
return lampHex
|
|
267
|
+
const versionHex = obj.version.toString(16).padStart(2, '0')
|
|
268
|
+
const sceneNoHex = obj.id.toString(16).padStart(2, '0')
|
|
269
|
+
const lampsHex = obj.lamps.map(lamp => {
|
|
270
|
+
let lampHex = lamp.enable ? '01' : '00'
|
|
271
|
+
const nodes = lamp.nodes || []
|
|
272
|
+
lampHex += nodes.length.toString(16).padStart(2, '0')
|
|
273
|
+
if (nodes.length === 0 || !lamp.enable) {
|
|
274
|
+
return lampHex
|
|
275
|
+
}
|
|
276
|
+
lampHex += lamp.type.toString(16).padStart(2, '0')
|
|
277
|
+
lampHex += nodes.map(node => {
|
|
278
|
+
let nodeHex = ''
|
|
279
|
+
nodeHex += node.intervalTime.toString(16).padStart(2, '0')
|
|
280
|
+
nodeHex += node.changeTime.toString(16).padStart(2, '0')
|
|
281
|
+
nodeHex += node.changeType.toString(16).padStart(2, '0')
|
|
282
|
+
switch (lamp.type) { // 1:W 只有亮度,2:CW 亮度+色温,3:RGB HSV,4:RGBC HSV+色温,5:RGBCW HSV+色温+亮度
|
|
283
|
+
case 1:
|
|
284
|
+
nodeHex += (node.brightness * 10).toString(16).padStart(4, '0')
|
|
285
|
+
break
|
|
286
|
+
case 2:
|
|
287
|
+
nodeHex += (node.brightness * 10).toString(16).padStart(4, '0')
|
|
288
|
+
nodeHex += (node.colorTemp * 10).toString(16).padStart(4, '0')
|
|
289
|
+
break
|
|
290
|
+
case 3:
|
|
291
|
+
nodeHex += node.hue.toString(16).padStart(4, '0')
|
|
292
|
+
nodeHex += (node.sat * 10).toString(16).padStart(4, '0')
|
|
293
|
+
nodeHex += (node.lightness * 10).toString(16).padStart(4, '0')
|
|
294
|
+
break
|
|
295
|
+
case 4:
|
|
296
|
+
nodeHex += node.hue.toString(16).padStart(4, '0')
|
|
297
|
+
nodeHex += (node.sat * 10).toString(16).padStart(4, '0')
|
|
298
|
+
nodeHex += (node.lightness * 10).toString(16).padStart(4, '0')
|
|
299
|
+
nodeHex += (node.colorTemp * 10).toString(16).padStart(4, '0')
|
|
300
|
+
break
|
|
301
|
+
case 5:
|
|
302
|
+
nodeHex += node.hue.toString(16).padStart(4, '0')
|
|
303
|
+
nodeHex += (node.sat * 10).toString(16).padStart(4, '0')
|
|
304
|
+
nodeHex += (node.lightness * 10).toString(16).padStart(4, '0')
|
|
305
|
+
nodeHex += (node.brightness * 10).toString(16).padStart(4, '0')
|
|
306
|
+
nodeHex += (node.colorTemp * 10).toString(16).padStart(4, '0')
|
|
307
|
+
break
|
|
308
|
+
}
|
|
309
|
+
return nodeHex
|
|
226
310
|
}).join('')
|
|
227
|
-
return
|
|
311
|
+
return lampHex
|
|
312
|
+
}).join('')
|
|
313
|
+
return versionHex + sceneNoHex + lampsHex
|
|
228
314
|
}
|
|
229
315
|
|