@ledvance/base 1.1.90 → 1.1.92
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
|
@@ -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
|
|