@eohjsc/react-native-smart-city 0.3.23 → 0.3.24

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/src/commons/ActionGroup/CurtainButtonTemplate.js +9 -17
  3. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +6 -8
  4. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +3 -13
  5. package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -23
  6. package/src/commons/ActionGroup/OneBigButtonTemplate.js +2 -3
  7. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -6
  8. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -4
  9. package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -14
  10. package/src/commons/ActionGroup/ThreeButtonTemplate.js +6 -9
  11. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +6 -18
  12. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +3 -15
  13. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +1 -2
  14. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +2 -10
  15. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -15
  16. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +1 -1
  17. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +3 -9
  18. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +1 -7
  19. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +10 -2
  20. package/src/commons/ActionGroup/__test__/index.test.js +7 -17
  21. package/src/commons/ConnectingProcess/index.js +6 -25
  22. package/src/commons/Device/HistoryChart.js +8 -6
  23. package/src/commons/RowItem/styles.js +0 -1
  24. package/src/commons/SubUnit/ShortDetail.js +13 -1
  25. package/src/configs/API.js +1 -1
  26. package/src/context/actionType.ts +1 -0
  27. package/src/context/reducer.ts +9 -0
  28. package/src/hooks/IoT/__test__/useRemoteControl.test.js +9 -11
  29. package/src/hooks/IoT/useRemoteControl.js +2 -3
  30. package/src/iot/RemoteControl/Internet.js +1 -8
  31. package/src/navigations/UnitStack.js +11 -0
  32. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  33. package/src/screens/Device/detail.js +0 -7
  34. package/src/screens/PlayBackCamera/index.js +22 -6
  35. package/src/screens/Unit/components/MyUnitDevice/index.js +2 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.3.23",
4
+ "version": "0.3.24",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -9,11 +9,8 @@ import { Colors, Images } from '../../configs';
9
9
  const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
10
10
  const { configuration } = actionGroup;
11
11
  const {
12
- text_open,
13
12
  open_action_data,
14
- text_stop,
15
13
  stop_action_data,
16
- text_close,
17
14
  close_action_data,
18
15
  action_off_data,
19
16
  action_on_data,
@@ -26,31 +23,26 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
26
23
  const [lock, setLock] = useState(false);
27
24
 
28
25
  const onButtonOpenPress = useCallback(() => {
29
- const actionName = `${sensor?.name} ${text_open?.toLowerCase()}`;
30
- doAction(open_action_data, null, actionName);
31
- }, [open_action_data, text_open, doAction, sensor?.name]);
26
+ doAction(open_action_data, null);
27
+ }, [open_action_data, doAction]);
32
28
 
33
29
  const onButtonStopPress = useCallback(() => {
34
- const actionName = `${sensor?.name} ${text_stop?.toLowerCase()}`;
35
- doAction(stop_action_data, null, actionName);
36
- }, [stop_action_data, text_stop, doAction, sensor?.name]);
30
+ doAction(stop_action_data, null);
31
+ }, [stop_action_data, doAction]);
37
32
 
38
33
  const onButtonClosePress = useCallback(() => {
39
- const actionName = `${sensor?.name} ${text_close?.toLowerCase()}`;
40
- doAction(close_action_data, null, actionName);
41
- }, [close_action_data, text_close, doAction, sensor?.name]);
34
+ doAction(close_action_data, null);
35
+ }, [close_action_data, doAction]);
42
36
 
43
37
  const onChangeSwitch = useCallback(() => {
44
38
  if (lock) {
45
- const actionName = `${sensor?.name} unlock`;
46
39
  setLock(false);
47
- doAction(action_off_data, null, actionName);
40
+ doAction(action_off_data, null);
48
41
  return;
49
42
  }
50
- const actionName = `${sensor?.name} lock`;
51
- doAction(action_on_data, null, actionName);
43
+ doAction(action_on_data, null);
52
44
  setLock(true);
53
- }, [action_off_data, action_on_data, doAction, lock, sensor?.name]);
45
+ }, [action_off_data, action_on_data, doAction, lock]);
54
46
 
55
47
  const RenderThreeButtonActions = () => {
56
48
  const buttons = [
@@ -39,7 +39,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
39
39
  }, [JSON.stringify(configValues)]);
40
40
 
41
41
  const doActionAndWatchConfig = useCallback(
42
- async (actionData, actionValue, actionName) => {
42
+ async (actionData, actionValue) => {
43
43
  let data = actionValue;
44
44
  if (sensor.device_type !== DEVICE_TYPE.GOOGLE_HOME) {
45
45
  data = { temperature: actionValue };
@@ -49,7 +49,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
49
49
  }
50
50
  data = JSON.stringify(data);
51
51
  }
52
- await doAction(actionData, data, actionName);
52
+ await doAction(actionData, data);
53
53
  if (!sensor?.is_managed_by_backend) {
54
54
  return;
55
55
  }
@@ -73,18 +73,16 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
73
73
  useUnwatchLGDeviceConfigControl(sensor, [config]);
74
74
 
75
75
  const doActionUp = useCallback(async () => {
76
- const actionName = `${sensor?.name} temp up`;
77
76
  const newValue = checkMinMax(value + 1);
78
- doActionAndWatchConfig(action_data, newValue, actionName);
77
+ doActionAndWatchConfig(action_data, newValue);
79
78
  setValue(newValue);
80
- }, [sensor?.name, checkMinMax, value, doActionAndWatchConfig, action_data]);
79
+ }, [checkMinMax, value, doActionAndWatchConfig, action_data]);
81
80
 
82
81
  const doActionDown = useCallback(async () => {
83
- const actionName = `${sensor?.name} temp down`;
84
82
  const newValue = checkMinMax(value - 1);
85
- doActionAndWatchConfig(action_data, newValue, actionName);
83
+ doActionAndWatchConfig(action_data, newValue);
86
84
  setValue(newValue);
87
- }, [sensor?.name, checkMinMax, value, doActionAndWatchConfig, action_data]);
85
+ }, [checkMinMax, value, doActionAndWatchConfig, action_data]);
88
86
 
89
87
  const checkMinMax = useCallback(
90
88
  (tempValue) => {
@@ -21,19 +21,11 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
21
21
  const handleActionSmartLock = useCallback(async () => {
22
22
  if (action_on_data && action_off_data) {
23
23
  if (isUnlock) {
24
- let actionName = `${
25
- sensor?.name
26
- } ${actionGroup?.title?.toLowerCase()} lock`;
27
- actionName = actionName.replace(/\s+/g, ' ').trim();
28
24
  const dataLock = { door_lock: 0 };
29
- await doAction(action_on_data, JSON.stringify(dataLock), actionName);
25
+ await doAction(action_on_data, JSON.stringify(dataLock));
30
26
  } else {
31
- let actionName = `${
32
- sensor?.name
33
- } ${actionGroup?.title?.toLowerCase()} unlock`;
34
- actionName = actionName.replace(/\s+/g, ' ').trim();
35
27
  const dataUnlock = { door_lock: 1 };
36
- await doAction(action_off_data, JSON.stringify(dataUnlock), actionName);
28
+ await doAction(action_off_data, JSON.stringify(dataUnlock));
37
29
  }
38
30
  if (sensor?.is_managed_by_backend) {
39
31
  configuration.config &&
@@ -42,15 +34,13 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
42
34
  }
43
35
  }
44
36
  }, [
45
- actionGroup?.title,
46
37
  action_off_data,
47
38
  action_on_data,
48
39
  doAction,
49
40
  isUnlock,
50
- sensor?.name,
51
41
  configuration,
52
42
  sensor?.is_managed_by_backend,
53
- sensor?.device_type,
43
+ sensor.device_type,
54
44
  ]);
55
45
 
56
46
  useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
@@ -45,32 +45,14 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
45
45
  }, 2500);
46
46
  };
47
47
 
48
- const actionName = useCallback(
49
- (text) => {
50
- const actionNameType = `${
51
- sensor?.name
52
- } ${actionGroup?.title?.toLowerCase()} ${text}`;
53
- return actionNameType.replace(/\s+/g, ' ').trim();
54
- },
55
- [actionGroup?.title, sensor?.name]
56
- );
57
-
58
48
  const triggerAction = useCallback(async () => {
59
49
  switch (sensor?.device_type) {
60
50
  case DEVICE_TYPE.ZIGBEE:
61
51
  if (action_on_data && action_off_data) {
62
52
  if (isOn) {
63
- await doAction(
64
- action_off_data,
65
- JSON.stringify({ state: 0 }),
66
- actionName('off')
67
- );
53
+ await doAction(action_off_data, JSON.stringify({ state: 0 }));
68
54
  } else {
69
- await doAction(
70
- action_on_data,
71
- JSON.stringify({ state: 1 }),
72
- actionName('on')
73
- );
55
+ await doAction(action_on_data, JSON.stringify({ state: 1 }));
74
56
  }
75
57
  }
76
58
  break;
@@ -90,9 +72,9 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
90
72
  }
91
73
  if (action_on_data && action_off_data) {
92
74
  if (isOn) {
93
- await doAction(action_off_data, null, actionName('off'));
75
+ await doAction(action_off_data, null);
94
76
  } else {
95
- await doAction(action_on_data, null, actionName('on'));
77
+ await doAction(action_on_data, null);
96
78
  }
97
79
  }
98
80
  break;
@@ -104,7 +86,6 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
104
86
  watchMultiConfigs([configuration?.config]);
105
87
  }
106
88
  }, [
107
- actionName,
108
89
  action_data,
109
90
  action_off_data,
110
91
  action_on_data,
@@ -11,9 +11,8 @@ const OneBigButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
11
11
  const { text, action_data } = configuration || {};
12
12
 
13
13
  const onPressDoAction = useCallback(() => {
14
- const actionName = `${sensor?.name} ${text?.toLowerCase()}`;
15
- doAction(action_data, null, actionName);
16
- }, [action_data, text, doAction, sensor?.name]);
14
+ doAction(action_data, null);
15
+ }, [action_data, doAction]);
17
16
 
18
17
  return (
19
18
  <>
@@ -60,15 +60,13 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
60
60
  const onDone = useCallback(() => {
61
61
  const newOption = options[selectedIndex];
62
62
  const value = getOptionValue(newOption);
63
- let actionName = `${sensor?.name} ${title?.toLowerCase()} ${value}`;
64
- actionName = actionName.replace(/\s+/g, ' ').trim();
65
63
 
66
64
  let data = JSON.stringify({ level: value, key_code: newOption?.value_int });
67
65
  if (sensor.device_type === DEVICE_TYPE.GOOGLE_HOME) {
68
66
  data = value;
69
67
  }
70
68
 
71
- doAction(action_data, data, actionName);
69
+ doAction(action_data, data);
72
70
  if (sensor?.is_managed_by_backend) {
73
71
  configuration.config &&
74
72
  sensor.device_type === DEVICE_TYPE.LG_THINQ &&
@@ -83,9 +81,7 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
83
81
  options,
84
82
  selectedIndex,
85
83
  sensor?.is_managed_by_backend,
86
- sensor?.name,
87
- sensor?.device_type,
88
- title,
84
+ sensor.device_type,
89
85
  ]);
90
86
 
91
87
  useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
@@ -33,11 +33,9 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
33
33
  const { config } = configuration;
34
34
  const configValue = configValues[config];
35
35
  let valueBrness = configValue?.value;
36
- let valueTemp = valueBrness;
37
- if (valueBrness > 0) {
38
- valueTemp = Math.round((valueBrness / 254) * 100);
36
+ if (valueBrness >= 0) {
37
+ setValueBrightness(valueBrness);
39
38
  }
40
- setValueBrightness(valueTemp);
41
39
  }, [configuration.config, configValues, configuration]);
42
40
 
43
41
  return (
@@ -40,26 +40,14 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
40
40
 
41
41
  const doActionAndWatchConfig = useCallback(
42
42
  (actionData) => {
43
- let actionName = `${
44
- sensor?.name
45
- } ${title?.toLowerCase()} ${text?.toLowerCase()}`;
46
- actionName = actionName.replace(/\s+/g, ' ').trim();
47
- doAction(actionData, null, actionName);
43
+ doAction(actionData, null);
48
44
  if (sensor?.is_managed_by_backend) {
49
45
  config &&
50
46
  sensor.device_type === DEVICE_TYPE.LG_THINQ &&
51
47
  watchMultiConfigs([config]);
52
48
  }
53
49
  },
54
- [
55
- config,
56
- doAction,
57
- sensor?.is_managed_by_backend,
58
- sensor?.name,
59
- sensor?.device_type,
60
- text,
61
- title,
62
- ]
50
+ [config, doAction, sensor?.is_managed_by_backend, sensor.device_type]
63
51
  );
64
52
 
65
53
  useUnwatchLGDeviceConfigControl(sensor, [config]);
@@ -30,19 +30,16 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
30
30
  );
31
31
  };
32
32
  const onButton1Press = useCallback(() => {
33
- const actionName = `${sensor?.name} ${text1?.toLowerCase()}`;
34
- doAction(action1_data, null, actionName);
35
- }, [action1_data, text1, doAction, sensor?.name]);
33
+ doAction(action1_data, null);
34
+ }, [action1_data, doAction]);
36
35
 
37
36
  const onButton2Press = useCallback(() => {
38
- const actionName = `${sensor?.name} ${text2?.toLowerCase()}`;
39
- doAction(action2_data, null, actionName);
40
- }, [action2_data, text2, doAction, sensor?.name]);
37
+ doAction(action2_data, null);
38
+ }, [action2_data, doAction]);
41
39
 
42
40
  const onButton3Press = useCallback(() => {
43
- const actionName = `${sensor?.name} ${text3?.toLowerCase()}`;
44
- doAction(action3_data, null, actionName);
45
- }, [action3_data, text3, doAction, sensor?.name]);
41
+ doAction(action3_data, null);
42
+ }, [action3_data, doAction]);
46
43
 
47
44
  const onChangeSwitch = useCallback(() => {
48
45
  if (lock) {
@@ -18,22 +18,12 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
18
18
  const [configValues] = useConfigGlobalState('configValues');
19
19
  const isLight = false;
20
20
 
21
- const actionName = useCallback(
22
- (text) => {
23
- const actionNameType = `${
24
- sensor?.name
25
- } ${actionGroup?.title?.toLowerCase()} ${text}`;
26
- return actionNameType.replace(/\s+/g, ' ').trim();
27
- },
28
- [actionGroup?.title, sensor?.name]
29
- );
30
-
31
21
  const triggerAction1 = useCallback(async () => {
32
22
  if (button1?.action_on_data && button1?.action_off_data) {
33
23
  if (isOn) {
34
- await doAction(button1?.action_off_data, null, actionName('off'));
24
+ await doAction(button1?.action_off_data, null);
35
25
  } else {
36
- await doAction(button1?.action_on_data, null, actionName('on'));
26
+ await doAction(button1?.action_on_data, null);
37
27
  }
38
28
  }
39
29
  if (sensor?.is_managed_by_backend) {
@@ -42,21 +32,20 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
42
32
  watchMultiConfigs([configuration.config]);
43
33
  }
44
34
  }, [
45
- actionName,
46
35
  button1,
47
36
  configuration.config,
48
37
  doAction,
49
38
  isOn,
50
39
  sensor?.is_managed_by_backend,
51
- sensor?.device_type,
40
+ sensor.device_type,
52
41
  ]);
53
42
 
54
43
  const triggerAction2 = useCallback(async () => {
55
44
  if (button2?.action_on_data && button2?.action_off_data) {
56
45
  if (isStart) {
57
- await doAction(button2?.action_off_data, null, actionName('stop'));
46
+ await doAction(button2?.action_off_data, null);
58
47
  } else {
59
- await doAction(button2?.action_on_data, null, actionName('start'));
48
+ await doAction(button2?.action_on_data, null);
60
49
  }
61
50
  }
62
51
  if (
@@ -66,14 +55,13 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
66
55
  configuration.config && watchMultiConfigs([configuration.config]);
67
56
  }
68
57
  }, [
69
- actionName,
70
58
  button2?.action_off_data,
71
59
  button2?.action_on_data,
72
60
  configuration.config,
73
61
  doAction,
74
62
  isStart,
75
63
  sensor?.is_managed_by_backend,
76
- sensor?.device_type,
64
+ sensor.device_type,
77
65
  ]);
78
66
 
79
67
  useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
@@ -97,25 +97,13 @@ describe('Test CurtainButtonTemplate', () => {
97
97
  await touchableOpacities[0].props.onPress();
98
98
  await touchableOpacities[1].props.onPress();
99
99
  await touchableOpacities[2].props.onPress();
100
- expect(mockDoAction).toBeCalledWith(
101
- mockCloseActionData,
102
- null,
103
- sensor?.name + ' undefined'
104
- );
100
+ expect(mockDoAction).toBeCalledWith(mockCloseActionData, null);
105
101
 
106
102
  const Switchs = instance.findAllByType(Switch);
107
103
  expect(Switchs).toHaveLength(1);
108
104
  await Switchs[0].props.onValueChange();
109
- expect(mockDoAction).toBeCalledWith(
110
- mockActionOnData,
111
- null,
112
- `${sensor.name} lock`
113
- );
105
+ expect(mockDoAction).toBeCalledWith(mockActionOnData, null);
114
106
  await Switchs[0].props.onValueChange();
115
- expect(mockDoAction).toBeCalledWith(
116
- mockActionOffData,
117
- null,
118
- `${sensor.name} unlock`
119
- );
107
+ expect(mockDoAction).toBeCalledWith(mockActionOffData, null);
120
108
  });
121
109
  });
@@ -399,8 +399,7 @@ describe('Test NumberUpDownActionTemplate', () => {
399
399
  id: 20,
400
400
  key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
401
401
  },
402
- 26,
403
- 'Device temp up'
402
+ 26
404
403
  );
405
404
  });
406
405
  });
@@ -87,11 +87,7 @@ describe('Test OnOffTemplate', () => {
87
87
  await act(async () => {
88
88
  await button.props.onPress();
89
89
  });
90
- expect(mockDoAction).toBeCalledWith(
91
- action_on_data,
92
- '{"door_lock":0}',
93
- 'Sensor smartlock lock'
94
- );
90
+ expect(mockDoAction).toBeCalledWith(action_on_data, '{"door_lock":0}');
95
91
  });
96
92
 
97
93
  test('render with template OnOffSmartLockActionTemplate doAction unlock', async () => {
@@ -111,10 +107,6 @@ describe('Test OnOffTemplate', () => {
111
107
  await act(async () => {
112
108
  await button.props.onPress();
113
109
  });
114
- expect(mockDoAction).toBeCalledWith(
115
- action_off_data,
116
- '{"door_lock":1}',
117
- 'Sensor smartlock unlock'
118
- );
110
+ expect(mockDoAction).toBeCalledWith(action_off_data, '{"door_lock":1}');
119
111
  });
120
112
  });
@@ -164,11 +164,7 @@ describe('Test OnOffTemplate', () => {
164
164
  await act(async () => {
165
165
  await template.props.triggerAction();
166
166
  });
167
- expect(mockDoAction).toHaveBeenCalledWith(
168
- action_off_data,
169
- null,
170
- 'Sensor turn on / off off'
171
- );
167
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, null);
172
168
  expect(watchMultiConfigs).toBeCalledTimes(0);
173
169
  });
174
170
 
@@ -185,11 +181,7 @@ describe('Test OnOffTemplate', () => {
185
181
  await act(async () => {
186
182
  await template.props.triggerAction();
187
183
  });
188
- expect(mockDoAction).toHaveBeenCalledWith(
189
- action_on_data,
190
- null,
191
- 'Sensor turn on / off on'
192
- );
184
+ expect(mockDoAction).toHaveBeenCalledWith(action_on_data, null);
193
185
  });
194
186
 
195
187
  test('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
@@ -204,11 +196,7 @@ describe('Test OnOffTemplate', () => {
204
196
  await act(async () => {
205
197
  await template.props.triggerAction();
206
198
  });
207
- expect(mockDoAction).toHaveBeenCalledWith(
208
- action_off_data,
209
- null,
210
- 'Sensor turn on / off off'
211
- );
199
+ expect(mockDoAction).toHaveBeenCalledWith(action_off_data, null);
212
200
  expect(watchMultiConfigs).toBeCalledTimes(0);
213
201
  });
214
202
 
@@ -69,6 +69,6 @@ describe('Test OneBigButtonTemplate', () => {
69
69
  });
70
70
 
71
71
  expect(mockDoAction).toHaveBeenCalledTimes(1);
72
- expect(mockDoAction).toHaveBeenCalledWith(action_data, null, 'Sensor up');
72
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, null);
73
73
  });
74
74
  });
@@ -159,8 +159,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
159
159
 
160
160
  expect(mockDoAction).toHaveBeenCalledWith(
161
161
  action_data,
162
- JSON.stringify({ level: 1, key_code: 1 }),
163
- 'Sensor name fan speed 1'
162
+ JSON.stringify({ level: 1, key_code: 1 })
164
163
  );
165
164
  is_managed_by_backend
166
165
  ? expect(watchMultiConfigs).not.toBeCalled()
@@ -228,8 +227,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
228
227
 
229
228
  expect(mockDoAction).toHaveBeenCalledWith(
230
229
  action_data,
231
- JSON.stringify({ level: 'level-1', key_code: 1 }),
232
- 'Sensor name fan speed level-1'
230
+ JSON.stringify({ level: 'level-1', key_code: 1 })
233
231
  ); // doAction with text instead of int
234
232
 
235
233
  expect(texts[1].props.children).toEqual('Level2');
@@ -303,10 +301,6 @@ describe('Test OptionsDropdownActionTemplate', () => {
303
301
  });
304
302
  expect(alertAction.props.visible).toBeFalsy();
305
303
 
306
- expect(mockDoAction).toHaveBeenCalledWith(
307
- action_data,
308
- 'level-1',
309
- 'Sensor name fan speed level-1'
310
- ); // doAction with text instead of int
304
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, 'level-1'); // doAction with text instead of int
311
305
  });
312
306
  });
@@ -73,12 +73,6 @@ describe('Test StatesGridActionTemplate', () => {
73
73
  const TouchableOpacities = instance.findAllByType(TouchableOpacity);
74
74
  expect(TouchableOpacities).toHaveLength(2);
75
75
  await TouchableOpacities[0].props.onPress();
76
- expect(mockDoAction).toBeCalledWith(
77
- mockActionData,
78
- null,
79
- `${sensor.name} ${actionGroup.title.toLowerCase()} ${
80
- actionGroup.configuration.options[0].text
81
- }`
82
- );
76
+ expect(mockDoAction).toBeCalledWith(mockActionData, null);
83
77
  });
84
78
  });
@@ -81,7 +81,11 @@ describe('Test TwoButtonTemplate', () => {
81
81
  const mockDoAction = jest.fn();
82
82
  act(() => {
83
83
  wrapper = create(
84
- <TwoButtonTemplate actionGroup={actionGroup} doAction={mockDoAction} />
84
+ <TwoButtonTemplate
85
+ actionGroup={actionGroup}
86
+ doAction={mockDoAction}
87
+ sensor={sensor}
88
+ />
85
89
  );
86
90
  });
87
91
 
@@ -101,7 +105,11 @@ describe('Test TwoButtonTemplate', () => {
101
105
  const mockDoAction = jest.fn();
102
106
  act(() => {
103
107
  wrapper = create(
104
- <TwoButtonTemplate actionGroup={actionGroup} doAction={mockDoAction} />
108
+ <TwoButtonTemplate
109
+ actionGroup={actionGroup}
110
+ doAction={mockDoAction}
111
+ sensor={sensor}
112
+ />
105
113
  );
106
114
  });
107
115
 
@@ -183,8 +183,7 @@ describe('Test ActionGroup', () => {
183
183
  expect(mockDoAction).toHaveBeenCalledTimes(1);
184
184
  expect(mockDoAction).toHaveBeenCalledWith(
185
185
  actionGroup.configuration.action1_data,
186
- null,
187
- 'Sensor name up'
186
+ null
188
187
  );
189
188
  act(() => {
190
189
  buttons[1].props.onPress();
@@ -192,8 +191,7 @@ describe('Test ActionGroup', () => {
192
191
  expect(mockDoAction).toHaveBeenCalledTimes(2);
193
192
  expect(mockDoAction).toHaveBeenCalledWith(
194
193
  actionGroup.configuration.action2_data,
195
- null,
196
- 'Sensor name stop'
194
+ null
197
195
  );
198
196
  act(() => {
199
197
  buttons[2].props.onPress();
@@ -201,8 +199,7 @@ describe('Test ActionGroup', () => {
201
199
  expect(mockDoAction).toHaveBeenCalledTimes(3);
202
200
  expect(mockDoAction).toHaveBeenCalledWith(
203
201
  actionGroup.configuration.action3_data,
204
- null,
205
- 'Sensor name down'
202
+ null
206
203
  );
207
204
  });
208
205
 
@@ -257,8 +254,7 @@ describe('Test ActionGroup', () => {
257
254
  expect(mockDoAction).toHaveBeenCalledTimes(1);
258
255
  expect(mockDoAction).toHaveBeenCalledWith(
259
256
  actionGroup.configuration.action1_data,
260
- null,
261
- 'Sensor name up'
257
+ null
262
258
  );
263
259
  act(() => {
264
260
  buttons[1].props.onPress();
@@ -266,8 +262,7 @@ describe('Test ActionGroup', () => {
266
262
  expect(mockDoAction).toHaveBeenCalledTimes(2);
267
263
  expect(mockDoAction).toHaveBeenCalledWith(
268
264
  actionGroup.configuration.action2_data,
269
- null,
270
- 'Sensor name stop'
265
+ null
271
266
  );
272
267
  act(() => {
273
268
  buttons[2].props.onPress();
@@ -275,8 +270,7 @@ describe('Test ActionGroup', () => {
275
270
  expect(mockDoAction).toHaveBeenCalledTimes(3);
276
271
  expect(mockDoAction).toHaveBeenCalledWith(
277
272
  actionGroup.configuration.action3_data,
278
- null,
279
- 'Sensor name down'
273
+ null
280
274
  );
281
275
  });
282
276
 
@@ -316,11 +310,7 @@ describe('Test ActionGroup', () => {
316
310
  buttons[0].props.onPress();
317
311
  });
318
312
  expect(mockDoAction).toHaveBeenCalledTimes(1);
319
- expect(mockDoAction).toHaveBeenCalledWith(
320
- action_data,
321
- null,
322
- 'Sensor name up'
323
- );
313
+ expect(mockDoAction).toHaveBeenCalledWith(action_data, null);
324
314
  });
325
315
 
326
316
  test('render ActionGroup on_off_button_action_template', async () => {
@@ -12,7 +12,6 @@ import styles from './styles';
12
12
  import DeviceItem from './DeviceItem/DeviceItem';
13
13
  import Connecting from '../Connecting';
14
14
  import { useSCContextSelector } from '../../context';
15
- import { ToastBottomHelper } from '../../utils/Utils';
16
15
 
17
16
  const ConnectingSuccess = ({
18
17
  unit,
@@ -76,7 +75,6 @@ const ConnectingProcess = ({ route }) => {
76
75
  setSensor(data);
77
76
  setNewName(data?.name);
78
77
  } else {
79
- ToastBottomHelper.error(JSON.stringify(data));
80
78
  goBack();
81
79
  }
82
80
 
@@ -96,7 +94,6 @@ const ConnectingProcess = ({ route }) => {
96
94
  setSensor(data);
97
95
  setNewName(data?.name);
98
96
  } else {
99
- ToastBottomHelper.error(JSON.stringify(data));
100
97
  goBack();
101
98
  }
102
99
  break;
@@ -113,7 +110,6 @@ const ConnectingProcess = ({ route }) => {
113
110
  setSensor(data);
114
111
  setNewName(data?.name || gateway?.model);
115
112
  } else {
116
- ToastBottomHelper.error(JSON.stringify(data));
117
113
  goBack();
118
114
  }
119
115
  break;
@@ -136,36 +132,21 @@ const ConnectingProcess = ({ route }) => {
136
132
  ]);
137
133
 
138
134
  const handleDone = useCallback(async () => {
139
- let result, message;
140
135
  switch (devicePrefixName) {
141
136
  case 'SENSOR': {
142
- const { success, data } = await axiosPatch(
143
- API.SENSOR.SENSOR_DETAIL(sensor?.id),
144
- {
145
- name: newName,
146
- }
147
- );
148
- result = success;
149
- message = data;
137
+ await axiosPatch(API.SENSOR.SENSOR_DETAIL(sensor?.id), {
138
+ name: newName,
139
+ });
150
140
  break;
151
141
  }
152
142
  case 'ROBOT':
153
143
  case 'LITE': {
154
- const { success, data } = await axiosPatch(
155
- API.CHIP.CHIP_DETAIL(sensor?.id),
156
- {
157
- name: newName,
158
- }
159
- );
160
- result = success;
161
- message = data;
144
+ await axiosPatch(API.CHIP.CHIP_DETAIL(sensor?.id), {
145
+ name: newName,
146
+ });
162
147
  break;
163
148
  }
164
149
  }
165
-
166
- if (!result) {
167
- ToastBottomHelper.error(JSON.stringify(message));
168
- }
169
150
  navigate(Routes.UnitStack, {
170
151
  screen: Routes.UnitDetail,
171
152
  params: {
@@ -76,7 +76,7 @@ const HistoryChart = memo(
76
76
  return {
77
77
  ...state,
78
78
  showModalStart: false,
79
- startTime: moment(date),
79
+ startTime: date ? moment(date) : moment().valueOf(),
80
80
  };
81
81
  } else {
82
82
  setStartDate(moment(date));
@@ -84,8 +84,8 @@ const HistoryChart = memo(
84
84
  return {
85
85
  ...state,
86
86
  showModalStart: false,
87
- startTime: moment(date),
88
- endTime: moment(date).add(1, 'day'),
87
+ startTime: date ? moment(date) : moment().valueOf(),
88
+ endTime: date ? moment(date).add(1, 'day') : moment().valueOf(),
89
89
  };
90
90
  }
91
91
  });
@@ -105,7 +105,7 @@ const HistoryChart = memo(
105
105
  return {
106
106
  ...state,
107
107
  showModalEnd: false,
108
- endTime: moment(date),
108
+ endTime: date ? moment(date) : moment().valueOf(),
109
109
  };
110
110
  } else {
111
111
  setStartDate(moment(date).add(-1, 'day'));
@@ -113,8 +113,10 @@ const HistoryChart = memo(
113
113
  return {
114
114
  ...state,
115
115
  showModalEnd: false,
116
- startTime: moment(date).add(-1, 'day'),
117
- endTime: moment(date),
116
+ startTime: date
117
+ ? moment(date).add(-1, 'day')
118
+ : moment().valueOf(),
119
+ endTime: date ? moment(date) : moment().valueOf(),
118
120
  };
119
121
  }
120
122
  });
@@ -9,7 +9,6 @@ export default StyleSheet.create({
9
9
  columeFlex: {
10
10
  paddingLeft: 16,
11
11
  flexDirection: 'column',
12
- width: '75%',
13
12
  },
14
13
  rowFlex: {
15
14
  flexDirection: 'row',
@@ -1,4 +1,4 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useCallback, useMemo } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -48,6 +48,17 @@ const ShortDetailSubUnit = ({ unit, station }) => {
48
48
 
49
49
  useWatchConfigs(configsNeedWatching);
50
50
 
51
+ const goToPlayBack = useCallback(() => {
52
+ navigate(Routes.PlaybackCamera, {
53
+ item: {
54
+ configuration: station?.camera,
55
+ thumbnail: {
56
+ uri: station?.background,
57
+ },
58
+ },
59
+ });
60
+ }, [navigate, station?.background, station?.camera]);
61
+
51
62
  const renderCamera = () => {
52
63
  if (station?.camera) {
53
64
  return (
@@ -70,6 +81,7 @@ const ShortDetailSubUnit = ({ unit, station }) => {
70
81
  cameraName={station?.camera?.name}
71
82
  width={standardizeWidth}
72
83
  height={standardizeHeight}
84
+ goToPlayBack={goToPlayBack}
73
85
  />
74
86
  </View>
75
87
  );
@@ -58,7 +58,7 @@ const API = {
58
58
  SENSOR_DETAIL: (id) => `/property_manager/sensors/${id}/`,
59
59
  DISPLAY: (id) => `/property_manager/sensors/${id}/display/`,
60
60
  SIDE_MENU_DETAIL: (id, side_menu_id) =>
61
- `/property_manager/sensors/${id}/display/side_menu/${side_menu_id}/`,
61
+ `/property_manager/devices/${id}/display/side_menu/${side_menu_id}/`,
62
62
  DISPLAY_VALUES_V2: (id) =>
63
63
  `/property_manager/sensors/${id}/display_values_v2/`,
64
64
  DISPLAY_HISTORY: (id, hId) =>
@@ -20,6 +20,7 @@ export const Action = {
20
20
  SET_GOOGLE_HOME_CONNECTIONS: 'SET_GOOGLE_HOME_CONNECTIONS',
21
21
  CHANGE_GOOGLE_HOME_CONN_STATE: 'CHANGE_GOOGLE_HOME_CONN_STATE',
22
22
  UPDATE_VALUE_EVALUATIONS: 'UPDATE_VALUE_EVALUATIONS',
23
+ NEED_UPDATE_VALUE_EVALUATIONS: 'NEED_UPDATE_VALUE_EVALUATIONS',
23
24
  ON_RECEIVE_NOTIFICATION: 'ON_RECEIVE_NOTIFICATION',
24
25
  SET_DEVICES_STATUS: 'SET_DEVICES_STATUS',
25
26
  };
@@ -323,6 +323,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
323
323
  currentState.valueEvaluations
324
324
  ),
325
325
  };
326
+ case Action.NEED_UPDATE_VALUE_EVALUATIONS:
327
+ return {
328
+ ...currentState,
329
+ fetchedValueEvaluationUnits:
330
+ currentState.fetchedValueEvaluationUnits.filter(
331
+ // eslint-disable-next-line no-shadow
332
+ (unitId) => unitId !== payload
333
+ ),
334
+ };
326
335
 
327
336
  case Action.ON_RECEIVE_NOTIFICATION:
328
337
  return {
@@ -28,7 +28,7 @@ const mockUseContext = jest.fn().mockImplementation(() => ({
28
28
  React.useContext = mockUseContext;
29
29
 
30
30
  describe('Test useRemoteControl', () => {
31
- let sensor, action, data, userId, actionName;
31
+ let sensor, action, data, userId;
32
32
 
33
33
  beforeEach(() => {
34
34
  sendCommandOverBluetooth.mockClear();
@@ -51,7 +51,6 @@ describe('Test useRemoteControl', () => {
51
51
  };
52
52
  data = null;
53
53
  userId = 1;
54
- actionName = 'action name';
55
54
  });
56
55
 
57
56
  it('test send remote command action null', async () => {
@@ -60,7 +59,7 @@ describe('Test useRemoteControl', () => {
60
59
  wrapper,
61
60
  });
62
61
  act(() => {
63
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
62
+ sendRemoteCommand.current(sensor, action, data, userId);
64
63
  });
65
64
  expect(sendCommandOverInternet).not.toBeCalled();
66
65
  expect(sendCommandOverGoogleHome).not.toBeCalled();
@@ -75,7 +74,7 @@ describe('Test useRemoteControl', () => {
75
74
 
76
75
  sendCommandOverBluetooth.mockImplementation(async () => true);
77
76
  act(() => {
78
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
77
+ sendRemoteCommand.current(sensor, action, data, userId);
79
78
  });
80
79
  expect(sendCommandOverBluetooth).toBeCalledWith(
81
80
  sensor,
@@ -98,7 +97,7 @@ describe('Test useRemoteControl', () => {
98
97
  });
99
98
  sendCommandOverInternet.mockImplementation(async () => true);
100
99
  act(() => {
101
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
100
+ sendRemoteCommand.current(sensor, action, data, userId);
102
101
  });
103
102
  expect(sendCommandOverBluetooth).toBeCalledWith(
104
103
  sensor,
@@ -110,8 +109,7 @@ describe('Test useRemoteControl', () => {
110
109
  sensor,
111
110
  action,
112
111
  data,
113
- 'bluetooth',
114
- actionName
112
+ 'bluetooth'
115
113
  );
116
114
  expect(sendCommandOverInternet).toBeCalledTimes(1);
117
115
  expect(sendCommandOverGoogleHome).not.toBeCalled();
@@ -128,7 +126,7 @@ describe('Test useRemoteControl', () => {
128
126
  });
129
127
  sendCommandOverInternet.mockImplementation(async () => true);
130
128
  act(() => {
131
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
129
+ sendRemoteCommand.current(sensor, action, data, userId);
132
130
  });
133
131
  expect(sendCommandOverBluetooth).toBeCalledWith(
134
132
  sensor,
@@ -150,7 +148,7 @@ describe('Test useRemoteControl', () => {
150
148
 
151
149
  sendCommandOverInternet.mockImplementation(async () => true);
152
150
  act(() => {
153
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
151
+ sendRemoteCommand.current(sensor, action, data, userId);
154
152
  });
155
153
  expect(sendCommandOverInternet).toBeCalledWith(
156
154
  sensor,
@@ -172,7 +170,7 @@ describe('Test useRemoteControl', () => {
172
170
 
173
171
  sendCommandOverGoogleHome.mockImplementation(async () => true);
174
172
  act(() => {
175
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
173
+ sendRemoteCommand.current(sensor, action, data, userId);
176
174
  });
177
175
  expect(sendCommandOverGoogleHome).toBeCalledWith({}, sensor, action, data);
178
176
  expect(sendCommandOverBluetooth).not.toBeCalled();
@@ -189,7 +187,7 @@ describe('Test useRemoteControl', () => {
189
187
 
190
188
  sendCommandOverLGThinq.mockImplementation(async () => true);
191
189
  act(() => {
192
- sendRemoteCommand.current(sensor, action, data, userId, actionName);
190
+ sendRemoteCommand.current(sensor, action, data, userId);
193
191
  });
194
192
  expect(sendCommandOverBluetooth).not.toBeCalled();
195
193
  expect(sendCommandOverGoogleHome).not.toBeCalled();
@@ -15,7 +15,7 @@ const useRemoteControl = () => {
15
15
  );
16
16
 
17
17
  const sendRemoteCommand = useCallback(
18
- async (sensor, action, data, userId, actionName) => {
18
+ async (sensor, action, data, userId) => {
19
19
  // No action, raise not authorized
20
20
  let result = false;
21
21
 
@@ -36,8 +36,7 @@ const useRemoteControl = () => {
36
36
  sensor,
37
37
  action,
38
38
  data,
39
- 'bluetooth',
40
- actionName
39
+ 'bluetooth'
41
40
  );
42
41
  } else {
43
42
  throw err;
@@ -4,13 +4,7 @@ import { ToastBottomHelper } from '../../utils/Utils';
4
4
  import { axiosPost } from '../../utils/Apis/axios';
5
5
  import { API } from '../../configs';
6
6
 
7
- export const sendCommandOverInternet = async (
8
- sensor,
9
- action,
10
- data,
11
- source,
12
- actionName
13
- ) => {
7
+ export const sendCommandOverInternet = async (sensor, action, data, source) => {
14
8
  if (data !== null) {
15
9
  if (Number.isInteger(data)) {
16
10
  data = data.toString(16).toUpperCase();
@@ -21,7 +15,6 @@ export const sendCommandOverInternet = async (
21
15
  key: action.key,
22
16
  data,
23
17
  source,
24
- action_name: actionName,
25
18
  });
26
19
  if (success) {
27
20
  ToastBottomHelper.success(t('Command is sent to device via internet'));
@@ -120,6 +120,17 @@ export const UnitStack = memo((props) => {
120
120
  };
121
121
  }, []);
122
122
 
123
+ useEffect(() => {
124
+ return () => {
125
+ const id = unitId || unitData?.id;
126
+ if (!id) {
127
+ return;
128
+ }
129
+ setAction(Action.NEED_UPDATE_VALUE_EVALUATIONS, id);
130
+ };
131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
132
+ }, []);
133
+
123
134
  return (
124
135
  <Stack.Navigator
125
136
  screenOptions={{
@@ -44,8 +44,8 @@ export const SensorDisplayItem = ({
44
44
  const sendRemoteCommand = useRemoteControl();
45
45
 
46
46
  const doAction = useCallback(
47
- (action, data, actionName) => {
48
- sendRemoteCommand(sensor, action, data, userId, actionName);
47
+ (action, data) => {
48
+ sendRemoteCommand(sensor, action, data, userId);
49
49
  },
50
50
  [sensor, userId, sendRemoteCommand]
51
51
  );
@@ -363,13 +363,6 @@ const DeviceDetail = ({ route }) => {
363
363
  text: t('auto_lock'),
364
364
  });
365
365
  }
366
- menuItems.push({
367
- route: Routes.SmartLockStack,
368
- data: {
369
- screen: Routes.SetupGeneratePasscode,
370
- },
371
- text: t('setup_generate_passcode'),
372
- });
373
366
  if (isOwner && isShowSetUpSmartLock) {
374
367
  menuItems.push({
375
368
  route: Routes.SmartLockStack,
@@ -62,6 +62,16 @@ const PlayBackCamera = () => {
62
62
  dateTemp = date;
63
63
  }, [selected]);
64
64
 
65
+ const getHourWithTimeZone = useCallback(
66
+ // eslint-disable-next-line no-shadow
67
+ (hour) => {
68
+ const hourWithTimezone =
69
+ parseInt(hour, 10) + parseInt(item?.configuration?.time_zone || 0, 10);
70
+ return hourWithTimezone < 10 ? '0' + hourWithTimezone : hourWithTimezone;
71
+ },
72
+ [item?.configuration?.time_zone]
73
+ );
74
+
65
75
  const onChangeValue = useCallback(
66
76
  (value, selectedTime) => {
67
77
  if (!isFirstTime) {
@@ -87,7 +97,7 @@ const PlayBackCamera = () => {
87
97
  setUri(
88
98
  `${playback.split('=')[0]}=${date[0]}${date[1]}${
89
99
  date[2]
90
- }T${h}${m}${s}Z`
100
+ }T${getHourWithTimeZone(h)}${m}${s}Z`
91
101
  );
92
102
  }
93
103
  const to = setTimeout(() => {
@@ -96,7 +106,13 @@ const PlayBackCamera = () => {
96
106
  }, 100);
97
107
  }
98
108
  },
99
- [arrHourTemp, item?.configuration, now]
109
+ [
110
+ arrHourTemp,
111
+ getHourWithTimeZone,
112
+ item?.configuration?.playback,
113
+ item?.configuration?.uri,
114
+ now,
115
+ ]
100
116
  );
101
117
 
102
118
  useEffect(() => {
@@ -111,9 +127,9 @@ const PlayBackCamera = () => {
111
127
  setUri(item?.configuration?.uri);
112
128
  } else {
113
129
  setUri(
114
- `${playback.split('=')[0]}=${date[0]}${date[1]}${date[2]}T${hour.h}${
115
- hour.m
116
- }${hour.s}Z`
130
+ `${playback.split('=')[0]}=${date[0]}${date[1]}${
131
+ date[2]
132
+ }T${getHourWithTimeZone(hour.h)}${hour.m}${hour.s}Z`
117
133
  );
118
134
  }
119
135
  const to = setTimeout(() => {
@@ -121,7 +137,7 @@ const PlayBackCamera = () => {
121
137
  clearTimeout(to);
122
138
  }, 100);
123
139
  // eslint-disable-next-line react-hooks/exhaustive-deps
124
- }, [selected]);
140
+ }, [selected, getHourWithTimeZone]);
125
141
 
126
142
  useEffect(() => {
127
143
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -67,7 +67,7 @@ const styles = StyleSheet.create({
67
67
  borderRadius: 16,
68
68
  justifyContent: 'center',
69
69
  alignItems: 'center',
70
- marginLeft: 10,
70
+ marginLeft: 5,
71
71
  },
72
72
  nameDevice: {
73
73
  fontSize: 14,
@@ -81,6 +81,7 @@ const styles = StyleSheet.create({
81
81
  roomDevicePart: {
82
82
  fontSize: 12,
83
83
  lineHeight: 20,
84
+ width: '100%',
84
85
  },
85
86
  rowCenter: {
86
87
  flexDirection: 'row',