@eohjsc/react-native-smart-city 0.3.0 → 0.3.1

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 (128) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
  3. package/src/commons/Action/ItemQuickAction.js +11 -2
  4. package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -20
  6. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
  7. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +0 -1
  8. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
  9. package/src/commons/ActionGroup/__test__/index.test.js +2 -2
  10. package/src/commons/ConnectingProcess/index.js +11 -7
  11. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  12. package/src/commons/Device/HistoryChart.js +3 -3
  13. package/src/commons/Device/ItemDevice.js +15 -11
  14. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  15. package/src/commons/FieldTemplate/ScheduleField/index.js +2 -2
  16. package/src/commons/Header/HeaderCustom.js +2 -1
  17. package/src/commons/HorizontalPicker/index.js +2 -2
  18. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
  19. package/src/commons/MediaPlayerDetail/index.js +19 -50
  20. package/src/commons/SubUnit/Favorites/index.js +2 -3
  21. package/src/commons/SubUnit/ShortDetail.js +1 -2
  22. package/src/commons/SubUnit/__test__/Item.test.js +0 -1
  23. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  24. package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
  25. package/src/commons/WheelDateTimePicker/index.js +2 -2
  26. package/src/configs/API.js +4 -13
  27. package/src/configs/Constants.js +13 -0
  28. package/src/context/actionType.ts +8 -0
  29. package/src/context/mockStore.ts +10 -0
  30. package/src/context/reducer.ts +38 -2
  31. package/src/hooks/Common/index.js +2 -0
  32. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  33. package/src/hooks/Common/useGetIdUser.js +1 -5
  34. package/src/hooks/Common/useSensorsStatus.js +5 -8
  35. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
  36. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  37. package/src/hooks/IoT/index.js +4 -0
  38. package/src/hooks/IoT/useGGHomeConnection.js +91 -0
  39. package/src/hooks/IoT/useRemoteControl.js +79 -0
  40. package/src/hooks/index.js +4 -0
  41. package/src/hooks/useReceiveNotifications.js +8 -4
  42. package/src/iot/Monitor.js +3 -2
  43. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  44. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  45. package/src/iot/RemoteControl/Internet.js +1 -1
  46. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +90 -21
  47. package/src/iot/RemoteControl/__test__/Internet.test.js +4 -4
  48. package/src/iot/RemoteControl/__test__/LgThinq.test.js +5 -5
  49. package/src/iot/RemoteControl/index.js +52 -52
  50. package/src/screens/ActivityLog/hooks/__test__/index.test.js +3 -3
  51. package/src/screens/ActivityLog/hooks/index.js +1 -1
  52. package/src/screens/AddLocationMaps/index.js +5 -4
  53. package/src/screens/AddNewAction/SelectAction.js +8 -8
  54. package/src/screens/AddNewAction/SetupSensor.js +7 -7
  55. package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
  56. package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
  57. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +2 -2
  58. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  59. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  60. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
  61. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  62. package/src/screens/AllCamera/index.js +4 -4
  63. package/src/screens/Automate/MultiUnits.js +8 -8
  64. package/src/screens/Automate/index.js +3 -3
  65. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +4 -4
  66. package/src/screens/Device/EditDevice/index.js +2 -2
  67. package/src/screens/Device/__test__/detail.test.js +13 -5
  68. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  69. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
  70. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  71. package/src/screens/Device/detail.js +49 -16
  72. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  73. package/src/screens/EditActionsList/index.js +1 -1
  74. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  75. package/src/screens/HanetCamera/Detail.js +1 -1
  76. package/src/screens/HanetCamera/__test__/Detail.test.js +2 -2
  77. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  78. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  79. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  80. package/src/screens/ManageAccess/hooks/index.js +7 -4
  81. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +2 -2
  82. package/src/screens/MoveToAnotherSubUnit/index.js +1 -1
  83. package/src/screens/Notification/__test__/NotificationItem.test.js +4 -4
  84. package/src/screens/Notification/components/NotificationItem.js +17 -20
  85. package/src/screens/Notification/index.js +9 -2
  86. package/src/screens/PlayBackCamera/Timer.js +2 -2
  87. package/src/screens/PlayBackCamera/index.js +3 -3
  88. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  89. package/src/screens/ScriptDetail/index.js +14 -10
  90. package/src/screens/SelectUnit/index.js +4 -2
  91. package/src/screens/SetSchedule/index.js +9 -9
  92. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  93. package/src/screens/Sharing/SelectPermission.js +14 -6
  94. package/src/screens/SideMenuDetail/__test__/index.test.js +4 -4
  95. package/src/screens/SideMenuDetail/index.js +2 -3
  96. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  97. package/src/screens/SubUnit/Detail.js +1 -2
  98. package/src/screens/SubUnit/ManageSubUnit.js +12 -7
  99. package/src/screens/SubUnit/__test__/Detail.test.js +1 -1
  100. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  101. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +1 -1
  102. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  103. package/src/screens/Unit/ChooseLocation.js +6 -13
  104. package/src/screens/Unit/Detail.js +30 -75
  105. package/src/screens/Unit/SelectAddress.js +34 -21
  106. package/src/screens/Unit/SmartAccount.js +4 -4
  107. package/src/screens/Unit/Summaries.js +17 -1
  108. package/src/screens/Unit/__test__/CheckSendEmail.test.js +9 -1
  109. package/src/screens/Unit/__test__/Detail.test.js +16 -15
  110. package/src/screens/Unit/__test__/SelectAddress.test.js +72 -13
  111. package/src/screens/Unit/__test__/SmartAccount.test.js +1 -1
  112. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  113. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  114. package/src/screens/Unit/styles.js +4 -0
  115. package/src/screens/UnitSummary/__test__/index.test.js +55 -1
  116. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  117. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  118. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  119. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  120. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  121. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  122. package/src/screens/UnitSummary/index.js +15 -1
  123. package/src/utils/Apis/axios.js +16 -25
  124. package/src/utils/Converter/time.js +0 -18
  125. package/src/utils/I18n/translations/en.json +2 -1
  126. package/src/utils/I18n/translations/vi.json +3 -1
  127. package/src/utils/Permission/common.js +39 -0
  128. package/src/utils/Utils.js +5 -1
@@ -5,8 +5,6 @@ import { ToastBottomHelper } from '../../utils/Utils';
5
5
  import { API } from '../../configs';
6
6
  import { axiosPost } from '../../utils/Apis/axios';
7
7
 
8
- let connections = {};
9
-
10
8
  let configMaps = {};
11
9
 
12
10
  let attributeMaps = {};
@@ -89,14 +87,14 @@ async function fetchConnectionEntities(connection) {
89
87
  const entity = states[i];
90
88
  const entityId = entity.entity_id;
91
89
 
92
- if (configMaps.hasOwnProperty(entityId)) {
90
+ if (Object.prototype.hasOwnProperty.call(configMaps, entityId)) {
93
91
  const [configId, type] = configMaps[entityId];
94
92
  const typeConverter = valueTypes[type] || keepValue;
95
93
 
96
94
  configValues[configId] = typeConverter(entity.state, entityId);
97
95
  }
98
96
 
99
- if (attributeMaps.hasOwnProperty(entityId)) {
97
+ if (Object.prototype.hasOwnProperty.call(attributeMaps, entityId)) {
100
98
  const entityAttributeMaps = attributeMaps[entityId];
101
99
  for (const [attributeName, attributeMap] of Object.entries(
102
100
  entityAttributeMaps
@@ -118,14 +116,21 @@ async function fetchConnectionEntities(connection) {
118
116
  setConfigGlobalState('configValues', { ...configValues });
119
117
  }
120
118
 
121
- export const googleHomeConnect = async (options) => {
122
- let isConnected = true;
119
+ export const googleHomeConnect = async (
120
+ oldConnections,
121
+ options,
122
+ onEstablished,
123
+ onDisconnected,
124
+ onReconnected
125
+ ) => {
126
+ let connections = {};
127
+
123
128
  for (let i = 0; i < options.length; i++) {
124
129
  const option = options[i];
125
130
 
126
- if (option.chip_id in connections) {
127
- // skip connected
128
- return isConnected;
131
+ if (option.chip_id in oldConnections && !!oldConnections[option.chip_id]) {
132
+ connections[option.chip_id] = oldConnections[option.chip_id];
133
+ continue;
129
134
  }
130
135
  connections[option.chip_id] = 0; // connecting
131
136
 
@@ -152,43 +157,45 @@ export const googleHomeConnect = async (options) => {
152
157
  }
153
158
  });
154
159
 
155
- let auth = new Auth(option.auth);
156
- const connection = await createConnection({ auth });
157
- await connection.subscribeEvents(stateChangeCallback, 'state_changed');
158
-
159
- connection.addEventListener('disconnected', () => {
160
- ToastBottomHelper.error(t('command_googlehome_lost'));
161
- isConnected = false;
162
- });
163
-
164
- connection.addEventListener('ready', async (conn, eventData) => {
165
- await fetchConnectionEntities(conn);
166
- ToastBottomHelper.success(t('command_googlehome_ready'));
167
- isConnected = true;
168
- });
169
-
170
- connections[option.chip_id] = connection;
171
- await fetchConnectionEntities(connection);
172
- isConnected = true;
160
+ try {
161
+ let auth = new Auth(option.auth);
162
+ const connection = await createConnection({ auth });
163
+ await connection.subscribeEvents(stateChangeCallback, 'state_changed');
164
+
165
+ connection.addEventListener('disconnected', async () => {
166
+ await onDisconnected(option);
167
+ ToastBottomHelper.error(t('command_googlehome_lost'));
168
+ });
169
+
170
+ connection.addEventListener('ready', async (conn, eventData) => {
171
+ await fetchConnectionEntities(conn);
172
+ await onReconnected(option, conn);
173
+ ToastBottomHelper.success(t('command_googlehome_ready'));
174
+ });
175
+
176
+ connections[option.chip_id] = connection;
177
+ await fetchConnectionEntities(connection);
178
+ } catch (err) {
179
+ connections[option.chip_id] = 0;
180
+ }
173
181
  }
174
- return isConnected;
182
+ await onEstablished(connections, options);
183
+ return connections;
175
184
  };
176
185
 
177
- export const googleHomeDisconnect = async (options) => {
186
+ export const googleHomeDisconnect = async (connections, options) => {
178
187
  for (let i = 0; i < options.length; i++) {
179
188
  const option = options[i];
180
-
181
- if (!(option.chip_id in connections)) {
182
- return;
189
+ if (option.chip_id in connections) {
190
+ if (connections[option.chip_id]) {
191
+ await connections[option.chip_id].close();
192
+ }
183
193
  }
184
-
185
- await connections[option.chip_id].close();
186
- delete connections[option.chip_id];
187
194
  }
188
195
  };
189
196
 
190
- function getSensorConnection(sensor) {
191
- return connections[sensor.chip_id];
197
+ function getDeviceConnection(connections, device) {
198
+ return connections[device.chip_id];
192
199
  }
193
200
 
194
201
  function getServiceName(message) {
@@ -209,10 +216,20 @@ async function sendCommandSingleAction(connection, ghAction, data) {
209
216
  message.service_data[name] = data;
210
217
  }
211
218
 
212
- await connection.sendMessagePromise(message);
219
+ try {
220
+ await connection.sendMessagePromise(message);
221
+ return true;
222
+ } catch (err) {
223
+ ToastBottomHelper.error(t('command_send_fail_googlehome'));
224
+ }
213
225
  }
214
226
 
215
- export async function sendCommandOverGoogleHome(sensor, action, data) {
227
+ export async function sendCommandOverGoogleHome(
228
+ connections,
229
+ device,
230
+ action,
231
+ data
232
+ ) {
216
233
  if (
217
234
  !(action.googlehome_actions && action.googlehome_actions.length) &&
218
235
  !action.googlehome_action
@@ -220,30 +237,39 @@ export async function sendCommandOverGoogleHome(sensor, action, data) {
220
237
  return;
221
238
  }
222
239
 
223
- const connection = getSensorConnection(sensor);
240
+ const connection = getDeviceConnection(connections, device);
224
241
  if (!connection) {
225
242
  ToastBottomHelper.error(t('command_send_fail_googlehome'));
226
243
  return;
227
244
  }
228
245
 
246
+ let triggerSuccess;
247
+
229
248
  if (action.googlehome_actions) {
230
249
  for (let i = 0; i < action.googlehome_actions.length; i++) {
231
- await sendCommandSingleAction(
250
+ triggerSuccess = await sendCommandSingleAction(
232
251
  connection,
233
252
  action.googlehome_actions[i],
234
253
  data
235
254
  );
236
255
  }
237
256
  } else if (action.googlehome_action) {
238
- await sendCommandSingleAction(connection, action.googlehome_action, data);
257
+ triggerSuccess = await sendCommandSingleAction(
258
+ connection,
259
+ action.googlehome_action,
260
+ data
261
+ );
239
262
  }
240
263
 
241
- const { success } = await axiosPost(API.SENSOR.ACTIVITY_LOG(), {
242
- action_id: action.id,
243
- message: 'Trigger by user action with google home',
244
- });
245
- if (success) {
246
- ToastBottomHelper.success(t('command_send_success_googlehome'));
264
+ if (triggerSuccess) {
265
+ const { success } = await axiosPost(API.DEVICE.ACTIVITY_LOG(), {
266
+ action_id: action.id,
267
+ message: 'Trigger by user action with google home',
268
+ });
269
+ if (success) {
270
+ ToastBottomHelper.success(t('command_send_success_googlehome'));
271
+ }
272
+ return success;
247
273
  }
248
- return success;
274
+ return false;
249
275
  }
@@ -17,7 +17,7 @@ export const sendCommandOverInternet = async (
17
17
  }
18
18
  }
19
19
  ToastBottomHelper.success(t('Sending command via internet'));
20
- const { success } = await axiosPost(API.SENSOR.QUICK_ACTION(sensor.id), {
20
+ const { success } = await axiosPost(API.DEVICE.TRIGGER_ACTION(sensor.id), {
21
21
  key: action.key,
22
22
  data,
23
23
  source,
@@ -27,6 +27,10 @@ const connection = {
27
27
  close: jest.fn(),
28
28
  };
29
29
 
30
+ const mockEstablished = jest.fn();
31
+ const mockDisconnected = jest.fn();
32
+ const mockReconnected = jest.fn();
33
+
30
34
  getStates.mockImplementation(() => []);
31
35
  createConnection.mockImplementation(() => connection);
32
36
 
@@ -82,7 +86,6 @@ describe('Remote Control Google Home', () => {
82
86
  };
83
87
 
84
88
  beforeEach(async () => {
85
- await googleHomeDisconnect(options);
86
89
  connection.sendMessagePromise.mockClear();
87
90
  createConnection.mockClear();
88
91
  getStates.mockClear();
@@ -108,7 +111,13 @@ describe('Remote Control Google Home', () => {
108
111
  let configValues = getConfigGlobalState('configValues');
109
112
  expect(configValues).toEqual({});
110
113
 
111
- await googleHomeConnect(options);
114
+ await googleHomeConnect(
115
+ {},
116
+ options,
117
+ mockEstablished,
118
+ mockDisconnected,
119
+ mockReconnected
120
+ );
112
121
  expect(createConnection).toBeCalledTimes(1);
113
122
  expect(getStates).toBeCalledTimes(1);
114
123
 
@@ -144,15 +153,33 @@ describe('Remote Control Google Home', () => {
144
153
  }
145
154
  });
146
155
 
147
- await googleHomeConnect(options);
156
+ await googleHomeConnect(
157
+ {},
158
+ options,
159
+ mockEstablished,
160
+ mockDisconnected,
161
+ mockReconnected
162
+ );
148
163
 
149
164
  configValues = getConfigGlobalState('configValues');
150
165
  expect(configValues).toEqual({ 1: true });
151
166
  });
152
167
 
153
168
  it('Connect to same google home will be skipped', async () => {
154
- await googleHomeConnect(options);
155
- await googleHomeConnect(options);
169
+ const connections = await googleHomeConnect(
170
+ {},
171
+ options,
172
+ mockEstablished,
173
+ mockDisconnected,
174
+ mockReconnected
175
+ );
176
+ await googleHomeConnect(
177
+ connections,
178
+ options,
179
+ mockEstablished,
180
+ mockDisconnected,
181
+ mockReconnected
182
+ );
156
183
  expect(createConnection).toBeCalledTimes(1);
157
184
  expect(getStates).toBeCalledTimes(1);
158
185
  });
@@ -163,7 +190,13 @@ describe('Remote Control Google Home', () => {
163
190
  listener();
164
191
  }
165
192
  });
166
- await googleHomeConnect(options);
193
+ await googleHomeConnect(
194
+ {},
195
+ options,
196
+ mockEstablished,
197
+ mockDisconnected,
198
+ mockReconnected
199
+ );
167
200
  expect(createConnection).toBeCalledTimes(1);
168
201
  expect(getStates).toBeCalledTimes(2);
169
202
  });
@@ -174,7 +207,13 @@ describe('Remote Control Google Home', () => {
174
207
  listener();
175
208
  }
176
209
  });
177
- await googleHomeConnect(options);
210
+ await googleHomeConnect(
211
+ {},
212
+ options,
213
+ mockEstablished,
214
+ mockDisconnected,
215
+ mockReconnected
216
+ );
178
217
  expect(Toast.show).toBeCalledWith({
179
218
  type: 'error',
180
219
  position: 'bottom',
@@ -184,9 +223,15 @@ describe('Remote Control Google Home', () => {
184
223
  });
185
224
 
186
225
  it('Send command over google home will send message to chip', async () => {
187
- mock.onPost(API.SENSOR.ACTIVITY_LOG()).reply(200);
188
- await googleHomeConnect(options);
189
- await sendCommandOverGoogleHome(sensor, action);
226
+ mock.onPost(API.DEVICE.ACTIVITY_LOG()).reply(200);
227
+ const connections = await googleHomeConnect(
228
+ {},
229
+ options,
230
+ mockEstablished,
231
+ mockDisconnected,
232
+ mockReconnected
233
+ );
234
+ await sendCommandOverGoogleHome(connections, sensor, action);
190
235
  expect(connection.sendMessagePromise).toBeCalledWith(
191
236
  action.googlehome_actions[0].message
192
237
  );
@@ -203,9 +248,15 @@ describe('Remote Control Google Home', () => {
203
248
  },
204
249
  id: 20,
205
250
  };
206
- mock.onPost(API.SENSOR.ACTIVITY_LOG()).reply(200);
207
- await googleHomeConnect(options);
208
- await sendCommandOverGoogleHome(sensor, action, 19);
251
+ mock.onPost(API.DEVICE.ACTIVITY_LOG()).reply(200);
252
+ const connections = await googleHomeConnect(
253
+ {},
254
+ options,
255
+ mockEstablished,
256
+ mockDisconnected,
257
+ mockReconnected
258
+ );
259
+ await sendCommandOverGoogleHome(connections, sensor, action, 19);
209
260
  action.googlehome_actions[0].message.service_data.temperature = 19;
210
261
  expect(connection.sendMessagePromise).toBeCalledWith(
211
262
  action.googlehome_actions[0].message
@@ -224,9 +275,15 @@ describe('Remote Control Google Home', () => {
224
275
  },
225
276
  id: 20,
226
277
  };
227
- mock.onPost(API.SENSOR.ACTIVITY_LOG()).reply(200);
228
- await googleHomeConnect(options);
229
- await sendCommandOverGoogleHome(sensor, action, 19);
278
+ mock.onPost(API.DEVICE.ACTIVITY_LOG()).reply(200);
279
+ const connections = await googleHomeConnect(
280
+ {},
281
+ options,
282
+ mockEstablished,
283
+ mockDisconnected,
284
+ mockReconnected
285
+ );
286
+ await sendCommandOverGoogleHome(connections, sensor, action, 19);
230
287
  action.googlehome_action.message.service_data.temperature = 19;
231
288
  expect(connection.sendMessagePromise).toBeCalledWith(
232
289
  action.googlehome_action.message
@@ -234,20 +291,32 @@ describe('Remote Control Google Home', () => {
234
291
  });
235
292
 
236
293
  it('Send command over google home that not connected', async () => {
237
- await googleHomeConnect(options);
238
- await sendCommandOverGoogleHome({ chip_id: 2 }, action);
294
+ await googleHomeConnect(
295
+ {},
296
+ options,
297
+ mockEstablished,
298
+ mockDisconnected,
299
+ mockReconnected
300
+ );
301
+ await sendCommandOverGoogleHome({}, { chip_id: 2 }, action);
239
302
  expect(connection.sendMessagePromise).not.toBeCalled();
240
303
  });
241
304
 
242
305
  it('Send command over google home that not a google home', async () => {
243
- await googleHomeConnect(options);
244
- await sendCommandOverGoogleHome(sensor, {});
306
+ await googleHomeConnect(
307
+ {},
308
+ options,
309
+ mockEstablished,
310
+ mockDisconnected,
311
+ mockReconnected
312
+ );
313
+ await sendCommandOverGoogleHome({}, sensor, {});
245
314
  expect(connection.sendMessagePromise).not.toBeCalled();
246
315
  });
247
316
 
248
317
  it('Disconnect a not connected gateway', async () => {
249
318
  connection.close.mockClear();
250
- await googleHomeDisconnect(options);
319
+ await googleHomeDisconnect({}, options);
251
320
  expect(connection.close).not.toBeCalled();
252
321
  });
253
322
  });
@@ -12,25 +12,25 @@ describe('Test IOT Remote Control Internet', () => {
12
12
  });
13
13
 
14
14
  test('Trigger action via request POST', async () => {
15
- mock.onPost(API.SENSOR.QUICK_ACTION()).reply(200);
15
+ mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200);
16
16
  await sendCommandOverInternet({}, {}, 'internet');
17
17
  expect(Toast.show).toBeCalledTimes(2);
18
18
  });
19
19
 
20
20
  test('Trigger action via request POST with data isInteger', async () => {
21
- mock.onPost(API.SENSOR.QUICK_ACTION()).reply(200);
21
+ mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200);
22
22
  await sendCommandOverInternet({}, {}, 1);
23
23
  expect(Toast.show).toBeCalledTimes(2);
24
24
  });
25
25
 
26
26
  test('Trigger action via request POST with data is null', async () => {
27
- mock.onPost(API.SENSOR.QUICK_ACTION()).reply(200);
27
+ mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200);
28
28
  await sendCommandOverInternet({}, {}, null);
29
29
  expect(Toast.show).toBeCalledTimes(2);
30
30
  });
31
31
 
32
32
  test('Trigger action fail show error', async () => {
33
- mock.onPost(API.SENSOR.QUICK_ACTION()).reply(400);
33
+ mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(400);
34
34
  await sendCommandOverInternet({}, {}, 'internet');
35
35
  expect(Toast.show).toBeCalled();
36
36
  });
@@ -86,7 +86,7 @@ describe('Remote Control LG Thinq', () => {
86
86
 
87
87
  it('Send command over lg thinq but fetch device status failed', async () => {
88
88
  mock.onGet(API.IOT.LG.DEVICE_STATUS()).reply(200, {});
89
- mock.onPost(API.SENSOR.QUICK_ACTION()).reply(200, {});
89
+ mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200, {});
90
90
  setConfigGlobalState('configValues', { 1: 'LOW' });
91
91
  await sendCommandOverLGThinq(sensor, action, 'AUTO');
92
92
  let configValues = getConfigGlobalState('configValues');
@@ -146,7 +146,7 @@ describe('Remote Control LG Thinq', () => {
146
146
  };
147
147
  mock.onGet(API.IOT.LG.DEVICE_STATUS(1)).reply(200, responseGet.data);
148
148
  jest.useFakeTimers();
149
- mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200);
149
+ mock.onPost(API.DEVICE.TRIGGER_ACTION(1)).reply(200);
150
150
  await lgThinqConnect(options);
151
151
  setConfigGlobalState('configValues', { 1: 0, 2: 0 });
152
152
  await sendCommandOverLGThinq(sensor, action, [18, 30]);
@@ -159,14 +159,14 @@ describe('Remote Control LG Thinq', () => {
159
159
 
160
160
  it('Send command over lg thinq will call sendCommandOverInternet with boolean', async () => {
161
161
  let configValues = getConfigGlobalState('configValues');
162
- mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200, {});
162
+ mock.onPost(API.DEVICE.TRIGGER_ACTION(1)).reply(200, {});
163
163
  await sendCommandOverLGThinq(sensor, action, true);
164
164
  expect(configValues).toEqual({});
165
165
  });
166
166
 
167
167
  it('Send command over lg thinq will call sendCommandOverInternet with number', async () => {
168
168
  let configValues = getConfigGlobalState('configValues');
169
- mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200, {});
169
+ mock.onPost(API.DEVICE.TRIGGER_ACTION(1)).reply(200, {});
170
170
  await sendCommandOverLGThinq(sensor, action, 7);
171
171
  expect(configValues).toEqual({});
172
172
  });
@@ -176,7 +176,7 @@ describe('Remote Control LG Thinq', () => {
176
176
  action.lg_actions[0].message = {
177
177
  temperature: { targetTemperature: 0, locationName: 'FRIDGE', unit: 'C' },
178
178
  };
179
- mock.onPost(API.SENSOR.QUICK_ACTION(1)).reply(200);
179
+ mock.onPost(API.DEVICE.TRIGGER_ACTION(1)).reply(200);
180
180
  await sendCommandOverLGThinq(sensor, action, 7);
181
181
  expect(configValues).toEqual({});
182
182
  });
@@ -1,55 +1,55 @@
1
- import {
2
- SEND_COMMAND_OVER_BLUETOOTH_FAIL,
3
- sendCommandOverBluetooth,
4
- } from './Bluetooth';
5
- import { sendCommandOverInternet } from './Internet';
6
- import { sendCommandOverGoogleHome } from './GoogleHome';
7
- import { ToastBottomHelper } from '../../utils/Utils';
8
- import t from '../../hooks/Common/useTranslations';
9
- import { sendCommandOverLGThinq } from './LG';
1
+ // import {
2
+ // SEND_COMMAND_OVER_BLUETOOTH_FAIL,
3
+ // sendCommandOverBluetooth,
4
+ // } from './Bluetooth';
5
+ // import { sendCommandOverInternet } from './Internet';
6
+ // import { sendCommandOverGoogleHome } from './GoogleHome';
7
+ // import { ToastBottomHelper } from '../../utils/Utils';
8
+ // import t from '../../hooks/Common/useTranslations';
9
+ // import { sendCommandOverLGThinq } from './LG';
10
10
 
11
- export const sendRemoteCommand = async (
12
- sensor,
13
- action,
14
- data,
15
- userId = null,
16
- actionName
17
- ) => {
18
- // No action, raise not authorized
19
- let result = false;
20
- if (!action) {
21
- ToastBottomHelper.error(
22
- t('your_account_has_not_been_authorized_to_control')
23
- );
24
- return result;
25
- }
26
- if (action.command_prefer_over_bluetooth) {
27
- try {
28
- result = await sendCommandOverBluetooth(sensor, action, data, userId);
29
- } catch (err) {
30
- if (err === SEND_COMMAND_OVER_BLUETOOTH_FAIL) {
31
- result = await sendCommandOverInternet(
32
- sensor,
33
- action,
34
- data,
35
- 'bluetooth',
36
- actionName
37
- );
38
- } else {
39
- throw err;
40
- }
41
- }
42
- }
43
- if (action.command_prefer_over_internet) {
44
- result = await sendCommandOverInternet(sensor, action, data, 'internet');
45
- }
11
+ // export const sendRemoteCommand = async (
12
+ // sensor,
13
+ // action,
14
+ // data,
15
+ // userId = null,
16
+ // actionName
17
+ // ) => {
18
+ // // No action, raise not authorized
19
+ // let result = false;
20
+ // if (!action) {
21
+ // ToastBottomHelper.error(
22
+ // t('your_account_has_not_been_authorized_to_control')
23
+ // );
24
+ // return result;
25
+ // }
26
+ // if (action.command_prefer_over_bluetooth) {
27
+ // try {
28
+ // result = await sendCommandOverBluetooth(sensor, action, data, userId);
29
+ // } catch (err) {
30
+ // if (err === SEND_COMMAND_OVER_BLUETOOTH_FAIL) {
31
+ // result = await sendCommandOverInternet(
32
+ // sensor,
33
+ // action,
34
+ // data,
35
+ // 'bluetooth',
36
+ // actionName
37
+ // );
38
+ // } else {
39
+ // throw err;
40
+ // }
41
+ // }
42
+ // }
43
+ // if (action.command_prefer_over_internet) {
44
+ // result = await sendCommandOverInternet(sensor, action, data, 'internet');
45
+ // }
46
46
 
47
- if (action.command_prefer_over_googlehome) {
48
- result = await sendCommandOverGoogleHome(sensor, action, data);
49
- }
47
+ // if (action.command_prefer_over_googlehome) {
48
+ // result = await sendCommandOverGoogleHome(sensor, action, data);
49
+ // }
50
50
 
51
- if (action.command_prefer_over_lg) {
52
- result = await sendCommandOverLGThinq(sensor, action, data);
53
- }
54
- return result;
55
- };
51
+ // if (action.command_prefer_over_lg) {
52
+ // result = await sendCommandOverLGThinq(sensor, action, data);
53
+ // }
54
+ // return result;
55
+ // };
@@ -81,7 +81,7 @@ describe('Test useActivityLog', () => {
81
81
 
82
82
  it('Test onRefresh activity log of sensor', async () => {
83
83
  const { result } = renderHook(() => useActivityLog(props));
84
- mock.onGet(API.SENSOR.ACTIVITY_LOG(1)).reply(200, {
84
+ mock.onGet(API.DEVICE.ACTIVITY_LOG(1)).reply(200, {
85
85
  results: actionLogData,
86
86
  count: 21,
87
87
  });
@@ -135,14 +135,14 @@ describe('Test useActivityLog', () => {
135
135
 
136
136
  it('Test onLoadMore', async () => {
137
137
  const { result } = renderHook(() => useActivityLog(props));
138
- mock.onGet(API.SENSOR.ACTIVITY_LOG(1)).reply(200, {
138
+ mock.onGet(API.DEVICE.ACTIVITY_LOG(1)).reply(200, {
139
139
  results: actionLogData,
140
140
  count: 21,
141
141
  });
142
142
  await act(async () => {
143
143
  await result.current.onLoadMore();
144
144
  });
145
- mock.onGet(API.SENSOR.ACTIVITY_LOG(2)).reply(200, {
145
+ mock.onGet(API.DEVICE.ACTIVITY_LOG(2)).reply(200, {
146
146
  results: actionLogData,
147
147
  count: 21,
148
148
  });
@@ -9,7 +9,7 @@ import { getDataForList, getEmergencyEventDataForList } from '../utils';
9
9
 
10
10
  const apiMaps = {
11
11
  ['action']: {
12
- url: () => API.SENSOR.ACTIVITY_LOG(),
12
+ url: () => API.DEVICE.ACTIVITY_LOG(),
13
13
  params: (id) => ({ id: id }),
14
14
  standardizeData: getDataForList,
15
15
  memberUrl: (id) => API.SHARE.UNITS_MEMBERS(id),
@@ -45,9 +45,9 @@ const AddLocationMaps = memo(() => {
45
45
  goBack();
46
46
  }, [goBack]);
47
47
 
48
- const onTextInput = useCallback(async (input) => {
49
- setInput(input);
50
- if (!input) {
48
+ const onTextInput = useCallback(async (newValue) => {
49
+ setInput(newValue);
50
+ if (!newValue) {
51
51
  setSearchData([]);
52
52
  setSearchedLocation(null);
53
53
  return;
@@ -55,7 +55,7 @@ const AddLocationMaps = memo(() => {
55
55
  try {
56
56
  const config = {
57
57
  params: {
58
- input: input,
58
+ input: newValue,
59
59
  key: SCConfig.GOOGLE_MAP_API_KEY,
60
60
  sessiontoken: 123456324,
61
61
  strictBounds: false,
@@ -70,6 +70,7 @@ const AddLocationMaps = memo(() => {
70
70
  if (success) {
71
71
  setSearchData(data.predictions);
72
72
  }
73
+ // eslint-disable-next-line no-empty
73
74
  } catch (error) {}
74
75
  }, []);
75
76