@ledvance/base 1.1.91 → 1.1.93

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/base",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.1.91",
7
+ "version": "1.1.93",
8
8
  "scripts": {},
9
9
  "dependencies": {
10
10
  "@reduxjs/toolkit": "^1.8.6",
package/src/api/native.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {NativeModules, Platform} from 'react-native'
2
2
  import {NativeResult, Result} from '../models/modules/Result'
3
-
3
+ import { TYSdk } from 'tuya-panel-kit'
4
4
  interface LDVDevicePanelManager {
5
5
  back: () => void
6
6
  control: (params: any, callback: (result: any) => void) => void
@@ -363,3 +363,25 @@ export const getMicrophoneAccess: () => Promise<boolean> = () => {
363
363
  })
364
364
  })
365
365
  }
366
+
367
+ export const getTuyaCloudData = (devId: string): Promise<Record<string, any>> => {
368
+ return new Promise((resolve, reject) => {
369
+ TYSdk.native.apiRNRequest(
370
+ {
371
+ a: 's.m.dev.property.get',
372
+ postData: {
373
+ devId: devId,
374
+ bizType: 0,
375
+ },
376
+ v: '2.0'
377
+ },
378
+ (d: string) => {
379
+ const data = typeof d === 'string' ? JSON.parse(d) : d;
380
+ resolve(data);
381
+ },
382
+ (err: string) => {
383
+ reject(err);
384
+ }
385
+ )
386
+ })
387
+ }
@@ -53,6 +53,9 @@ interface DrawToolViewProps extends PropsWithChildren<ViewProps> {
53
53
  hideLedNum?: boolean
54
54
  ledNum?: number
55
55
  setLedNum: (num: number) => void
56
+ hidLampAdjustView?: boolean
57
+ hideDisableLight?: boolean
58
+ hideColorize?: boolean
56
59
  }
57
60
 
58
61
  const DrawToolView = (props: DrawToolViewProps) => {
@@ -88,7 +91,7 @@ const DrawToolView = (props: DrawToolViewProps) => {
88
91
  }
89
92
  return '#ffffff'
90
93
  }, [props.isColorMode, props.h, props.s])
91
-
94
+
92
95
  return (
93
96
  <Card style={{ marginHorizontal: cx(24) }}>
94
97
  <LdvSwitch
@@ -97,109 +100,117 @@ const DrawToolView = (props: DrawToolViewProps) => {
97
100
  colorAlpha={1}
98
101
  enable={!!props.switchLed}
99
102
  showSwitch={!!props.showEnable}
100
- setEnable={props.setEnable}/>
103
+ setEnable={props.setEnable} />
101
104
  {(props.showEnable && props.switchLed || !props.showEnable) && <>
102
- <View style={styles.container}>
103
- <View style={styles.adjustButtons}>
104
- <TouchableOpacity
105
- onPress={() => {
106
- props.setAdjustType(1)
107
- }}>
108
- <Image
109
- style={[styles.adjustButton, { tintColor: props.adjustType === 1 ? '#f60' : '#666' }]}
110
- source={res.ic_paint_bucket}/>
111
- </TouchableOpacity>
112
- <TouchableOpacity
113
- onPress={() => {
114
- props.setAdjustType(3)
115
- }}>
116
- <Image
117
- style={[styles.adjustButton, { tintColor: props.adjustType === 3 ? '#f60' : '#666' }]}
118
- source={res.ic_disabled_light}/>
119
- </TouchableOpacity>
120
- <TouchableOpacity
121
- onPress={() => {
122
- props.setAdjustType(2)
123
- }}>
124
- <Image
125
- style={[styles.adjustButton, { tintColor: props.adjustType === 2 ? '#f60' : '#666' }]}
126
- source={res.ic_colorize}/>
127
- </TouchableOpacity>
128
- {!props.hideLedNum && <TouchableOpacity
129
- onPress={() => {
130
- state.visible = true
131
- }}
132
- style={[styles.adjustButton, {
133
- alignItems: 'center',
134
- justifyContent: 'center',
135
- backgroundColor: '#f60',
136
- borderRadius: cx(5),
137
- }]}>
138
- <Text style={{ color: '#fff', fontSize: cx(18), fontWeight: 'bold' }}>{props.ledNum || 5}</Text>
139
- </TouchableOpacity>}
140
- </View>
141
- <StripLightView
142
- style={{ height, flex: 1 }}
143
- nodes={props.nodes}
144
- fixCount={props.fixCount || 5}
145
- stripStyle={props.stripStyle || 'WITH_BEAD'}
146
- touchingMode={props.touchingMode || 'TOUCH'}
147
- width={state.width}
148
- onLayout={onLayout}/>
105
+ <View style={styles.container}>
106
+ <View style={styles.adjustButtons}>
107
+ <TouchableOpacity
108
+ onPress={() => {
109
+ props.setAdjustType(1)
110
+ }}>
111
+ <Image
112
+ style={[styles.adjustButton, { tintColor: props.adjustType === 1 ? '#f60' : '#666' }]}
113
+ source={res.ic_paint_bucket} />
114
+ </TouchableOpacity>
115
+ {!props.hideDisableLight && <TouchableOpacity
116
+ onPress={() => {
117
+ props.setAdjustType(3)
118
+ }}>
119
+ <Image
120
+ style={[styles.adjustButton, { tintColor: props.adjustType === 3 ? '#f60' : '#666' }]}
121
+ source={res.ic_disabled_light} />
122
+ </TouchableOpacity>}
123
+ {!props.hideColorize && <TouchableOpacity
124
+ onPress={() => {
125
+ props.setAdjustType(2)
126
+ }}>
127
+ <Image
128
+ style={[styles.adjustButton, { tintColor: props.adjustType === 2 ? '#f60' : '#666' }]}
129
+ source={res.ic_colorize} />
130
+ </TouchableOpacity>}
131
+ {!props.hideLedNum && <TouchableOpacity
132
+ onPress={() => {
133
+ state.visible = true
134
+ }}
135
+ style={[styles.adjustButton, {
136
+ alignItems: 'center',
137
+ justifyContent: 'center',
138
+ backgroundColor: '#f60',
139
+ borderRadius: cx(5),
140
+ }]}>
141
+ <Text style={{ color: '#fff', fontSize: cx(18), fontWeight: 'bold' }}>{props.ledNum || 5}</Text>
142
+ </TouchableOpacity>}
149
143
  </View>
150
- <LdvSwitch
151
- title={I18n.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
152
- color={getBlockColor()}
153
- colorAlpha={1}
154
- enable={false}
155
- showSwitch={false}
156
- setEnable={() => {
157
- }}/>
158
- <LampAdjustView
159
- isSupportColor={!!props.isSupportColor}
160
- isSupportTemperature={!!props.isSupportTemperature}
161
- isSupportBrightness={!!props.isSupportBrightness}
162
- isColorMode={!!props.isColorMode}
163
- reserveSV={true}
164
- setIsColorMode={props.setIsColorMode}
165
- h={props.h} s={props.s} v={props.v}
166
- onHSVChange={props.onHSVChange}
167
- onHSVChangeComplete={props.onHSVChangeComplete}
168
- colorTemp={props.temperature}
169
- brightness={props.brightness}
170
- onCCTChange={props.onCCTChange}
171
- onCCTChangeComplete={props.onCCTChangeComplete}
172
- onBrightnessChange={props.onBrightnessChange}
173
- onBrightnessChangeComplete={props.onBrightnessChangeComplete}/>
144
+ <StripLightView
145
+ style={{ height, flex: 1 }}
146
+ nodes={props.nodes}
147
+ fixCount={props.fixCount || 5}
148
+ stripStyle={props.stripStyle || 'WITH_BEAD'}
149
+ touchingMode={props.touchingMode || 'TOUCH'}
150
+ width={state.width}
151
+ onLayout={onLayout} />
152
+ </View>
153
+ <LdvSwitch
154
+ title={I18n.getLang('add_new_dynamic_mood_lights_field_headline2_text')}
155
+ color={getBlockColor()}
156
+ colorAlpha={1}
157
+ enable={false}
158
+ showSwitch={false}
159
+ setEnable={() => {
160
+ }} />
161
+ {!props.hidLampAdjustView && <LampAdjustView
162
+ isSupportColor={!!props.isSupportColor}
163
+ isSupportTemperature={!!props.isSupportTemperature}
164
+ isSupportBrightness={!!props.isSupportBrightness}
165
+ isColorMode={!!props.isColorMode}
166
+ reserveSV={true}
167
+ setIsColorMode={props.setIsColorMode}
168
+ h={props.h} s={props.s} v={props.v}
169
+ onHSVChange={props.onHSVChange}
170
+ onHSVChangeComplete={props.onHSVChangeComplete}
171
+ colorTemp={props.temperature}
172
+ brightness={props.brightness}
173
+ onCCTChange={props.onCCTChange}
174
+ onCCTChangeComplete={props.onCCTChangeComplete}
175
+ onBrightnessChange={props.onBrightnessChange}
176
+ onBrightnessChangeComplete={props.onBrightnessChangeComplete} />}
174
177
  {!props.hideLedNum && <Modal
175
- visible={state.visible}
176
- onMaskPress={() => {
177
- state.visible = false
178
- }}
179
- alignContainer="center"
180
- style={{ width: '100%', height: cx(100) }}>
181
- <Card style={{ marginHorizontal: cx(24), marginTop: cx(50), alignItems: 'center' }}>
182
- <Spacer/>
183
- <Stepper
184
- min={5}
185
- max={48}
186
- stepValue={1}
187
- editable={true}
188
- value={state.ledNum}
189
- onValueChange={(v) => {
190
- state.ledNum = v
191
- }}/>
192
- <Spacer/>
193
- <DeleteButton
194
- text={I18n.getLang('auto_scan_system_wifi_confirm')}
195
- style={{ width: cx(150), height: cx(40), backgroundColor: '#f60' }}
196
- textStyle={{ fontSize: cx(14) }}
197
- onPress={() => {
198
- props.setLedNum(state.ledNum)
199
- state.visible = false
200
- }}/>
201
- <Spacer/>
202
- </Card>
178
+ visible={state.visible}
179
+ onMaskPress={() => {
180
+ state.visible = false
181
+ }}
182
+ alignContainer="center"
183
+ style={{ width: '100%', height: cx(150) }}>
184
+ <Card
185
+ containerStyle={{ marginHorizontal: cx(16), alignItems: 'center' }}
186
+ style={{ marginHorizontal: cx(16), marginTop: cx(50) }}>
187
+ <Spacer />
188
+ <Text style={{ color: '#000', fontSize: cx(14) }}>Please set the number of bulbs according to the actual number of bulbs in the lamp string</Text>
189
+ <Spacer height={cx(10)}/>
190
+ <Text style={{color: '#999'}}>Supports a maximum of 48 and a minumum of 5</Text>
191
+ <Spacer />
192
+ <Stepper
193
+ min={5}
194
+ max={48}
195
+ stepValue={1}
196
+ editable={true}
197
+ value={state.ledNum}
198
+ isRealTime={true}
199
+ onValueChange={(v) => {
200
+ state.ledNum = v
201
+ }} />
202
+ <Spacer />
203
+ <DeleteButton
204
+ text={I18n.getLang('auto_scan_system_wifi_confirm')}
205
+ style={{ width: cx(150), height: cx(40), backgroundColor: (state.ledNum < 5 || state.ledNum > 48) ? '#666' : '#f60' }}
206
+ textStyle={{ fontSize: cx(14) }}
207
+ onPress={() => {
208
+ if(state.ledNum < 5 || state.ledNum > 48) return
209
+ props.setLedNum(state.ledNum)
210
+ state.visible = false
211
+ }} />
212
+ <Spacer />
213
+ </Card>
203
214
  </Modal>}
204
215
  {props.children}
205
216
  </>}
@@ -16,6 +16,7 @@ export interface StepperProps {
16
16
  max?: number // 99
17
17
  editable?: boolean
18
18
  selectionColor?: string
19
+ isRealTime?: boolean
19
20
  onValueChange?: ((value: number) => void)
20
21
  disabled?: boolean
21
22
  style?: StyleProp<ViewStyle>
@@ -44,10 +45,17 @@ const Stepper = (props: StepperProps) => {
44
45
  if(newValue[0] === '.' ||
45
46
  (newValue.length === 2 && newValue[0] === '0' && newValue[1] !== '.') ||
46
47
  newValue.split('').filter(item => item === '.').length > 1 ||
47
- Number(newValue) > state.max || Number(newValue) < state.min ||
48
+ // Number(newValue) > state.max || Number(newValue) < state.min ||
48
49
  (idx !== -1 && newValue.length > idx + 2)){
49
50
  return
50
51
  }
52
+ if(props.isRealTime){
53
+ if (typeof v === 'string' && !v.length) {
54
+ props.onValueChange && props.onValueChange(0)
55
+ }else{
56
+ props.onValueChange && props.onValueChange(Number(exchangeNumber(v)))
57
+ }
58
+ }
51
59
  state.value = v
52
60
  }, [])
53
61
 
@@ -49,7 +49,7 @@ export declare function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Pro
49
49
  */
50
50
  export declare function useGroupConfigFeature<GC, GCPT extends {
51
51
  [K in keyof GC]: GC[K];
52
- }[keyof GC]>(key: keyof GC, dpKey?: string): [GCPT, (value: GCPT, dpValue: any, extraDps?: any) => Promise<Result<any>>];
52
+ }[keyof GC]>(key: keyof GC, dpKey?: string): [GCPT, (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => Promise<Result<any>>];
53
53
  export declare const useFanMaxSpeed: () => 3 | 20;
54
54
  export declare const isUVCFanDevice: () => boolean;
55
55
  export declare const ldvModules: import("@reduxjs/toolkit").Reducer<NativeProps, import("@reduxjs/toolkit").AnyAction>;
@@ -1,12 +1,12 @@
1
- import {createSlice, PayloadAction} from '@reduxjs/toolkit'
2
- import {useSelector} from '../index'
3
- import {Dispatch, useCallback} from 'react'
4
- import {DpsResult, Result} from './Result'
5
- import {DevInfo, DpValue} from 'tuya-panel-kit'
6
- import {NativeApi} from '../../api/native'
7
- import {useDispatch} from 'react-redux'
8
- import {GlobalParams} from '../GlobalParams'
9
- import {isNumber, snakeCase} from 'lodash'
1
+ import { createSlice, PayloadAction } from '@reduxjs/toolkit'
2
+ import { useSelector } from '../index'
3
+ import { Dispatch, useCallback } from 'react'
4
+ import { DpsResult, Result } from './Result'
5
+ import { DevInfo, DpValue } from 'tuya-panel-kit'
6
+ import { NativeApi } from '../../api/native'
7
+ import { useDispatch } from 'react-redux'
8
+ import { GlobalParams } from '../GlobalParams'
9
+ import { isNumber, snakeCase } from 'lodash'
10
10
 
11
11
  export interface NativeProps {
12
12
  familyName: string
@@ -72,7 +72,7 @@ const nativePropsSlice = createSlice({
72
72
  if (!!action.payload.deviceInfo.pId) {
73
73
  state.deviceInfo.pId = action.payload.deviceInfo.pId
74
74
  }
75
- state.deviceInfo.dps = {...state.deviceInfo.dps, ...action.payload.deviceInfo.dps}
75
+ state.deviceInfo.dps = { ...state.deviceInfo.dps, ...action.payload.deviceInfo.dps }
76
76
  },
77
77
  setGroupNativeProps: (state, action: PayloadAction<NativeProps>) => {
78
78
  state.uaGroupInfo.tyGroupId = action.payload.uaGroupInfo.tyGroupId
@@ -82,7 +82,7 @@ const nativePropsSlice = createSlice({
82
82
  if (!!action.payload.uaGroupInfo.pId) {
83
83
  state.uaGroupInfo.pId = action.payload.uaGroupInfo.pId
84
84
  }
85
- state.uaGroupInfo.dps = {...state.uaGroupInfo.dps, ...action.payload.uaGroupInfo.dps}
85
+ state.uaGroupInfo.dps = { ...state.uaGroupInfo.dps, ...action.payload.uaGroupInfo.dps }
86
86
  state.uaGroupInfo.config = action.payload.uaGroupInfo.config
87
87
  },
88
88
  setGroupConfig: (state, action: PayloadAction<any>) => {
@@ -124,12 +124,12 @@ function simpleSetDps<T>(dispatch: Dispatch<any>): (deviceId: string, dps: any)
124
124
  const res = await NativeApi.setDps(deviceId, dps)
125
125
  if (res.result) {
126
126
  return {
127
- result: {success: true},
127
+ result: { success: true },
128
128
  dps: dps,
129
129
  }
130
130
  }
131
131
  return {
132
- result: {success: false, msg: res.msg},
132
+ result: { success: false, msg: res.msg },
133
133
  }
134
134
  })
135
135
  }
@@ -138,7 +138,7 @@ function simpleSetDps<T>(dispatch: Dispatch<any>): (deviceId: string, dps: any)
138
138
  function simpleSetDp<T>(dispatch: Dispatch<any>): (deviceId: string, dp: string, value: any) => Promise<Result<T>> {
139
139
  return (deviceId, dp, value) => {
140
140
  const fun = simpleSetDps<T>(dispatch)
141
- return fun(deviceId, {[dp]: value})
141
+ return fun(deviceId, { [dp]: value })
142
142
  }
143
143
  }
144
144
 
@@ -211,7 +211,7 @@ const useEnergieverbrauch = () => {
211
211
  }
212
212
 
213
213
  export const useEngergyGeneration = () => {
214
- const {productId} = useDeviceInfo()
214
+ const { productId } = useDeviceInfo()
215
215
  return productList.some(val => val === productId)
216
216
  }
217
217
 
@@ -223,7 +223,7 @@ export function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Res
223
223
  const tyGroupId = useUAGroupInfo().tyGroupId
224
224
  const config = useUAGroupInfo().config as T
225
225
  const dispatch = useDispatch()
226
- const {setGroupConfig} = nativePropsSlice.actions
226
+ const { setGroupConfig } = nativePropsSlice.actions
227
227
  const setConfig = useCallback(async (dps: any, newConfig: T) => {
228
228
  // 发送控制命令
229
229
  const res = await NativeApi.groupControl(tyGroupId, JSON.stringify(dps), JSON.stringify(newConfig))
@@ -243,9 +243,9 @@ export function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Res
243
243
  * @param dpKey
244
244
  */
245
245
  export function useGroupConfigFeature<GC, GCPT extends { [K in keyof GC]: GC[K] }[keyof GC]>
246
- (key: keyof GC, dpKey?: string): [GCPT, (value: GCPT, dpValue: any, extraDps?: any) => Promise<Result<any>>] {
246
+ (key: keyof GC, dpKey?: string): [GCPT, (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => Promise<Result<any>>] {
247
247
  const [groupConfig, setGroupConfig] = useGroupConfig<GC>()
248
- const setGroupConfigFeature = async (value: GCPT, dpValue: any, extraDps?: any) => {
248
+ const setGroupConfigFeature = async (value: GCPT, dpValue: any, extraDps?: any, extraConfig?: any) => {
249
249
  return await setGroupConfig(
250
250
  {
251
251
  [!!dpKey ? dpKey : GlobalParams.dpSchemaMap[snakeCase(key as string)].dp]: dpValue,
@@ -253,6 +253,7 @@ export function useGroupConfigFeature<GC, GCPT extends { [K in keyof GC]: GC[K]
253
253
  },
254
254
  {
255
255
  ...groupConfig,
256
+ ...(extraConfig || {}),
256
257
  [key]: value,
257
258
  },
258
259
  )
@@ -261,12 +262,12 @@ export function useGroupConfigFeature<GC, GCPT extends { [K in keyof GC]: GC[K]
261
262
  }
262
263
 
263
264
  export const useFanMaxSpeed = () => {
264
- const {productId} = useDeviceInfo()
265
+ const { productId } = useDeviceInfo()
265
266
  return fanProductList.includes(productId) ? 20 : 3
266
267
  }
267
268
 
268
- export const isUVCFanDevice = () =>{
269
- const {productId} = useDeviceInfo()
269
+ export const isUVCFanDevice = () => {
270
+ const { productId } = useDeviceInfo()
270
271
  return fanProductList.includes(productId)
271
272
  }
272
273
 
@@ -1,51 +0,0 @@
1
- @ColumnInfo(name = "device_id")
2
- val deviceId: String,
3
- @ColumnInfo(name = "device_name")
4
- val deviceName: String,
5
- @ColumnInfo(name = "cat_id")
6
- val catId: String,
7
- @ColumnInfo(name = "channel_no")
8
- val channelNo: Int,
9
- @ColumnInfo(name = "device_category")
10
- val deviceCategory: String,
11
- @ColumnInfo(name = "device_image")
12
- val deviceImage: String,
13
- @ColumnInfo(name = "tuya_device_id")
14
- val tuyaDeviceId: String,
15
- // deviceType 对应 ProductInfo 的 productId
16
- @ColumnInfo(name = "device_type")
17
- val deviceType: String,
18
- @ColumnInfo(name = "offline_time")
19
- val offlineTime: String,
20
- @ColumnInfo(name = "rn_package")
21
- val rnPackage: String?,
22
- @ColumnInfo(name = "status")
23
- val status: Int,
24
- @ColumnInfo(name = "create_time")
25
- val createTime: String,
26
- @ColumnInfo(name = "version")
27
- val version: String,
28
- @ColumnInfo(name = "user_id")
29
- val userId: String,
30
- @ColumnInfo(name = "family_id")
31
- val familyId: Long,
32
- @ColumnInfo(name = "room_id")
33
- val roomId: Long,
34
- @ColumnInfo(name = "room_name")
35
- val roomName: String,
36
- @ColumnInfo(name = "is_shared")
37
- val isShared: Int,
38
- @ColumnInfo(name = "local_index")
39
- val localIndex: String,
40
- @ColumnInfo(name = "resource_category")
41
- val resourceCategory: String,
42
- @ColumnInfo(name = "resource_id")
43
- val resourceId: String,
44
- @ColumnInfo(name = "resource_identifier")
45
- val resourceIdentifier: String,
46
- @ColumnInfo(name = "resource_type")
47
- val resourceType: Int,
48
- @ColumnInfo(name = "index")
49
- val index: Int = 0,
50
- @ColumnInfo(name = "switch_state")
51
- val switchState: Boolean = true