@eohjsc/react-native-smart-city 0.3.70 → 0.3.72

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 (161) hide show
  1. package/index.js +0 -2
  2. package/package.json +4 -5
  3. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +0 -1
  4. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
  5. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  6. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -1
  7. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -11
  8. package/src/commons/ActionGroup/OnOffTemplate/index.js +22 -11
  9. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +19 -13
  10. package/src/commons/ActionGroup/SliderRangeTemplate.js +3 -4
  11. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +1 -0
  12. package/src/commons/ActionGroup/ThreeButtonTemplate.js +9 -4
  13. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -0
  14. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +40 -39
  15. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +3 -3
  16. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +19 -10
  17. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +0 -1
  18. package/src/commons/ActionGroup/__test__/index.test.js +24 -16
  19. package/src/commons/ActionTemplate/__test__/index.test.js +5 -1
  20. package/src/commons/AlertAction/__test__/AlertAction.test.js +2 -2
  21. package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
  22. package/src/commons/Calendar/__test__/Calendar.test.js +3 -5
  23. package/src/commons/CameraDevice/index.js +37 -22
  24. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -3
  25. package/src/commons/Dashboard/MyUnit/index.js +1 -1
  26. package/src/commons/Device/ConnectedViewHeader.js +2 -1
  27. package/src/commons/Device/DeviceAlertStatus.js +1 -1
  28. package/src/commons/Device/DisconnectedView.js +10 -14
  29. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  30. package/src/commons/Device/HorizontalBarChart.js +1 -1
  31. package/src/commons/Device/LinearChart/LinearChart.test.js +10 -4
  32. package/src/commons/Device/LinearChart.js +5 -1
  33. package/src/commons/Device/RainningSensor/CurrentRainSensor.js +7 -16
  34. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
  35. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  36. package/src/commons/Device/WindDirection/Compass/Compass.test.js +12 -27
  37. package/src/commons/Device/WindDirection/Compass/index.js +15 -23
  38. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +4 -4
  39. package/src/commons/Device/WindSpeed/__test__/ChartInfo.test.js +2 -2
  40. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +11 -8
  41. package/src/commons/Device/__test__/DisconnectedView.test.js +8 -45
  42. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  43. package/src/commons/DisplayChecking/index.js +4 -3
  44. package/src/commons/DisplayChecking/styles.js +2 -2
  45. package/src/commons/MediaPlayer/index.js +2 -1
  46. package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
  47. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +0 -1
  48. package/src/commons/MediaPlayerDetail/index.js +2 -3
  49. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +2 -1
  50. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -1
  51. package/src/commons/MenuActionList/index.js +8 -70
  52. package/src/commons/MenuActionList/styles.js +68 -0
  53. package/src/commons/Modal/__test__/ModalBottom.test.js +1 -10
  54. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +45 -31
  55. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +15 -13
  56. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +12 -9
  57. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +19 -13
  58. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -5
  59. package/src/commons/PreventAccess/index.js +3 -3
  60. package/src/commons/Sharing/__test__/MemberList.test.js +17 -6
  61. package/src/commons/Sharing/__test__/RowMember.test.js +0 -2
  62. package/src/commons/SubUnit/OneTap/index.js +6 -1
  63. package/src/commons/Today/__test__/Today.test.js +3 -3
  64. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  65. package/src/configs/IOPinConstants.js +285 -0
  66. package/src/configs/SCConfig.js +1 -0
  67. package/src/iot/RemoteControl/HomeAssistant.js +2 -11
  68. package/src/iot/RemoteControl/__test__/HomeAssistant.test.js +1 -33
  69. package/src/libs/react-native-parallax-scroll-view/index.js +2 -1
  70. package/src/navigations/AllGatewayStack.js +3 -3
  71. package/src/navigations/UnitStack.js +0 -6
  72. package/src/screens/ActivityLog/__test__/index.test.js +16 -22
  73. package/src/screens/ActivityLog/index.js +2 -3
  74. package/src/screens/AddNewAction/SelectAction.js +3 -0
  75. package/src/screens/AddNewAction/SetupSensor.js +3 -3
  76. package/src/screens/AddNewAction/__test__/SelectAction.test.js +12 -0
  77. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +11 -24
  78. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -1
  79. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +0 -1
  80. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +0 -1
  81. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +2 -2
  82. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +22 -7
  83. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  84. package/src/screens/AllCamera/index.js +1 -1
  85. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +82 -0
  86. package/src/screens/AllGateway/DetailConfigActionInternal/index.js +84 -5
  87. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +63 -57
  88. package/src/screens/AllGateway/DeviceInternalDetail/index.js +32 -32
  89. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +40 -79
  90. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -42
  91. package/src/screens/AllGateway/DeviceZigbeeDetail/index.js +4 -4
  92. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +49 -61
  93. package/src/screens/AllGateway/GatewayDetail/index.js +2 -1
  94. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
  95. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  96. package/src/screens/AllGateway/hooks/useGateway.js +1 -0
  97. package/src/screens/AllGateway/test-utils.js +20 -0
  98. package/src/screens/Device/__test__/detail.test.js +8 -3
  99. package/src/screens/Device/components/SensorDisplayItem.js +1 -5
  100. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -4
  101. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +32 -4
  102. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -5
  103. package/src/screens/EmergencyContacts/__test__/hooks.test.js +1 -1
  104. package/src/screens/GuestInfo/__test__/index.test.js +26 -14
  105. package/src/screens/HanetCamera/CaptureFaceID.js +1 -1
  106. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +1 -5
  107. package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +1 -1
  108. package/src/screens/PlayBackCamera/Timer.js +2 -3
  109. package/src/screens/PlayBackCamera/__test__/index.test.js +69 -48
  110. package/src/screens/ScanChipQR/components/QRScan/index.js +8 -8
  111. package/src/screens/SharedUnit/__test__/ShareUnit.test.js +20 -10
  112. package/src/screens/SharedUnit/index.js +19 -17
  113. package/src/screens/SmartAccount/Connecting/index.js +2 -2
  114. package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +4 -2
  115. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +17 -8
  116. package/src/screens/SmartAccount/ListDevice/index.js +1 -1
  117. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +9 -6
  118. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +1 -0
  119. package/src/screens/SmartAccount/__test__/Connecting.test.js +2 -1
  120. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +17 -6
  121. package/src/screens/SubUnit/EditSubUnit.js +6 -6
  122. package/src/screens/SubUnit/EditSubUnitStyles.js +2 -2
  123. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -6
  124. package/src/screens/SubUnit/__test__/Detail.test.js +2 -3
  125. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +25 -10
  126. package/src/screens/Template/EditTemplate.js +13 -3
  127. package/src/screens/Template/__test__/EditTemplate.test.js +21 -15
  128. package/src/screens/Unit/Detail.js +157 -121
  129. package/src/screens/Unit/ManageUnit.js +3 -3
  130. package/src/screens/Unit/ManageUnitStyles.js +1 -1
  131. package/src/screens/Unit/__test__/Detail.test.js +40 -20
  132. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -15
  133. package/src/screens/Unit/components/AutomateScript/index.js +9 -8
  134. package/src/screens/Unit/components/Header/index.js +1 -14
  135. package/src/screens/Unit/components/__test__/AutomateScript.test.js +10 -36
  136. package/src/screens/Unit/components/__test__/Header.test.js +14 -9
  137. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +4 -5
  138. package/src/utils/I18n/translations/en.json +2 -1
  139. package/src/utils/I18n/translations/vi.json +2 -1
  140. package/src/utils/Route/index.js +1 -2
  141. package/src/utils/Utils.js +62 -2
  142. package/src/commons/Explore/ActivityIndicator/index.js +0 -49
  143. package/src/commons/Explore/CityItem/index.js +0 -116
  144. package/src/commons/Explore/HeaderExplore/index.js +0 -44
  145. package/src/commons/Explore/HeaderLabel/index.js +0 -46
  146. package/src/commons/Explore/LocationItem/index.js +0 -71
  147. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +0 -58
  148. package/src/commons/Explore/SearchBox/index.js +0 -59
  149. package/src/commons/Explore/__test__/CityItem.test.js +0 -156
  150. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -25
  151. package/src/commons/Explore/__test__/HeaderLabel.test.js +0 -33
  152. package/src/commons/Explore/__test__/LocationItem.test.js +0 -31
  153. package/src/screens/Explore/__test__/Explore.test.js +0 -43
  154. package/src/screens/Explore/index.js +0 -201
  155. package/src/screens/Unit/MyAllUnit/index.js +0 -44
  156. package/src/screens/Unit/__test__/MyAllUnit.test.js +0 -87
  157. package/src/screens/Unit/components/ListMyAllUnit/index.js +0 -162
  158. package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +0 -117
  159. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  160. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  161. package/src/screens/Unit/components/MyAllUnit/index.js +0 -44
@@ -6,6 +6,7 @@ import StatesGridActionTemplate from '../StatesGridActionTemplate';
6
6
 
7
7
  import { TouchableOpacity } from 'react-native';
8
8
  import { AccessibilityLabel } from '../../../configs/Constants';
9
+ import SelectActionCard from '../../SelectActionCard';
9
10
 
10
11
  const mockOnSelectAction = jest.fn();
11
12
 
@@ -15,7 +16,7 @@ const wrapComponent = (data) => (
15
16
  </SCProvider>
16
17
  );
17
18
 
18
- describe('Test StatesGridActionTempalte', () => {
19
+ describe('Test StatesGridActionTemplate', () => {
19
20
  let tree;
20
21
  let data = {
21
22
  title: 'Mode',
@@ -57,35 +58,40 @@ describe('Test StatesGridActionTempalte', () => {
57
58
  ],
58
59
  },
59
60
  };
60
- it('Test render StatesGridActionTempalte', async () => {
61
+
62
+ it('Test render', async () => {
61
63
  await act(async () => {
62
64
  tree = await create(wrapComponent(data));
63
65
  });
64
66
  const instance = tree.root;
65
- const touchOpacity = instance.findAll(
67
+ let items;
68
+ const card = instance.findByType(SelectActionCard);
69
+ await act(async () => {
70
+ card.props.onPress();
71
+ });
72
+
73
+ items = instance.findAll(
66
74
  (item) =>
67
75
  item.props.accessibilityLabel ===
68
76
  AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM &&
69
77
  item.type === TouchableOpacity
70
78
  );
71
- expect(touchOpacity).toHaveLength(4);
79
+ expect(items).toHaveLength(data.configuration.options.length);
72
80
  });
73
81
 
74
- it('Test onPress hanleSelectAction', async () => {
82
+ it('Test onPress', async () => {
75
83
  await act(async () => {
76
84
  tree = await create(wrapComponent(data));
77
85
  });
78
86
  const instance = tree.root;
79
- const touchOpacity = instance.findAll(
80
- (item) =>
81
- item.props.accessibilityLabel ===
82
- AccessibilityLabel.STATES_GRID_ACTION_GRID_ITEM &&
83
- item.type === TouchableOpacity
84
- );
85
- expect(touchOpacity).toHaveLength(4);
86
87
 
88
+ const card = instance.findByType(SelectActionCard);
89
+ await act(async () => {
90
+ card.props.onPress();
91
+ });
92
+ const touchOpacity = instance.findAllByType(TouchableOpacity)[1];
87
93
  await act(async () => {
88
- touchOpacity[0].props.onPress(data.configuration.options[0]);
94
+ touchOpacity.props.onPress();
89
95
  });
90
96
  expect(mockOnSelectAction).toHaveBeenCalled();
91
97
  });
@@ -6,6 +6,7 @@ import { AccessibilityLabel } from '../../../configs/Constants';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
8
  import Text from '../../Text';
9
+ import t from '../../../hooks/Common/useTranslations';
9
10
 
10
11
  const mockGoBack = jest.fn();
11
12
 
@@ -31,19 +32,18 @@ jest.mock('@react-navigation/native', () => {
31
32
 
32
33
  describe('Test PreventAccess.test', () => {
33
34
  let tree;
34
- let headerBodyText;
35
- let visible;
35
+ let headerBodyText = 'some header test';
36
36
  let hidePreventAccess = () => {};
37
37
 
38
38
  it('onItemClick MenuActionList', async () => {
39
39
  await act(async () => {
40
40
  tree = await create(
41
- wrapComponent(headerBodyText, visible, hidePreventAccess)
41
+ wrapComponent(headerBodyText, true, hidePreventAccess)
42
42
  );
43
43
  });
44
44
  const instance = tree.root;
45
- const text = instance.findAllByType(Text);
46
- expect(text).toHaveLength(5);
45
+ const texts = instance.findAllByType(Text);
46
+ expect(texts[0].props.children).toEqual(t('note'));
47
47
  const button1 = instance.find(
48
48
  (el) =>
49
49
  el.props.accessibilityLabel === AccessibilityLabel.BUTTON_PREVENT_ACCESS
@@ -43,10 +43,10 @@ const PreventAccess = memo(({ headerBodyText, visible, hidePreventAccess }) => {
43
43
  <View style={styles.popoverStyle}>
44
44
  <View style={styles.actionTextWrap}>
45
45
  <Text size={17} bold color={Colors.Gray9} style={styles.textHeader}>
46
- {dataText?.headerText}
46
+ {dataText.headerText}
47
47
  </Text>
48
48
  <Text type="H4" color={Colors.Gray8} style={styles.textNotification}>
49
- {dataText?.bodyText}
49
+ {dataText.bodyText}
50
50
  </Text>
51
51
  </View>
52
52
  <View style={styles.endOfText}>
@@ -57,7 +57,7 @@ const PreventAccess = memo(({ headerBodyText, visible, hidePreventAccess }) => {
57
57
  color={Colors.Primary}
58
58
  onPress={handleDonePopup}
59
59
  >
60
- {dataText?.endOfText}
60
+ {dataText.endOfText}
61
61
  </Text>
62
62
  </View>
63
63
  </View>
@@ -5,6 +5,7 @@ import RowMember from '../RowMember';
5
5
  import Text from '../../Text';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
+ import t from '../../../hooks/Common/useTranslations';
8
9
 
9
10
  const wrapComponent = (dataMember, ownerId, currentUserId, mockFunc) => (
10
11
  <SCProvider initState={mockSCStore({})}>
@@ -20,33 +21,43 @@ const wrapComponent = (dataMember, ownerId, currentUserId, mockFunc) => (
20
21
  describe('MemberList', () => {
21
22
  let tree;
22
23
  const mockFunc = jest.fn();
24
+
23
25
  it('MemberList snapshot id dataMember === ownerId', async () => {
24
26
  const dataMember = [{ id: 1, name: 'CEO' }];
25
27
  await act(async () => {
26
28
  tree = renderer.create(wrapComponent(dataMember, 1, 2, mockFunc));
27
29
  });
28
30
  const instance = tree.root;
29
- const textInputs = instance.findAllByType(Text);
30
- expect(textInputs.length).toBe(5);
31
+ const rowMember = instance.findByType(RowMember);
32
+
33
+ const texts = rowMember.findAllByType(Text);
34
+ const role = texts[texts.length - 1];
35
+ expect(role.props.children).toEqual(t('owner'));
31
36
  });
37
+
32
38
  it('MemberList snapshot id dataMember !== ownerId', async () => {
33
39
  const dataMember = [{ id: 1, name: 'CEO' }];
34
40
  await act(async () => {
35
41
  tree = renderer.create(wrapComponent(dataMember, 2, null, mockFunc));
36
42
  });
37
43
  const instance = tree.root;
38
- const textInputs = instance.findAllByType(Text);
39
- expect(textInputs.length).toBe(5);
44
+ const rowMember = instance.findByType(RowMember);
45
+
46
+ const texts = rowMember.findAllByType(Text);
47
+ const role = texts[texts.length - 1];
48
+ expect(role.props.children).toEqual(t('member'));
40
49
  });
50
+
41
51
  it('MemberList snapshot id dataMember === currentUserId', async () => {
42
52
  const dataMember = [{ id: 1, name: 'CEO' }];
43
53
  await act(async () => {
44
54
  tree = renderer.create(wrapComponent(dataMember, 2, 1, mockFunc));
45
55
  });
46
56
  const instance = tree.root;
47
- const textInputs = instance.findAllByType(Text);
48
- expect(textInputs.length).toBe(5);
57
+ const rowMembers = instance.findAllByType(RowMember);
58
+ expect(rowMembers).toHaveLength(1);
49
59
  });
60
+
50
61
  it('MemberList dataMember null', async () => {
51
62
  const dataMember = [];
52
63
  await act(async () => {
@@ -26,7 +26,6 @@ describe('RowMember', () => {
26
26
  });
27
27
  const instance = tree.root;
28
28
  const textInputs = instance.findAllByType(Text);
29
- expect(textInputs.length).toBe(5);
30
29
  expect(textInputs[1].props.children).toEqual('CEO');
31
30
  });
32
31
  it('RowMember owner dont have name show start of email ', async () => {
@@ -36,7 +35,6 @@ describe('RowMember', () => {
36
35
  });
37
36
  const instance = tree.root;
38
37
  const textInputs = instance.findAllByType(Text);
39
- expect(textInputs.length).toBe(5);
40
38
  expect(textInputs[1].props.children).toEqual('abc');
41
39
  });
42
40
  });
@@ -75,7 +75,12 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
75
75
  <View style={styles.boxDevices}>
76
76
  {automates?.data &&
77
77
  automates.data.map((item) => (
78
- <ItemOneTap isOwner={isOwner} automate={item} unit={unit} />
78
+ <ItemOneTap
79
+ isOwner={isOwner}
80
+ automate={item}
81
+ unit={unit}
82
+ key={item.id}
83
+ />
79
84
  ))}
80
85
  <ItemAddNew
81
86
  title={t('add_new')}
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { View } from 'react-native';
3
2
  import renderer, { act } from 'react-test-renderer';
4
3
  import { SCProvider } from '../../../context';
5
4
  import { mockSCStore } from '../../../context/mockStore';
6
5
  import Today from '../index';
6
+ import Text from '../../Text';
7
7
 
8
8
  const wrapComponent = () => (
9
9
  <SCProvider initState={mockSCStore({})}>
@@ -19,7 +19,7 @@ describe('Test Today', () => {
19
19
  tree = renderer.create(wrapComponent());
20
20
  });
21
21
  const instance = tree.root;
22
- const Views = instance.findAllByType(View);
23
- expect(Views).toHaveLength(6);
22
+ const texts = instance.findAllByType(Text);
23
+ expect(texts[0].props.children).toEqual('Today, Jan 24');
24
24
  });
25
25
  });
@@ -3,12 +3,12 @@ import { act, create } from 'react-test-renderer';
3
3
  import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import ConfigHistoryChart from '../';
6
- import HighchartsReactNative from '@eohjsc/highcharts';
7
6
  import api from '../../../../utils/Apis/axios';
8
7
  import { mockSCStore } from '../../../../context/mockStore';
9
8
  import { SCProvider } from '../../../../context';
10
9
  import API from '../../../../configs/API';
11
10
  import { getPusher } from '../../../../utils/Pusher';
11
+ import HighchartsReactNative from '@eohjsc/highcharts';
12
12
 
13
13
  const mock = new MockAdapter(api.axiosInstance);
14
14
 
@@ -0,0 +1,285 @@
1
+ export const INTERNAL_DEVICE = {
2
+ ESP32: 'esp32',
3
+ STM32: 'stm32',
4
+ RASPBERRY_PI: 'raspberry_pi',
5
+ };
6
+
7
+ export const TYPE_BOARD = [
8
+ { value: INTERNAL_DEVICE.ESP32, text: 'ESP32' },
9
+ { value: INTERNAL_DEVICE.STM32, text: 'STM32' },
10
+ { value: INTERNAL_DEVICE.RASPBERRY_PI, text: 'Raspberry Pi' },
11
+ ];
12
+
13
+ // DEFAULT
14
+
15
+ export const TYPE_PIN_MODE = {
16
+ OUTPUT: 'output',
17
+ INPUT: 'input',
18
+ };
19
+ export const ARDUINO_PIN_CONFIG_TYPE = [
20
+ { key: 'boolean', value: 'Digital' },
21
+ { key: 'integer', value: 'Analog' },
22
+ ];
23
+
24
+ export const READ_DIGITAL_PIN_MODE = [
25
+ { key: 'input', value: 'Input' },
26
+ { key: 'pull_up', value: 'Pullup' },
27
+ { key: 'pull_down', value: 'Pulldown' },
28
+ ];
29
+
30
+ export const READ_ANALOG_PIN_MODE = [{ key: 'analog', value: 'Analog' }];
31
+
32
+ export const WRITE_DIGITAL_PIN_MODE = [
33
+ { key: 'output', value: 'Output' },
34
+ { key: 'open_drain', value: 'Open drain' },
35
+ ];
36
+
37
+ export const WRITE_ANALOG_PIN_MODE = [{ key: 'pwm', value: 'PWM' }];
38
+
39
+ export const CONFIG_IS_WRITE_IS_READ_PIN_MODE = [
40
+ { key: 'output', value: 'Input' },
41
+ ];
42
+
43
+ // ESP32
44
+
45
+ export const ESP32_DIGITAL = [
46
+ { key: '0', value: 'GPIO 0' },
47
+ { key: '1', value: 'GPIO 1 - UART 0 TX' },
48
+ { key: '2', value: 'GPIO 2' },
49
+ { key: '3', value: 'GPIO 3 - UART 0 RX' },
50
+ { key: '4', value: 'GPIO 4' },
51
+ { key: '5', value: 'GPIO 5' },
52
+ { key: '12', value: 'GPIO 12' },
53
+ { key: '13', value: 'GPIO 13' },
54
+ { key: '14', value: 'GPIO 14' },
55
+ { key: '15', value: 'GPIO 15' },
56
+ { key: '16', value: 'GPIO 16 - UART 1 RX' },
57
+ { key: '17', value: 'GPIO 17 - UART 1 TX' },
58
+ { key: '18', value: 'GPIO 18' },
59
+ { key: '19', value: 'GPIO 19' },
60
+ { key: '21', value: 'GPIO 21' },
61
+ { key: '22', value: 'GPIO 22' },
62
+ { key: '23', value: 'GPIO 23' },
63
+ { key: '25', value: 'GPIO 25' },
64
+ { key: '26', value: 'GPIO 26' },
65
+ { key: '27', value: 'GPIO 27' },
66
+ { key: '32', value: 'GPIO 32 - ADC1 CH4' },
67
+ { key: '34', value: 'GPIO 34 - ADC1 CH6' },
68
+ { key: '35', value: 'GPIO 35 - ADC1 CH7' },
69
+ { key: '36', value: 'GPIO 36 - ADC1 CH0' },
70
+ { key: '39', value: 'GPIO 39 - ADC1 CH3' },
71
+ ];
72
+
73
+ export const ESP32_ANALOG_READ = [
74
+ { key: '36', value: 'GPIO 36 - ADC1 CH0 - A0' },
75
+ { key: '37', value: 'GPIO 37 - ADC1 CH0 - A1' },
76
+ { key: '38', value: 'GPIO 38 - ADC1 CH0 - A2' },
77
+ { key: '39', value: 'GPIO 39 - ADC1 CH0 - A3' },
78
+ { key: '32', value: 'GPIO 32 - ADC1 CH0 - A4' },
79
+ { key: '33', value: 'GPIO 33 - ADC1 CH0 - A5' },
80
+ { key: '34', value: 'GPIO 34 - ADC1 CH0 - A6' },
81
+ { key: '35', value: 'GPIO 35 - ADC1 CH0 - A7' },
82
+ ];
83
+
84
+ export const ESP32_ANALOG_WRITE = [
85
+ { key: '0', value: 'GPIO 0' },
86
+ { key: '1', value: 'GPIO 1 - UART 0 TX' },
87
+ { key: '2', value: 'GPIO 2' },
88
+ { key: '3', value: 'GPIO 3 - UART 0 RX' },
89
+ { key: '4', value: 'GPIO 4' },
90
+ { key: '5', value: 'GPIO 5' },
91
+ { key: '12', value: 'GPIO 12' },
92
+ { key: '13', value: 'GPIO 13' },
93
+ { key: '14', value: 'GPIO 14' },
94
+ { key: '15', value: 'GPIO 15' },
95
+ { key: '16', value: 'GPIO 16 - UART 2 RX' },
96
+ { key: '17', value: 'GPIO 17 - UART 2 TX' },
97
+ { key: '18', value: 'GPIO 18' },
98
+ { key: '19', value: 'GPIO 19' },
99
+ { key: '21', value: 'GPIO 21' },
100
+ { key: '22', value: 'GPIO 22' },
101
+ { key: '23', value: 'GPIO 23' },
102
+ { key: '25', value: 'GPIO 25' },
103
+ { key: '26', value: 'GPIO 26' },
104
+ { key: '27', value: 'GPIO 27' },
105
+ ];
106
+
107
+ // RASPBERRY
108
+
109
+ export const RASPBERRY_PI_DIGITAL = [
110
+ { key: '0', value: 'GPIO 0 - UART TXD' },
111
+ { key: '1', value: 'GPIO 1 - UART RXD' },
112
+ { key: '2', value: 'GPIO 2' },
113
+ { key: '3', value: 'GPIO 3' },
114
+ { key: '4', value: 'GPIO 4 - UART TXD' },
115
+ { key: '5', value: 'GPIO 5 - UART RXD' },
116
+ { key: '6', value: 'GPIO 6' },
117
+ { key: '7', value: 'GPIO 7' },
118
+ { key: '8', value: 'GPIO 8 - UART TXD' },
119
+ { key: '9', value: 'GPIO 9 - UART RXD' },
120
+ { key: '10', value: 'GPIO 10' },
121
+ { key: '11', value: 'GPIO 11' },
122
+ { key: '12', value: 'GPIO 12 - PWM 0 - UART TXD' },
123
+ { key: '13', value: 'GPIO 13 - PWM 1 - UART RXD' },
124
+ { key: '14', value: 'GPIO 14 - UART TXD' },
125
+ { key: '15', value: 'GPIO 15 - UART RXD' },
126
+ { key: '16', value: 'GPIO 16' },
127
+ { key: '17', value: 'GPIO 17' },
128
+ { key: '18', value: 'GPIO 18 - PWM 0' },
129
+ { key: '19', value: 'GPIO 19 - PWM 1' },
130
+ { key: '20', value: 'GPIO 20' },
131
+ { key: '21', value: 'GPIO 21' },
132
+ { key: '22', value: 'GPIO 22' },
133
+ { key: '23', value: 'GPIO 23' },
134
+ { key: '24', value: 'GPIO 24' },
135
+ { key: '25', value: 'GPIO 25' },
136
+ { key: '26', value: 'GPIO 26' },
137
+ { key: '27', value: 'GPIO 27' },
138
+ ];
139
+
140
+ export const RASPBERRY_PI_ANALOG_READ = [];
141
+
142
+ export const RASPBERRY_PI_ANALOG_WRITE = [
143
+ { key: '12', value: 'GPIO 12 - PWM 0 - UART TXD' },
144
+ { key: '13', value: 'GPIO 13 - PWM 1 - UART RXD' },
145
+ { key: '18', value: 'GPIO 18 - PWM 0' },
146
+ { key: '19', value: 'GPIO 19 - PWM 1' },
147
+ ];
148
+
149
+ export const STM32_DIGITAL_READ = [
150
+ { key: '0', value: 'PE1' },
151
+ { key: '1', value: 'PE0' },
152
+ { key: '2', value: 'PB9' },
153
+ { key: '3', value: 'PB8' },
154
+ { key: '4', value: 'PB7' },
155
+ { key: '5', value: 'PB6' },
156
+ { key: '6', value: 'PB5' },
157
+ { key: '7', value: 'PB3' },
158
+ { key: '8', value: 'PD7' },
159
+ { key: '9', value: 'PD6' },
160
+ { key: '10', value: 'PD5' },
161
+ { key: '11', value: 'PD4' },
162
+ { key: '12', value: 'PD3' },
163
+ { key: '13', value: 'PD2' },
164
+ { key: '14', value: 'PD1' },
165
+ { key: '15', value: 'PD0' },
166
+ { key: '16', value: 'PC12' },
167
+ { key: '17', value: 'PC11' },
168
+ { key: '18', value: 'PC10' },
169
+ { key: '19', value: 'PA15' },
170
+ { key: '20', value: 'PA12' },
171
+ { key: '21', value: 'PA11' },
172
+ { key: '22', value: 'PA10' },
173
+ { key: '23', value: 'PA9' },
174
+ { key: '24', value: 'PA8' },
175
+ { key: '25', value: 'PC9' },
176
+ { key: '26', value: 'PC8' },
177
+ { key: '27', value: 'PC7' },
178
+ { key: '28', value: 'PC6' },
179
+ { key: '29', value: 'PD15' },
180
+ { key: '30', value: 'PD14' },
181
+ { key: '31', value: 'PD13' },
182
+ { key: '32', value: 'PD12' },
183
+ { key: '33', value: 'PD11' },
184
+ { key: '34', value: 'PD10' },
185
+ { key: '35', value: 'PD9' },
186
+ { key: '36', value: 'PD8' },
187
+ { key: '37', value: 'PB15' },
188
+ { key: '38', value: 'PE2' },
189
+ { key: '39', value: 'PE3' },
190
+ { key: '40', value: 'PE4' },
191
+ { key: '41', value: 'PE5' },
192
+ { key: '42', value: 'PE6' },
193
+ { key: '43', value: 'PC13' },
194
+ { key: '44', value: 'PC0' },
195
+ { key: '45', value: 'PC1' },
196
+ { key: '46', value: 'PC2' },
197
+ { key: '47', value: 'PC3' },
198
+ { key: '48', value: 'PA0' },
199
+ { key: '49', value: 'PA1' },
200
+ { key: '50', value: 'PA2' },
201
+ { key: '51', value: 'PA3' },
202
+ { key: '52', value: 'PA4' },
203
+ { key: '53', value: 'PA5' },
204
+ { key: '54', value: 'PC4' },
205
+ { key: '55', value: 'PC5' },
206
+ { key: '56', value: 'PB0' },
207
+ { key: '57', value: 'PB1' },
208
+ { key: '58', value: 'PA6' },
209
+ { key: '59', value: 'PA7' },
210
+ { key: '60', value: 'PE7' },
211
+ { key: '61', value: 'PE8' },
212
+ { key: '62', value: 'PE9' },
213
+ { key: '63', value: 'PE10' },
214
+ { key: '64', value: 'PE11' },
215
+ { key: '65', value: 'PE12' },
216
+ { key: '66', value: 'PE13' },
217
+ { key: '67', value: 'PE14' },
218
+ { key: '68', value: 'PE15' },
219
+ { key: '69', value: 'PB10' },
220
+ { key: '70', value: 'PB11' },
221
+ { key: '71', value: 'PB12' },
222
+ { key: '72', value: 'PB13' },
223
+ { key: '73', value: 'PB14' },
224
+ { key: '74', value: 'PB4' },
225
+ ];
226
+ export const STM32_ANALOG_READ = [
227
+ { key: '44', value: 'PCO-A0' },
228
+ { key: '45', value: 'PC1-A1' },
229
+ { key: '46', value: 'PC2-A2' },
230
+ { key: '47', value: 'PC3-A3' },
231
+ { key: '48', value: 'PA0-A4' },
232
+ { key: '49', value: 'PA1-A5' },
233
+ { key: '50', value: 'PA2-A6' },
234
+ { key: '51', value: 'PA3-A7' },
235
+ { key: '52', value: 'PA4-A8' },
236
+ { key: '53', value: 'PA5-A9' },
237
+ { key: '54', value: 'PC4-A10' },
238
+ { key: '55', value: 'PC5-A11' },
239
+ { key: '56', value: 'PB0-A12' },
240
+ { key: '57', value: 'PB1-A13' },
241
+ { key: '58', value: 'PA6-A14' },
242
+ { key: '59', value: 'PA7-A15' },
243
+ ];
244
+ export const STM32_DIGITAL_WRITE = STM32_DIGITAL_READ;
245
+ export const STM32_ANALOG_WRITE = [
246
+ { key: '2', value: 'PB9' },
247
+ { key: '3', value: 'PB8' },
248
+ { key: '4', value: 'PB7' },
249
+ { key: '5', value: 'PB6' },
250
+ { key: '6', value: 'PB5' },
251
+ { key: '7', value: 'PB3' },
252
+ { key: '19', value: 'PA15' },
253
+ { key: '21', value: 'PA11' },
254
+ { key: '22', value: 'PA10' },
255
+ { key: '23', value: 'PA9' },
256
+ { key: '24', value: 'PA8' },
257
+ { key: '25', value: 'PC8' },
258
+ { key: '26', value: 'PC8' },
259
+ { key: '27', value: 'PC7' },
260
+ { key: '28', value: 'PC6' },
261
+ { key: '29', value: 'PD15' },
262
+ { key: '30', value: 'PD14' },
263
+ { key: '31', value: 'PD13' },
264
+ { key: '32', value: 'PD12' },
265
+ { key: '37', value: 'PB15' },
266
+ { key: '41', value: 'PE5' },
267
+ { key: '42', value: 'PE6' },
268
+ { key: '48', value: 'PA0' },
269
+ { key: '49', value: 'PA1' },
270
+ { key: '50', value: 'PA2' },
271
+ { key: '51', value: 'PA3' },
272
+ { key: '53', value: 'PA5' },
273
+ { key: '58', value: 'PA6' },
274
+ { key: '59', value: 'PA7' },
275
+ { key: '61', value: 'PE9' },
276
+ { key: '62', value: 'PE9' },
277
+ { key: '63', value: 'PE10' },
278
+ { key: '64', value: 'PE11' },
279
+ { key: '65', value: 'PE12' },
280
+ { key: '66', value: 'PE13' },
281
+ { key: '67', value: 'PE14' },
282
+ { key: '72', value: 'PB13' },
283
+ { key: '73', value: 'PB14' },
284
+ { key: '74', value: 'PB4' },
285
+ ];
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  import { LocaleConfig } from 'react-native-calendars';
2
3
  import api from '../utils/Apis/axios';
3
4
 
@@ -214,7 +214,6 @@ async function sendCommandSingleAction(connection, ghAction, data) {
214
214
  if (name && data) {
215
215
  message.service_data[name] = data;
216
216
  }
217
-
218
217
  try {
219
218
  await connection.sendMessagePromise(message);
220
219
  return true;
@@ -238,21 +237,13 @@ export async function sendCommandOverHomeAssistant(
238
237
 
239
238
  const connection = getDeviceConnection(connections, device);
240
239
  if (!connection) {
241
- ToastBottomHelper.error(t('command_send_fail_homeassistant'));
240
+ ToastBottomHelper.error(t('home_assistant_device_not_found'));
242
241
  return;
243
242
  }
244
243
 
245
244
  let triggerSuccess;
246
245
 
247
- if (action.googlehome_actions) {
248
- for (let i = 0; i < action.googlehome_actions.length; i++) {
249
- triggerSuccess = await sendCommandSingleAction(
250
- connection,
251
- action.googlehome_actions[i],
252
- data
253
- );
254
- }
255
- } else if (action.googlehome_action) {
246
+ if (action.googlehome_action) {
256
247
  triggerSuccess = await sendCommandSingleAction(
257
248
  connection,
258
249
  action.googlehome_action,
@@ -75,11 +75,6 @@ describe('Remote Control Home Assistant', () => {
75
75
 
76
76
  const action = {
77
77
  id: 1,
78
- googlehome_actions: [
79
- {
80
- message: 'message',
81
- },
82
- ],
83
78
  googlehome_action: {
84
79
  message: 'message',
85
80
  },
@@ -238,38 +233,11 @@ describe('Remote Control Home Assistant', () => {
238
233
  );
239
234
  await sendCommandOverHomeAssistant(connections, sensor, action);
240
235
  expect(connection.sendMessagePromise).toBeCalledWith(
241
- action.googlehome_actions[0].message
236
+ action.googlehome_action.message
242
237
  );
243
238
  });
244
239
 
245
240
  it('Send command over Home Assistant will send message to chip with service_data and data', async () => {
246
- action.googlehome_actions[0].message = {
247
- type: 'call_service',
248
- domain: 'climate',
249
- service: 'set_temperature',
250
- service_data: {
251
- temperature: 0,
252
- entity_id: 'climate.dqsmart_0108f6cdde',
253
- },
254
- id: 20,
255
- };
256
- mock.onPost(API.DEVICE.ACTIVITY_LOG()).reply(200);
257
- const connections = await homeAssistantConnect(
258
- {},
259
- options,
260
- mockEstablished,
261
- mockDisconnected,
262
- mockReconnected
263
- );
264
- await sendCommandOverHomeAssistant(connections, sensor, action, 19);
265
- action.googlehome_actions[0].message.service_data.temperature = 19;
266
- expect(connection.sendMessagePromise).toBeCalledWith(
267
- action.googlehome_actions[0].message
268
- );
269
- });
270
-
271
- it('Send command over Home Assistant action googlehome_action one to one', async () => {
272
- action.googlehome_actions = null;
273
241
  action.googlehome_action.message = {
274
242
  type: 'call_service',
275
243
  domain: 'climate',
@@ -1,7 +1,8 @@
1
1
  import React, { Component } from 'react';
2
- import { Animated, Dimensions, View, ViewPropTypes } from 'react-native';
2
+ import { Animated, Dimensions, View } from 'react-native';
3
3
  import styles from './styles';
4
4
  import { bool, func, number, string } from 'prop-types';
5
+ import {ViewPropTypes} from "deprecated-react-native-prop-types";
5
6
  const window = Dimensions.get('window');
6
7
  const SCROLLVIEW_REF = 'ScrollView';
7
8
  const pivotPoint = (a, b) => a - b;
@@ -11,7 +11,7 @@ import DetailConfigActionZigbee from '../screens/AllGateway/DetailConfigActionZi
11
11
  import DeviceModbusDetail from '../screens/AllGateway/DeviceModbusDetail';
12
12
  import DetailConfigActionModbus from '../screens/AllGateway/DetailConfigActionModbus';
13
13
  import DetailChildConfigActionModbus from '../screens/AllGateway/DetailConfigActionModbus';
14
- import DetailConfigActionInterval from '../screens/AllGateway/DetailConfigActionInternal';
14
+ import DetailConfigActionInternal from '../screens/AllGateway/DetailConfigActionInternal';
15
15
  import Route from '../utils/Route'; // utils/Route
16
16
  import { screenOptions } from './utils';
17
17
 
@@ -52,8 +52,8 @@ export const AllGatewayStack = memo(() => {
52
52
  name={Route.DetailConfigActionZigbee}
53
53
  />
54
54
  <Stack.Screen
55
- component={DetailConfigActionInterval}
56
- name={Route.DetailConfigActionInterval}
55
+ component={DetailConfigActionInternal}
56
+ name={Route.DetailConfigActionInternal}
57
57
  />
58
58
  <Stack.Screen
59
59
  component={DetailConfigActionModbus}