@ledvance/base 1.2.58 → 1.2.60

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.
@@ -21,6 +21,7 @@ export interface NativeProps {
21
21
  flags: any[]
22
22
  flagModeState: FlagModeState
23
23
  is24HourClock: boolean
24
+ timeZone: string
24
25
  }
25
26
 
26
27
  interface FlagModeState {
@@ -65,7 +66,8 @@ const initialState: NativeProps = {
65
66
  flagMode: false,
66
67
  flagId: undefined
67
68
  },
68
- is24HourClock: true
69
+ is24HourClock: true,
70
+ timeZone: 'Europe/Berlin'
69
71
  }
70
72
 
71
73
  // energy generation
@@ -137,6 +139,9 @@ const nativePropsSlice = createSlice({
137
139
  },
138
140
  setSystemTimeFormat(state, action: PayloadAction<any>) {
139
141
  state.is24HourClock = action.payload
142
+ },
143
+ setTimeZone(state, action: PayloadAction<any>) {
144
+ state.timeZone = action.payload
140
145
  }
141
146
  },
142
147
  })
@@ -279,6 +284,14 @@ const useSystemTimeFormate = (): boolean => {
279
284
  return useSelector(store => store.ldvModules.is24HourClock)
280
285
  }
281
286
 
287
+ const useTimeZone = (): string => {
288
+ return useSelector(store => store.ldvModules.timeZone)
289
+ }
290
+
291
+ const useTimeZoneCity = (): string => {
292
+ return useSelector(store => store.ldvModules.timeZone).split('/')[1]
293
+ }
294
+
282
295
  const useEnergieverbrauch = () => {
283
296
  const dps = useSelector(store => store.ldvModules.energieverbrauch)
284
297
  const dispatch = useDispatch()
@@ -337,7 +350,6 @@ export function useGroupConfigFeature<GC, GCPT extends PropertyValueTypes<GC>>
337
350
  ...(extraDps || {}),
338
351
  },
339
352
  {
340
- ...groupConfig,
341
353
  ...(extraConfig || {}),
342
354
  [key]: value,
343
355
  },
@@ -360,7 +372,7 @@ export function useFeatureHook<GC, T extends PropertyValueTypes<GC>>(
360
372
  const extraConfig = getExtraConfig ? getExtraConfig(value) : undefined
361
373
  return await setFH(value, dpValue, extraDps, extraConfig)
362
374
  }, [setFH])
363
- return [featureHook || defValue, setFeatureHook]
375
+ return [featureHook ?? defValue, setFeatureHook]
364
376
  }
365
377
 
366
378
  export const useFanMaxSpeed = () => {
@@ -385,6 +397,7 @@ export const {
385
397
  setFlagMode,
386
398
  setGroupDevices,
387
399
  setSystemTimeFormat,
400
+ setTimeZone,
388
401
  setEnergieverbrauch,
389
402
  } = nativePropsSlice.actions
390
403
 
@@ -405,5 +418,7 @@ export {
405
418
  useFlagMode,
406
419
  useGroupDevices,
407
420
  useSystemTimeFormate,
421
+ useTimeZone,
422
+ useTimeZoneCity,
408
423
  useEnergieverbrauch,
409
424
  }
@@ -2,6 +2,7 @@
2
2
  import {Utils} from 'tuya-panel-kit'
3
3
  import {store} from '../models'
4
4
  import I18n from '../i18n/index'
5
+ import dayjs from "dayjs";
5
6
 
6
7
  export const getFaultStrings = (faultCode: string, faultValue: number, onlyPrior = true) => {
7
8
  const {devInfo} = store.getState()
@@ -183,4 +184,8 @@ export function abbreviateMonths(str: string) {
183
184
  };
184
185
 
185
186
  return str.replace(/(?:January|February|March|April|May|June|July|August|September|October|November|December)/g, match => monthAbbreviations[match]);
186
- }
187
+ }
188
+
189
+ export function overDays(date: string, days: number): boolean {
190
+ return dayjs().diff(dayjs(date), 'days') >= days
191
+ }
@@ -3,4 +3,9 @@ export enum WorkMode {
3
3
  Colour = 'colour',
4
4
  Scene = 'scene',
5
5
  Music = 'music',
6
- }
6
+ Control = 'control',
7
+ Night = 'night',
8
+ Disinfect = 'disinfect',
9
+ Rhythm = 'rhythm',
10
+ Plan = 'plan'
11
+ }
@@ -0,0 +1,52 @@
1
+ import json
2
+ import os
3
+ import subprocess
4
+ import sys
5
+
6
+
7
+ def main():
8
+ try:
9
+ print('Begin update localazy.')
10
+ # 读取translateKey.txt并生成include_keys
11
+ with open('../translateKey.txt', 'r') as f:
12
+ include_keys = [f'MATCH:{line.strip()}' for line in f]
13
+
14
+ # 读取和更新localazy.json
15
+ with open('localazy.json', 'r+') as f:
16
+ content = json.load(f)
17
+ content['conversion']['actions']['includeKeys'] = include_keys
18
+ f.seek(0)
19
+ f.truncate()
20
+ f.write(json.dumps(content, indent=4, ensure_ascii=False))
21
+
22
+ # 根据平台执行localazy download命令
23
+ params = ['cmd', '/c', 'localazy', 'download'] if sys.platform.startswith('win') else ['localazy', 'download']
24
+ result = subprocess.run(params, stdout=subprocess.PIPE, text=True, errors='ignore')
25
+
26
+ # 检查命令执行结果
27
+ if 'Done.' in result.stdout:
28
+ print('Download localazy successful.')
29
+ else:
30
+ print('Download localazy failed.')
31
+ sys.exit(-1)
32
+
33
+ # 读取strings.json并写入strings.ts
34
+ with open('strings.json', 'r', encoding='utf8') as f:
35
+ string_json = json.load(f)
36
+
37
+ with open('src/i18n/strings.ts', 'w', encoding='utf8') as f:
38
+ pt = string_json.get('pt-BR')
39
+ if pt:
40
+ string_json['pt_BR'] = pt
41
+ f.write(f'export default {json.dumps(string_json, indent=4, ensure_ascii=False)}')
42
+
43
+ os.remove('strings.json')
44
+ print('Update localazy finished.')
45
+
46
+ except Exception as e:
47
+ print(f'An error occurred: {e}')
48
+ sys.exit(-1)
49
+
50
+
51
+ if __name__ == '__main__':
52
+ main()