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

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 (44) 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 +8 -10
  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/configs/Constants.js +4 -0
  27. package/src/context/actionType.ts +1 -0
  28. package/src/context/reducer.ts +9 -0
  29. package/src/hooks/IoT/__test__/useRemoteControl.test.js +9 -11
  30. package/src/hooks/IoT/useRemoteControl.js +2 -3
  31. package/src/iot/RemoteControl/Internet.js +1 -8
  32. package/src/navigations/UnitStack.js +11 -0
  33. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  34. package/src/screens/Device/detail.js +0 -7
  35. package/src/screens/GuestInfo/index.js +11 -4
  36. package/src/screens/GuestInfo/styles/indexStyles.js +7 -0
  37. package/src/screens/ManageAccess/index.js +14 -5
  38. package/src/screens/ManageAccess/styles/ManageAccessStyles.js +9 -0
  39. package/src/screens/PlayBackCamera/Timer.js +3 -0
  40. package/src/screens/PlayBackCamera/__test__/index.test.js +8 -1
  41. package/src/screens/PlayBackCamera/index.js +86 -49
  42. package/src/screens/Unit/Detail.js +16 -10
  43. package/src/screens/Unit/components/MyUnitDevice/index.js +2 -1
  44. package/src/screens/Unit/components/__test__/AutomateScript.test.js +116 -0
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.26",
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]);
@@ -12,11 +12,11 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
12
12
  const t = useTranslations();
13
13
  const { configuration } = actionGroup;
14
14
  const [valueBrightness, setValueBrightness] = useState(0);
15
+ const [valueBrightnessTemp, setValueBrightnessTemp] = useState(0);
15
16
  const [configValues] = useConfigGlobalState('configValues');
16
17
 
17
18
  const onChangeBrightness = useCallback(
18
19
  (value) => {
19
- setValueBrightness(value);
20
20
  doAction(
21
21
  configuration?.action_brightness_data,
22
22
  JSON.stringify({ value_brness: value })
@@ -26,19 +26,17 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
26
26
  );
27
27
 
28
28
  const percentBrightness = useMemo(() => {
29
- return valueBrightness || 0;
30
- }, [valueBrightness]);
29
+ return valueBrightnessTemp || valueBrightness || 0;
30
+ }, [valueBrightness, valueBrightnessTemp]);
31
31
 
32
32
  useEffect(() => {
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 && valueBrightness >= 0) {
37
+ setValueBrightness(valueBrness);
39
38
  }
40
- setValueBrightness(valueTemp);
41
- }, [configuration.config, configValues, configuration]);
39
+ }, [configuration.config, configValues, configuration, valueBrightness]);
42
40
 
43
41
  return (
44
42
  <View style={styles.viewBrightness}>
@@ -51,9 +49,9 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
51
49
  <View style={styles.RightBrightness}>
52
50
  <View style={styles.slider}>
53
51
  <SliderRange
54
- value={valueBrightness}
52
+ value={valueBrightnessTemp}
55
53
  onSlidingComplete={onChangeBrightness}
56
- onValueChange={setValueBrightness}
54
+ onValueChange={setValueBrightnessTemp}
57
55
  step={1}
58
56
  minimumValue={0}
59
57
  maximumValue={100}
@@ -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 () => {