@eohjsc/react-native-smart-city 0.2.96 → 0.2.99

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 (109) hide show
  1. package/README.md +35 -14
  2. package/package.json +16 -4
  3. package/src/commons/Action/ItemQuickAction.js +5 -2
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
  7. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  8. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  9. package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
  10. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +8 -2
  11. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  12. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
  13. package/src/commons/ActionGroup/StatesGridActionTemplate.js +14 -4
  14. package/src/commons/ActionGroup/TimerActionTemplate.js +9 -1
  15. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
  16. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  17. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  18. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  19. package/src/commons/Auth/AccountList.js +1 -1
  20. package/src/commons/{Connecting → Connecting}/__test__/Connecting.test.js +0 -0
  21. package/src/commons/{Connecting → Connecting}/index.js +0 -0
  22. package/src/commons/{Connecting → Connecting}/styles.js +0 -0
  23. package/src/commons/ConnectingProcess/index.js +1 -1
  24. package/src/commons/Device/HistoryChart.js +6 -2
  25. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  26. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  27. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  28. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  29. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  30. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  31. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +113 -0
  32. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  33. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  34. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +93 -0
  35. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  36. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  37. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +182 -0
  38. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  39. package/src/commons/FullLoading/index.js +2 -1
  40. package/src/commons/MenuActionAddnew/index.js +1 -0
  41. package/src/commons/MenuActionList/index.js +1 -0
  42. package/src/commons/MenuActionMore/index.js +1 -1
  43. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  44. package/src/commons/PreventAccess/index.js +67 -0
  45. package/src/commons/PreventAccess/styles.js +33 -0
  46. package/src/commons/WheelDateTimePicker/index.js +2 -1
  47. package/src/configs/API.js +3 -0
  48. package/src/configs/Constants.js +16 -1
  49. package/src/iot/RemoteControl/GoogleHome.js +24 -11
  50. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +32 -0
  51. package/src/navigations/UnitStack.js +8 -0
  52. package/src/screens/AQIGuide/index.js +1 -1
  53. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  54. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  55. package/src/screens/AddCommon/SelectUnit.js +1 -0
  56. package/src/screens/AddLocationMaps/index.js +4 -1
  57. package/src/screens/AddNewAction/SelectSensorDevices.js +14 -3
  58. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +34 -92
  59. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  60. package/src/screens/AddNewAutoSmart/index.js +5 -2
  61. package/src/screens/AddNewDevice/index.js +1 -0
  62. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +1 -1
  63. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
  64. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  65. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  66. package/src/screens/AddNewGateway/index.js +1 -0
  67. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +1 -1
  68. package/src/screens/AddNewOneTap/index.js +3 -2
  69. package/src/screens/Automate/index.js +2 -0
  70. package/src/screens/Device/__test__/detail.test.js +4 -4
  71. package/src/screens/Device/detail.js +44 -6
  72. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -2
  73. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +14 -0
  74. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +19 -1
  75. package/src/screens/EmergencySetting/index.js +4 -1
  76. package/src/screens/Explore/index.js +2 -0
  77. package/src/screens/GuestInfo/__test__/index.test.js +1 -1
  78. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  79. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  80. package/src/screens/ManageAccess/index.js +1 -0
  81. package/src/screens/MoveToAnotherSubUnit/index.js +1 -1
  82. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  83. package/src/screens/ScriptDetail/index.js +3 -3
  84. package/src/screens/SelectUnit/__test__/index.test.js +1 -1
  85. package/src/screens/SelectUnit/index.js +5 -2
  86. package/src/screens/SetSchedule/index.js +6 -2
  87. package/src/screens/SharedUnit/index.js +2 -0
  88. package/src/screens/Sharing/MemberList.js +12 -11
  89. package/src/screens/Sharing/SelectPermission.js +1 -1
  90. package/src/screens/Sharing/hooks/index.js +3 -0
  91. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  92. package/src/screens/SideMenuDetail/__test__/index.test.js +165 -0
  93. package/src/screens/SideMenuDetail/index.js +149 -0
  94. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  95. package/src/screens/SubUnit/ManageSubUnit.js +1 -0
  96. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  97. package/src/screens/TDSGuide/index.js +4 -1
  98. package/src/screens/UVIndexGuide/index.js +1 -1
  99. package/src/screens/Unit/Detail.js +18 -5
  100. package/src/screens/Unit/SelectAddress.js +4 -1
  101. package/src/screens/Unit/Station/index.js +1 -0
  102. package/src/screens/Unit/Summaries.js +1 -1
  103. package/src/screens/Unit/__test__/Detail.test.js +25 -5
  104. package/src/screens/UnitSummary/__test__/index.test.js +32 -0
  105. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +1 -1
  106. package/src/screens/WaterQualityGuide/index.js +1 -1
  107. package/src/utils/I18n/translations/en.json +5 -1
  108. package/src/utils/I18n/translations/vi.json +5 -1
  109. package/src/utils/Route/index.js +1 -0
package/README.md CHANGED
@@ -1,19 +1,26 @@
1
1
  ## react-native-smart-city
2
2
 
3
3
  ## Getting started
4
+
4
5
  1. Install package dependencies:
5
- - Using [Yarn](https://yarnpkg.com/): `yarn add react-native-reanimated@^1.10.1`
6
+
7
+ - Using [Yarn](https://yarnpkg.com/): `yarn add react-native-reanimated@^1.10.1`
6
8
 
7
9
  2. Install:
8
- - Using [npm](https://www.npmjs.com/#getting-started): `npm install @eohjsc/react-native-smart-city --save`
9
- - Using [Yarn](https://yarnpkg.com/): `yarn add @eohjsc/react-native-smart-city`
10
+
11
+ - Using [npm](https://www.npmjs.com/#getting-started): `npm install @eohjsc/react-native-smart-city --save`
12
+ - Using [Yarn](https://yarnpkg.com/): `yarn add @eohjsc/react-native-smart-city`
10
13
 
11
14
  3. Compile application using react-native run-android
15
+
12
16
  ### Mostly automatic installation
17
+
13
18
  `$ react-native link @eohjsc/react-native-smart-city`
14
19
 
15
20
  ## Usage
21
+
16
22
  1. StackNavigator
23
+
17
24
  ```javascript
18
25
  import {
19
26
  UnitStack,
@@ -30,7 +37,7 @@ import {
30
37
  } from '@eohjsc/react-native-smart-city';
31
38
  import { createStackNavigator } from '@react-navigation/stack';
32
39
 
33
- // TODO: What to do with the module?
40
+ // TODO: What to do with the module?
34
41
  const Stack = createStackNavigator();
35
42
 
36
43
  const YourStack = () => {
@@ -84,7 +91,9 @@ const MainTab = () => {
84
91
  );
85
92
  };
86
93
  ```
94
+
87
95
  2. Use components
96
+
88
97
  ```javascript
89
98
  import React from 'react';
90
99
  import { View } from 'react-native';
@@ -93,13 +102,15 @@ import { MyPinnedSharedUnit, MyUnit } from '@eohjsc/react-native-smart-city';
93
102
  const MyScreen = () => {
94
103
  return (
95
104
  <View>
96
- <MyUnit />
97
- <MyPinnedSharedUnit />
105
+ <MyUnit />
106
+ <MyPinnedSharedUnit />
98
107
  </View>
99
108
  );
100
109
  };
101
110
  ```
111
+
102
112
  3. Trigger quick action
113
+
103
114
  ```javascript
104
115
  import React from 'react';
105
116
  import { View, Button } from 'react-native';
@@ -126,23 +137,33 @@ export const MyFunctionalComponent = () => {
126
137
  lg_actions: [],
127
138
  name: 'Garage Up',
128
139
  };
129
- const handleQuickAction = async() => {
140
+ const handleQuickAction = async () => {
130
141
  const result = await sendRemoteCommand(sensor, action); // Action Garage Up
131
- if (result){
132
- console.log('Successful control')
133
- }else {
134
- console.log('Control failed')
142
+ if (result) {
143
+ console.log('Successful control');
144
+ } else {
145
+ console.log('Control failed');
135
146
  }
136
147
  };
137
148
  return (
138
149
  <View>
139
- <Button onPress={handleQuickAction} title="Example trigger quick action control Garage Up" />
150
+ <Button
151
+ onPress={handleQuickAction}
152
+ title="Example trigger quick action control Garage Up"
153
+ />
140
154
  </View>
141
155
  );
142
156
  };
143
157
  ```
144
- - sendRemoteCommand user needs to `have permission to control the device`, you pass in the `sensor and action` to it and it will run after calling render.
145
- - `sensor` is a device in your Unit and action is the `action` key of the device..
158
+
159
+ - sendRemoteCommand user needs to `have permission to control the device`, you pass in the `sensor and action` to it and it will run after calling render.
160
+ - `sensor` is a device in your Unit and action is the `action` key of the device..
146
161
  - You can take out the sensor and action from your Unit when calling the `API.UNIT.UNIT_DETAIL(unitId)` it will return all devices in 1 unit.
147
162
  - Or get sensor from `API.SENSOR.DISPLAY(sensor.id)` returns all actions of 1 device.
148
163
  - Refer YourProjectPath /node_modules/@eohjsc/react-native-smart-city/src/screens/Unit/Detail.js
164
+
165
+ ## Sync file to EoH source
166
+
167
+ ```
168
+ yarn install && yarn watch
169
+ ```
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.2.96",
4
+ "version": "0.2.99",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -81,10 +81,11 @@
81
81
  "eslint-plugin-react": "^7.21.5",
82
82
  "eslint-plugin-react-native": "^3.10.0",
83
83
  "factory-girl": "^5.0.4",
84
+ "husky": "^8.0.1",
84
85
  "jest": "^26.6.3",
85
86
  "jest-circus": "^26.6.3",
86
87
  "jetifier": "^1.6.6",
87
- "lint-staged": "^8.2.1",
88
+ "lint-staged": "^12.4.1",
88
89
  "metro-react-native-babel-preset": "^0.66.2",
89
90
  "node-html-parser": "^2.0.2",
90
91
  "react": "17.0.2",
@@ -97,6 +98,7 @@
97
98
  "dependencies": {
98
99
  "@ant-design/icons-react-native": "^2.2.1",
99
100
  "@ant-design/react-native": "^4.0.5",
101
+ "@babel/helper-environment-visitor": "^7.16.7",
100
102
  "@eohjsc/highcharts": "^1.0.8",
101
103
  "@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
102
104
  "@formatjs/intl-getcanonicallocales": "^1.4.5",
@@ -188,7 +190,7 @@
188
190
  "react-native-unimodules": "^0.11.0",
189
191
  "react-native-version-check": "^3.4.2",
190
192
  "react-native-vlc-media-player": "^1.0.39",
191
- "react-native-webview": "^10.9.3",
193
+ "react-native-webview": "11.17.2",
192
194
  "react-native-wheel-color-picker": "^1.2.0",
193
195
  "react-native-wheel-scrollview-picker": "^1.2.2",
194
196
  "react-native-wifi-reborn": "^4.5.0",
@@ -209,5 +211,15 @@
209
211
  "bugs": {
210
212
  "url": "https://github.com/github_account/react-native-smart-city/issues"
211
213
  },
212
- "homepage": "https://github.com/github_account/react-native-smart-city#readme"
214
+ "homepage": "https://github.com/github_account/react-native-smart-city#readme",
215
+ "husky": {
216
+ "hooks": {
217
+ "pre-commit": "lint-staged"
218
+ }
219
+ },
220
+ "lint-staged": {
221
+ "*.{js, ts}": [
222
+ "yarn lint"
223
+ ]
224
+ }
213
225
  }
@@ -43,8 +43,9 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus, unit }) => {
43
43
  useEffect(() => {
44
44
  sensor.quick_action &&
45
45
  sensor.quick_action.config_id &&
46
+ sensor.device_type !== 'GOOGLE_HOME' &&
46
47
  watchMultiConfigs([sensor.quick_action.config_id]);
47
- }, [sensor.quick_action]);
48
+ }, [sensor.quick_action, sensor?.device_type]);
48
49
 
49
50
  useEffect(() => {
50
51
  if (!sensor.quick_action) {
@@ -59,7 +60,9 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus, unit }) => {
59
60
  const userId = useSCContextSelector((state) => state?.auth.account.user.id);
60
61
  const onActionPress = useCallback(() => {
61
62
  sendRemoteCommand(sensor, action, null, userId);
62
- sensor.quick_action && watchMultiConfigs([sensor.quick_action.config_id]);
63
+ sensor.quick_action &&
64
+ sensor.device_type !== 'GOOGLE_HOME' &&
65
+ watchMultiConfigs([sensor.quick_action.config_id]);
63
66
  setIsSendingCommand(true);
64
67
 
65
68
  if (!sensor.quick_action) {
@@ -35,7 +35,7 @@ const ColorPickerTemplate = memo(({ actionGroup, doAction, sensor }) => {
35
35
  }, [configuration.config, configValues, configuration]);
36
36
 
37
37
  useEffect(() => {
38
- if (sensor?.is_managed_by_backend) {
38
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
39
39
  watchMultiConfigs([configuration.config]);
40
40
  }
41
41
  }, [sensor, configuration.config]);
@@ -38,8 +38,8 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
38
38
  }, [configValues, config, keep_track_config]);
39
39
 
40
40
  const doActionAndWatchConfig = useCallback(
41
- (actionData, actionValue, actionName) => {
42
- doAction(
41
+ async (actionData, actionValue, actionName) => {
42
+ await doAction(
43
43
  actionData,
44
44
  JSON.stringify({ temperature: actionValue }),
45
45
  actionName
@@ -54,9 +54,17 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
54
54
  return;
55
55
  }
56
56
 
57
- config && watchMultiConfigs([config]);
57
+ config &&
58
+ sensor.device_type !== 'GOOGLE_HOME' &&
59
+ watchMultiConfigs([config]);
58
60
  },
59
- [config, doAction, keep_track_config, sensor.is_managed_by_backend]
61
+ [
62
+ config,
63
+ doAction,
64
+ keep_track_config,
65
+ sensor.is_managed_by_backend,
66
+ sensor.device_type,
67
+ ]
60
68
  );
61
69
 
62
70
  const doActionUp = useCallback(async () => {
@@ -17,7 +17,7 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
17
17
  const [isUnlock, setisUnlock] = useState(true);
18
18
  const [configValues] = useConfigGlobalState('configValues');
19
19
 
20
- const handleActionSmartLock = useCallback(() => {
20
+ const handleActionSmartLock = useCallback(async () => {
21
21
  if (action_on_data && action_off_data) {
22
22
  if (isUnlock) {
23
23
  let actionName = `${
@@ -25,17 +25,19 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
25
25
  } ${actionGroup?.title?.toLowerCase()} lock`;
26
26
  actionName = actionName.replace(/\s+/g, ' ').trim();
27
27
  const dataLock = { door_lock: 0 };
28
- doAction(action_on_data, JSON.stringify(dataLock), actionName);
28
+ await doAction(action_on_data, JSON.stringify(dataLock), actionName);
29
29
  } else {
30
30
  let actionName = `${
31
31
  sensor?.name
32
32
  } ${actionGroup?.title?.toLowerCase()} unlock`;
33
33
  actionName = actionName.replace(/\s+/g, ' ').trim();
34
34
  const dataUnlock = { door_lock: 1 };
35
- doAction(action_off_data, JSON.stringify(dataUnlock), actionName);
35
+ await doAction(action_off_data, JSON.stringify(dataUnlock), actionName);
36
36
  }
37
37
  if (sensor?.is_managed_by_backend) {
38
- configuration.config && watchMultiConfigs([configuration.config]);
38
+ configuration.config &&
39
+ sensor.device_type !== 'GOOGLE_HOME' &&
40
+ watchMultiConfigs([configuration.config]);
39
41
  }
40
42
  }
41
43
  }, [
@@ -47,6 +49,7 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
47
49
  sensor?.name,
48
50
  configuration,
49
51
  sensor?.is_managed_by_backend,
52
+ sensor?.device_type,
50
53
  ]);
51
54
 
52
55
  useEffect(() => {
@@ -180,6 +180,7 @@ const SetupGeneratePasscode = memo(() => {
180
180
  showsVerticalScrollIndicator={false}
181
181
  showsHorizontalScrollIndicator={false}
182
182
  style={styles.scrollview}
183
+ scrollIndicatorInsets={{ right: 1 }}
183
184
  >
184
185
  <View style={styles.wrap}>
185
186
  <ButtonWrapper
@@ -12,22 +12,22 @@ const OnOffSimpleTemplate = ({
12
12
  actionGroup,
13
13
  disabled,
14
14
  }) => {
15
- const isEnabled = !!isOn;
16
-
17
15
  return (
18
16
  <View style={styles.wrap}>
19
17
  <View style={styles.iconAndText}>
20
18
  <IconOutline name="poweroff" size={20} style={styles.marginRight} />
21
19
  <Text type="H4">{actionGroup.title}</Text>
22
20
  </View>
23
- <Switch
24
- trackColor={{ false: Colors.Gray4, true: Colors.Primary }}
25
- thumbColor={isEnabled ? Colors.White : Colors.Gray6}
26
- ios_backgroundColor={Colors.Gray4}
27
- onValueChange={triggerAction}
28
- value={isEnabled}
29
- disabled={disabled}
30
- />
21
+ {isOn !== null && (
22
+ <Switch
23
+ trackColor={{ false: Colors.Gray4, true: Colors.Primary }}
24
+ thumbColor={isOn ? Colors.White : Colors.Gray6}
25
+ ios_backgroundColor={Colors.Gray4}
26
+ onValueChange={triggerAction}
27
+ value={!!isOn}
28
+ disabled={disabled}
29
+ />
30
+ )}
31
31
  </View>
32
32
  );
33
33
  };
@@ -20,7 +20,8 @@ const getComponent = (template) => {
20
20
  const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
21
21
  const { configuration } = actionGroup;
22
22
  const { action_data, action_on_data, action_off_data } = configuration;
23
- const [isOn, setIsOn] = useState(true);
23
+ const [isOn, setIsOn] = useState(null);
24
+
24
25
  // eslint-disable-next-line no-unused-vars
25
26
  const [configValues, _] = useConfigGlobalState('configValues');
26
27
 
@@ -33,51 +34,53 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
33
34
  },
34
35
  [actionGroup?.title, sensor?.name]
35
36
  );
36
- const triggerAction = useCallback(() => {
37
+ const triggerAction = useCallback(async () => {
37
38
  switch (sensor?.device_type) {
38
39
  case DEVICE_TYPE.ZIGBEE:
39
40
  if (action_on_data && action_off_data) {
40
41
  if (isOn) {
41
- doAction(
42
+ await doAction(
42
43
  action_off_data,
43
44
  JSON.stringify({ state: 0 }),
44
45
  actionName('off')
45
46
  );
46
47
  } else {
47
- doAction(
48
+ await doAction(
48
49
  action_on_data,
49
50
  JSON.stringify({ state: 1 }),
50
51
  actionName('on')
51
52
  );
52
53
  }
53
54
  }
54
- return;
55
+ break;
55
56
  default:
56
57
  if (action_data) {
57
58
  if (isOn) {
58
- doAction(action_data, false);
59
+ await doAction(action_data, false);
59
60
  } else {
60
- doAction(action_data, true);
61
+ await doAction(action_data, true);
61
62
  }
62
63
  }
63
64
  if (action_on_data && action_off_data) {
64
65
  if (isOn) {
65
- doAction(action_off_data, null, actionName('off'));
66
+ await doAction(action_off_data, null, actionName('off'));
66
67
  } else {
67
- doAction(action_on_data, null, actionName('on'));
68
+ await doAction(action_on_data, null, actionName('on'));
68
69
  }
69
70
  }
70
- if (sensor?.is_managed_by_backend) {
71
- configuration.config && watchMultiConfigs([configuration.config]);
72
- }
73
- return;
71
+ break;
72
+ }
73
+ if (sensor?.is_managed_by_backend) {
74
+ configuration?.config &&
75
+ sensor?.device_type !== 'GOOGLE_HOME' &&
76
+ watchMultiConfigs([configuration?.config]);
74
77
  }
75
78
  }, [
76
79
  actionName,
77
80
  action_data,
78
81
  action_off_data,
79
82
  action_on_data,
80
- configuration.config,
83
+ configuration?.config,
81
84
  doAction,
82
85
  isOn,
83
86
  sensor?.device_type,
@@ -103,7 +106,7 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
103
106
  if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
104
107
  return;
105
108
  }
106
- if (sensor?.is_managed_by_backend) {
109
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
107
110
  watchMultiConfigs([configuration.config]);
108
111
  }
109
112
  }, [sensor, configuration.config]);
@@ -67,7 +67,9 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
67
67
  actionName
68
68
  );
69
69
  if (sensor?.is_managed_by_backend) {
70
- configuration.config && watchMultiConfigs([configuration.config]);
70
+ configuration.config &&
71
+ sensor.device_type !== 'GOOGLE_HOME' &&
72
+ watchMultiConfigs([configuration.config]);
71
73
  }
72
74
  hideAlertAction();
73
75
  }, [
@@ -79,6 +81,7 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
79
81
  selectedIndex,
80
82
  sensor?.is_managed_by_backend,
81
83
  sensor?.name,
84
+ sensor?.device_type,
82
85
  title,
83
86
  ]);
84
87
 
@@ -145,7 +148,10 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
145
148
  rightButtonClick={onDone}
146
149
  >
147
150
  <View style={styles.wrapRename}>
148
- <ScrollView style={styles.scrollView}>
151
+ <ScrollView
152
+ style={styles.scrollView}
153
+ scrollIndicatorInsets={{ right: 1 }}
154
+ >
149
155
  {!action_data && (
150
156
  <Text
151
157
  color={Colors.Gray6}
@@ -37,7 +37,7 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
37
37
  }, [configuration.config, configValues, configuration]);
38
38
 
39
39
  useEffect(() => {
40
- if (sensor?.is_managed_by_backend) {
40
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
41
41
  watchMultiConfigs([configuration.config]);
42
42
  }
43
43
  }, [sensor, configuration.config]);
@@ -91,7 +91,10 @@ const SmartTiviActionTemplate = memo(
91
91
  }, []);
92
92
  return (
93
93
  <>
94
- <ScrollView scrollEnabled={scrollEnabled}>
94
+ <ScrollView
95
+ scrollEnabled={scrollEnabled}
96
+ scrollIndicatorInsets={{ right: 1 }}
97
+ >
95
98
  <View style={styles.wrap}>
96
99
  <View style={styles.rowOnOff}>
97
100
  <CircleButton
@@ -45,10 +45,20 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
45
45
  actionName = actionName.replace(/\s+/g, ' ').trim();
46
46
  doAction(actionData, null, actionName);
47
47
  if (sensor?.is_managed_by_backend) {
48
- config && watchMultiConfigs([config]);
48
+ config &&
49
+ sensor.device_type !== 'GOOGLE_HOME' &&
50
+ watchMultiConfigs([config]);
49
51
  }
50
52
  },
51
- [config, doAction, sensor?.is_managed_by_backend, sensor?.name, text, title]
53
+ [
54
+ config,
55
+ doAction,
56
+ sensor?.is_managed_by_backend,
57
+ sensor?.name,
58
+ sensor?.device_type,
59
+ text,
60
+ title,
61
+ ]
52
62
  );
53
63
 
54
64
  const iconKit = !!icon_kit_data && icon_kit_data.icon;
@@ -114,10 +124,10 @@ const StatesGridActionTemplate = ({ actionGroup, doAction, sensor }) => {
114
124
  }, [configuration, configValues]);
115
125
 
116
126
  useEffect(() => {
117
- if (sensor?.is_managed_by_backend) {
127
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
118
128
  watchMultiConfigs(configuration.options.map((option) => option.config));
119
129
  }
120
- }, [sensor.is_managed_by_backend, configuration.options]);
130
+ }, [sensor.is_managed_by_backend, sensor.device_type, configuration.options]);
121
131
 
122
132
  return (
123
133
  <View style={styles.wrap}>
@@ -94,6 +94,7 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
94
94
  if (sensor.is_managed_by_backend) {
95
95
  hour !== undefined &&
96
96
  minute !== undefined &&
97
+ sensor.device_type !== 'GOOGLE_HOME' &&
97
98
  watchMultiConfigs([
98
99
  configuration.config_hour,
99
100
  configuration.config_minute,
@@ -106,13 +107,17 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
106
107
  configuration.config_minute,
107
108
  doAction,
108
109
  sensor.is_managed_by_backend,
110
+ sensor.device_type,
109
111
  ]
110
112
  );
111
113
 
112
114
  const doActionHour = useCallback(
113
115
  (hour) => {
114
116
  doAction(configuration.action_data, hour);
115
- if (sensor.is_managed_by_backend) {
117
+ if (
118
+ sensor.is_managed_by_backend &&
119
+ sensor.device_type !== 'GOOGLE_HOME'
120
+ ) {
116
121
  hour && watchMultiConfigs([configuration.config_hour]);
117
122
  }
118
123
  },
@@ -121,6 +126,7 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
121
126
  configuration.config_hour,
122
127
  doAction,
123
128
  sensor.is_managed_by_backend,
129
+ sensor.device_type,
124
130
  ]
125
131
  );
126
132
 
@@ -201,6 +207,8 @@ const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
201
207
  onConfirm={onConfirmTime}
202
208
  onCancel={onHideTime}
203
209
  display="spinner"
210
+ cancelTextIOS={t('cancel')}
211
+ confirmTextIOS={t('confirm')}
204
212
  />
205
213
  <BottomScrollPicker
206
214
  min={configuration.min}
@@ -28,16 +28,18 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
28
28
  [actionGroup?.title, sensor?.name]
29
29
  );
30
30
 
31
- const triggerAction1 = useCallback(() => {
31
+ const triggerAction1 = useCallback(async () => {
32
32
  if (button1?.action_on_data && button1?.action_off_data) {
33
33
  if (isOn) {
34
- doAction(button1?.action_off_data, null, actionName('off'));
34
+ await doAction(button1?.action_off_data, null, actionName('off'));
35
35
  } else {
36
- doAction(button1?.action_on_data, null, actionName('on'));
36
+ await doAction(button1?.action_on_data, null, actionName('on'));
37
37
  }
38
38
  }
39
39
  if (sensor?.is_managed_by_backend) {
40
- configuration.config && watchMultiConfigs([configuration.config]);
40
+ configuration.config &&
41
+ sensor.device_type !== 'GOOGLE_HOME' &&
42
+ watchMultiConfigs([configuration.config]);
41
43
  }
42
44
  }, [
43
45
  actionName,
@@ -46,17 +48,18 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
46
48
  doAction,
47
49
  isOn,
48
50
  sensor?.is_managed_by_backend,
51
+ sensor?.device_type,
49
52
  ]);
50
53
 
51
- const triggerAction2 = useCallback(() => {
54
+ const triggerAction2 = useCallback(async () => {
52
55
  if (button2?.action_on_data && button2?.action_off_data) {
53
56
  if (isStart) {
54
- doAction(button2?.action_off_data, null, actionName('stop'));
57
+ await doAction(button2?.action_off_data, null, actionName('stop'));
55
58
  } else {
56
- doAction(button2?.action_on_data, null, actionName('start'));
59
+ await doAction(button2?.action_on_data, null, actionName('start'));
57
60
  }
58
61
  }
59
- if (sensor?.is_managed_by_backend) {
62
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
60
63
  configuration.config && watchMultiConfigs([configuration.config]);
61
64
  }
62
65
  }, [
@@ -67,6 +70,7 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
67
70
  doAction,
68
71
  isStart,
69
72
  sensor?.is_managed_by_backend,
73
+ sensor?.device_type,
70
74
  ]);
71
75
 
72
76
  useEffect(() => {
@@ -98,7 +102,7 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
98
102
  if (sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
99
103
  return;
100
104
  }
101
- if (sensor?.is_managed_by_backend) {
105
+ if (sensor?.is_managed_by_backend && sensor.device_type !== 'GOOGLE_HOME') {
102
106
  watchMultiConfigs([configuration.config]);
103
107
  }
104
108
  }, [sensor, configuration.config]);
@@ -1,6 +1,14 @@
1
1
  import React, { useState } from 'react';
2
2
  import { act, create } from 'react-test-renderer';
3
- import Index from '../OnOffTemplate';
3
+ import OnOffTemplate from '../OnOffTemplate';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import { SCProvider } from '../../../context';
6
+
7
+ const wrapComponent = (actionGroup, mockDoAction) => (
8
+ <SCProvider initState={mockSCStore({})}>
9
+ <OnOffTemplate actionGroup={actionGroup} doAction={mockDoAction} />
10
+ </SCProvider>
11
+ );
4
12
 
5
13
  jest.mock('react', () => ({
6
14
  ...jest.requireActual('react'),
@@ -49,21 +57,15 @@ describe('Test OneBigButtonTemplate', () => {
49
57
  const assertRender = (state, text) => {
50
58
  useState.mockImplementationOnce((init) => [state, setState]);
51
59
  const mockDoAction = jest.fn();
60
+
52
61
  act(() => {
53
- wrapper = create(
54
- <Index actionGroup={actionGroup} doAction={mockDoAction} />
55
- );
62
+ wrapper = create(wrapComponent(actionGroup, mockDoAction));
56
63
  });
57
64
 
58
65
  const renderJson = wrapper.toJSON();
59
66
 
60
- expect(renderJson?.children[0].children[0].children[1].children).toEqual(
61
- undefined
62
- );
63
-
64
- expect(
65
- renderJson?.children[0].children[0].children[1].children
66
- ).not.toEqual([text]);
67
+ expect(renderJson?.props?.visible).toEqual(false);
68
+ expect(renderJson?.type).toEqual('Modal');
67
69
  };
68
70
 
69
71
  test('render state on', () => {
@@ -78,9 +80,7 @@ describe('Test OneBigButtonTemplate', () => {
78
80
  useState.mockImplementationOnce((init) => [state, setState]);
79
81
  const mockDoAction = jest.fn();
80
82
  act(() => {
81
- wrapper = create(
82
- <Index actionGroup={actionGroup} doAction={mockDoAction} />
83
- );
83
+ wrapper = create(wrapComponent(actionGroup, mockDoAction));
84
84
  });
85
85
 
86
86
  expect(mockDoAction).not.toHaveBeenCalled();