@eohjsc/react-native-smart-city 0.3.31 → 0.3.34
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.
- package/assets/images/AddNewDevice/add-gateway-icon.svg +13 -0
- package/assets/images/AddNewDevice/add-modbus-device-icon.svg +8 -0
- package/assets/images/AddNewDevice/add-wifi-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/add-zigbee-device-icon.svg +4 -0
- package/assets/images/AddNewDevice/interact-smartphone-icon.svg +14 -0
- package/index.js +2 -0
- package/package.json +8 -5
- package/src/Images/SmartAccount/DienQuang.png +0 -0
- package/src/Images/SmartAccount/DienQuang@2x.png +0 -0
- package/src/Images/SmartAccount/DienQuang@3x.png +0 -0
- package/src/Images/SmartAccount/LG.png +0 -0
- package/src/Images/SmartAccount/LG@2x.png +0 -0
- package/src/Images/SmartAccount/LG@3x.png +0 -0
- package/src/Images/SmartAccount/Samsung.png +0 -0
- package/src/Images/SmartAccount/Samsung@2x.png +0 -0
- package/src/Images/SmartAccount/Samsung@3x.png +0 -0
- package/src/commons/Action/ItemQuickAction.js +20 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +35 -11
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +9 -6
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +5 -2
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +10 -4
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +4 -4
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -6
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +8 -4
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -6
- package/src/commons/ActionGroup/OnOffTemplate/index.js +28 -10
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +1 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +25 -12
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/ControlPlay.test.js +13 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/RectangleButton.test.js +9 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/__test__/SmartTiviActionTemplate.test.js +25 -9
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +16 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +10 -4
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/RectangleButton.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +21 -7
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +5 -5
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +4 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +7 -7
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +9 -5
- package/src/commons/ActionGroup/__test__/index.test.js +5 -3
- package/src/commons/ActionTemplate/OnOffButtonAction.js +14 -5
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +23 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
- package/src/commons/ActionTemplate/index.js +1 -0
- package/src/commons/AlertAction/index.js +2 -2
- package/src/commons/Auth/AccountItem.js +9 -3
- package/src/commons/Auth/__test__/AccountItem.test.js +6 -3
- package/src/commons/Automate/ItemAutomate.js +22 -3
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +4 -5
- package/src/commons/Button/index.js +0 -2
- package/src/commons/ButtonPopup/index.js +3 -3
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +4 -2
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +6 -3
- package/src/commons/Dashboard/MyUnit/index.js +5 -3
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DeviceAlertStatus.js +2 -2
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyButton.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +3 -2
- package/src/commons/Device/FlatListItems.js +2 -2
- package/src/commons/Device/ItemAddNew/index.js +7 -12
- package/src/commons/Device/ItemDevice.js +16 -11
- package/src/commons/Device/SensorConnectedStatus.js +5 -2
- package/src/commons/Device/WindDirection/Compass/index.js +5 -2
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +8 -4
- package/src/commons/Device/__test__/FlatListItems.test.js +3 -2
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +4 -2
- package/src/commons/Explore/ActivityIndicator/index.js +5 -2
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +3 -3
- package/src/commons/Explore/SearchBox/index.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +4 -4
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +11 -8
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -2
- package/src/commons/FieldTemplate/PasscodeField/index.js +2 -2
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +12 -7
- package/src/commons/Form/TextInput.js +2 -2
- package/src/commons/Form/TextInputPassword.js +2 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +5 -3
- package/src/commons/GroupCheckBox/index.js +2 -2
- package/src/commons/HeaderAni/index.js +2 -3
- package/src/commons/MediaPlayerDetail/index.js +2 -2
- package/src/commons/MenuActionList/index.js +2 -2
- package/src/commons/MenuActionMore/index.js +2 -3
- package/src/commons/NavBar/index.js +2 -3
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +12 -6
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +7 -3
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +4 -2
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +11 -8
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +9 -5
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +5 -3
- package/src/commons/Popover/index.js +2 -13
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -3
- package/src/commons/PreventAccess/index.js +3 -3
- package/src/commons/{Connecting → Processing}/__test__/Connecting.test.js +5 -4
- package/src/commons/Processing/index.js +93 -0
- package/src/commons/{Connecting → Processing}/styles.js +9 -1
- package/src/commons/SelectGateway/index.js +105 -0
- package/src/commons/SelectGateway/styles.js +55 -0
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +106 -0
- package/src/commons/SelectSubUnit/index.js +124 -0
- package/src/commons/SelectSubUnit/styles.js +52 -0
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +120 -0
- package/src/commons/SelectUnit/index.js +105 -0
- package/src/commons/SelectUnit/styles.js +53 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -4
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +25 -10
- package/src/commons/SubUnit/OneTap/index.js +9 -4
- package/src/commons/SubUnit/ShortDetail.js +11 -29
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +15 -10
- package/src/commons/SummaryItem/index.js +2 -2
- package/src/commons/Tabbar/__test__/index.test.js +97 -0
- package/src/commons/Unit/HeaderUnit/index.js +4 -5
- package/src/commons/Unit/SharedUnit.js +10 -8
- package/src/commons/Unit/__test__/HeaderUnit.test.js +13 -5
- package/src/commons/Unit/__test__/SharedUnit.test.js +30 -11
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +13 -8
- package/src/commons/UnitSummary/AirQuality/index.js +7 -3
- package/src/commons/UnitSummary/TotalPowerBox.js +2 -2
- package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -2
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +3 -2
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/commons/ViewButtonBottom/index.js +4 -4
- package/src/commons/WheelDateTimePicker/index.js +5 -3
- package/src/commons/WrapParallaxScrollView/index.js +2 -1
- package/src/configs/API.js +16 -14
- package/src/configs/AccessibilityLabel.js +629 -0
- package/src/configs/Constants.js +1 -604
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +10 -3
- package/src/context/mockStore.ts +6 -3
- package/src/context/reducer.ts +45 -8
- package/src/hoc/__test__/withRemoteControl.test.js +24 -0
- package/src/hoc/withRemoteControl.js +1 -0
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +55 -0
- package/src/hooks/Common/index.js +2 -2
- package/src/hooks/Common/useDevicesStatus.js +19 -15
- package/src/hooks/Common/{useGGHomeDeviceConnected.js → useHomeAssistantDeviceConnected.js} +3 -3
- package/src/hooks/Common/usePopover.js +6 -1
- package/src/hooks/IoT/__test__/{useGGHomeConnection.test.js → useHomeAssistantConnection.test.js} +18 -18
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +17 -12
- package/src/hooks/IoT/index.js +2 -2
- package/src/hooks/IoT/useHomeAssistantConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +6 -6
- package/src/hooks/__test__/useInitDeepLink.test.js +28 -0
- package/src/hooks/useReceiveNotifications.js +2 -4
- package/src/iot/RemoteControl/{GoogleHome.js → HomeAssistant.js} +21 -17
- package/src/iot/RemoteControl/LG.js +2 -1
- package/src/iot/RemoteControl/__test__/{GoogleHome.test.js → HomeAssistant.test.js} +30 -30
- package/src/navigations/AddDeviceStack.js +0 -14
- package/src/navigations/AddGatewayStack.js +56 -21
- package/src/navigations/Main.js +2 -2
- package/src/navigations/SmartAccountStack.js +52 -0
- package/src/navigations/SmartIrStack.js +3 -3
- package/src/navigations/UnitStack.js +1 -1
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +5 -3
- package/src/screens/AQIGuide/index.js +5 -3
- package/src/screens/ActivityLog/FilterPopup.js +2 -2
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +3 -2
- package/src/screens/ActivityLog/index.js +3 -3
- package/src/screens/AddCommon/SelectSubUnit.js +49 -192
- package/src/screens/AddCommon/SelectUnit.js +58 -204
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +25 -61
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +41 -32
- package/src/screens/AddLocationMaps/__test__/index.test.js +13 -7
- package/src/screens/AddLocationMaps/index.js +3 -3
- package/src/screens/AddNewAction/Device/index.js +2 -2
- package/src/screens/AddNewAction/SelectAction.js +16 -7
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -3
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +8 -3
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -7
- package/src/screens/AddNewAutoSmart/index.js +9 -12
- package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +7 -4
- package/src/screens/AddNewDevice/index.js +4 -4
- package/src/screens/AddNewGateway/ConnectingDevice.js +40 -0
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +61 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +70 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +167 -0
- package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +58 -0
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +16 -8
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +23 -4
- package/src/screens/AddNewGateway/RenameNewDevices.js +141 -0
- package/src/screens/AddNewGateway/RenameNewDevicesStyles.js +75 -0
- package/src/screens/AddNewGateway/ScanGatewayQR.js +80 -0
- package/src/screens/AddNewGateway/ScanModbusQR.js +53 -0
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +55 -0
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +31 -0
- package/src/screens/AddNewGateway/SelectDeviceType.js +147 -0
- package/src/screens/AddNewGateway/SelectDeviceTypeStyles.js +51 -0
- package/src/screens/AddNewGateway/SelectDeviceUnit.js +29 -0
- package/src/screens/AddNewGateway/SelectModbusGateway.js +34 -0
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +34 -0
- package/src/screens/AddNewGateway/ShareWifiPassword.js +198 -0
- package/src/screens/AddNewGateway/ShareWifiPasswordStyles.js +44 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -4
- package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +63 -0
- package/src/screens/AddNewGateway/__test__/{SelectGateway.test.js → ConnectingWifiDevice.test.js} +15 -10
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +224 -0
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +62 -0
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +191 -0
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +72 -0
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +75 -0
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +73 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +47 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +124 -0
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +48 -0
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +77 -0
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +155 -0
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -1
- package/src/screens/AddNewGateway/index.js +4 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +5 -4
- package/src/screens/AddNewOneTap/index.js +4 -4
- package/src/screens/Automate/__test__/index.test.js +2 -2
- package/src/screens/Automate/index.js +6 -2
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +3 -2
- package/src/screens/ConfirmUnitDeletion/index.js +3 -3
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +5 -5
- package/src/screens/Device/EditDevice/index.js +3 -3
- package/src/screens/Device/__test__/detail.test.js +38 -22
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +6 -6
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +28 -22
- package/src/screens/Device/hooks/useEvaluateValue.js +0 -2
- package/src/screens/DeviceInfo/__test__/index.test.js +8 -4
- package/src/screens/DeviceInfo/index.js +10 -6
- package/src/screens/Drawer/index.js +21 -9
- package/src/screens/EditActionsList/__tests__/index.test.js +120 -0
- package/src/screens/EditActionsList/index.js +15 -5
- package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +9 -5
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +7 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -3
- package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +3 -2
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +6 -3
- package/src/screens/EnterPassword/index.js +5 -3
- package/src/screens/GuestInfo/__test__/index.test.js +18 -12
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +2 -2
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +3 -3
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +4 -4
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -3
- package/src/screens/GuestInfo/index.js +1 -1
- package/src/screens/HanetCamera/Detail.js +10 -4
- package/src/screens/HanetCamera/ManageAccess.js +4 -4
- package/src/screens/HanetCamera/MemberInfo.js +1 -1
- package/src/screens/HanetCamera/__test__/Detail.test.js +5 -3
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +10 -4
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +4 -2
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +4 -4
- package/src/screens/MoveToAnotherSubUnit/index.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +9 -6
- package/src/screens/PlayBackCamera/index.js +6 -6
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +10 -3
- package/src/screens/ScriptDetail/__test__/index.test.js +43 -38
- package/src/screens/ScriptDetail/index.js +26 -16
- package/src/screens/SelectUnit/__test__/index.test.js +4 -3
- package/src/screens/SelectUnit/index.js +3 -3
- package/src/screens/SetSchedule/index.js +1 -1
- package/src/screens/SharedUnit/__test__/ShareUnit.test.js +25 -0
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/{SensorItem.js → DeviceItem.js} +40 -30
- package/src/screens/Sharing/Components/Styles/{SensorItemStyles.js → DeviceItemStyles.js} +0 -0
- package/src/screens/Sharing/Components/__test__/{SensorItem.test.js → DeviceItem.test.js} +10 -8
- package/src/screens/Sharing/Components/index.js +2 -2
- package/src/screens/Sharing/InfoMemberUnit.js +7 -6
- package/src/screens/Sharing/MemberList.js +4 -4
- package/src/screens/Sharing/SelectPermission.js +139 -123
- package/src/screens/Sharing/SelectUser.js +9 -5
- package/src/screens/Sharing/Styles/SelectPermissionStyles.js +2 -2
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +3 -2
- package/src/screens/Sharing/__test__/SelectPermission.test.js +67 -14
- package/src/screens/Sharing/__test__/SelectUser.test.js +7 -4
- package/src/screens/SideMenuDetail/__test__/index.test.js +11 -7
- package/src/screens/SideMenuDetail/index.js +2 -2
- package/src/screens/SmartAccount/Connecting/index.js +171 -0
- package/src/{commons/ConnectingProcess/styles.js → screens/SmartAccount/Connecting/style.js} +3 -22
- package/src/screens/SmartAccount/ListDevice/DeviceItem.js +45 -0
- package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +34 -0
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +139 -0
- package/src/screens/SmartAccount/ListDevice/index.js +186 -0
- package/src/screens/SmartAccount/ListDevice/styles/DeviceItemStyles.js +70 -0
- package/src/screens/SmartAccount/ListDevice/styles/index.js +85 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItem.js +37 -0
- package/src/{commons/ConnectingProcess/DeviceItem → screens/SmartAccount/SuccessfullyConnected}/DeviceItemStyles.js +13 -5
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/DeviceItem.test.js +65 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +88 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +101 -0
- package/src/screens/SmartAccount/SuccessfullyConnected/styles.js +42 -0
- package/src/screens/SmartAccount/__test__/Connecting.test.js +86 -0
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +249 -0
- package/src/screens/SmartAccount/index.js +172 -0
- package/src/screens/SmartAccount/style.js +70 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +4 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SmartIr.test.js +14 -6
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +4 -2
- package/src/screens/SmartIr/components/{SelectDeviceType.js → SelectIrDeviceType.js} +2 -2
- package/src/screens/SmartIr/index.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +7 -3
- package/src/screens/SubUnit/Detail.js +6 -6
- package/src/screens/SubUnit/EditSubUnit.js +10 -6
- package/src/screens/SubUnit/ManageSubUnit.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +6 -3
- package/src/screens/SubUnit/__test__/Detail.test.js +5 -3
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +9 -5
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +3 -2
- package/src/screens/SyncLGDevice/AddLGDevice.js +4 -4
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +44 -14
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +4 -2
- package/src/screens/TDSGuide/index.js +2 -2
- package/src/screens/Template/EditTemplate.js +2 -1
- package/src/screens/Template/__test__/detail.test.js +9 -1
- package/src/screens/Template/index.js +0 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +3 -2
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/AddMenu.js +10 -25
- package/src/screens/Unit/ChooseLocation.js +1 -1
- package/src/screens/Unit/Detail.js +10 -10
- package/src/screens/Unit/ManageUnit.js +21 -15
- package/src/screens/Unit/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/SelectAddToFavorites.js +7 -8
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccount.js +8 -5
- package/src/screens/Unit/SmartAccountItem.js +3 -3
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/Station/index.js +2 -2
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +6 -6
- package/src/screens/Unit/__test__/Detail.test.js +17 -12
- package/src/screens/Unit/__test__/ManageUnit.test.js +40 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +15 -8
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -5
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +4 -3
- package/src/screens/Unit/components/AutomateScript/index.js +5 -2
- package/src/screens/Unit/components/ListMyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +9 -5
- package/src/screens/Unit/components/MyAllUnit/index.js +1 -1
- package/src/screens/Unit/components/MyUnitDevice/index.js +8 -5
- package/src/screens/Unit/components/SharedUnit/index.js +12 -6
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +24 -9
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +25 -11
- package/src/screens/UnitSummary/__test__/index.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +5 -4
- package/src/screens/UnitSummary/components/RunningDevices/index.js +6 -3
- package/src/screens/UnitSummary/components/TotalPowerBox/index.js +2 -2
- package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +3 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +4 -2
- package/src/screens/UnitSummary/index.js +10 -8
- package/src/screens/WaterQualityGuide/__test__/index.test.js +17 -12
- package/src/screens/WaterQualityGuide/index.js +26 -10
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.json +36 -11
- package/src/utils/I18n/translations/vi.json +36 -10
- package/src/utils/Route/index.js +19 -10
- package/src/utils/Utils.js +6 -7
- package/src/utils/Validation.js +4 -0
- package/src/commons/Connecting/index.js +0 -67
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +0 -28
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +0 -163
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +0 -19
- package/src/commons/ConnectingProcess/index.js +0 -213
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/iot/RemoteControl/index.js +0 -55
- package/src/screens/AddNewDevice/ConnectDevices.js +0 -184
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -131
- package/src/screens/AddNewGateway/ConnectedGateway.js +0 -139
- package/src/screens/AddNewGateway/ConnectingGateway.js +0 -137
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +0 -214
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +0 -319
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +0 -75
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +0 -130
- package/src/screens/AddNewGateway/SelectGateway.js +0 -133
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -207
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -71
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +0 -96
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -120
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +0 -115
- package/src/screens/ScanChipQR/hooks/index.js +0 -120
- package/src/screens/ScanChipQR/index.js +0 -29
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +0 -111
- package/src/screens/ScanSensorQR/hooks/index.js +0 -40
- package/src/screens/ScanSensorQR/index.js +0 -39
package/src/context/reducer.ts
CHANGED
|
@@ -28,6 +28,7 @@ export type ContextData = {
|
|
|
28
28
|
valueEvaluations: {};
|
|
29
29
|
fetchedValueEvaluationUnits: Array<number>;
|
|
30
30
|
devMode: DevModeType;
|
|
31
|
+
percent: number;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
export type Action = {
|
|
@@ -48,6 +49,7 @@ export const initialState = {
|
|
|
48
49
|
statusBar: {} as StatusBar,
|
|
49
50
|
listDevice: {} as ListDevice,
|
|
50
51
|
listAction: [] as ListAction,
|
|
52
|
+
percent: 0,
|
|
51
53
|
unit: {
|
|
52
54
|
favoriteDeviceIds: [],
|
|
53
55
|
},
|
|
@@ -66,9 +68,12 @@ export const initialState = {
|
|
|
66
68
|
isLockWhenPickColor: false,
|
|
67
69
|
},
|
|
68
70
|
iot: {
|
|
69
|
-
|
|
71
|
+
homeassistant: {
|
|
70
72
|
connections: {},
|
|
71
73
|
},
|
|
74
|
+
lgthinq: {
|
|
75
|
+
unitConnected: [],
|
|
76
|
+
},
|
|
72
77
|
internet: {
|
|
73
78
|
statuses: {},
|
|
74
79
|
},
|
|
@@ -92,6 +97,26 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
92
97
|
return { ...currentState, statusBar: payload };
|
|
93
98
|
case Action.UPDATE_LANGUAGE:
|
|
94
99
|
return { ...currentState, language: payload };
|
|
100
|
+
case Action.PERCENT_LOADED:
|
|
101
|
+
// eslint-disable-next-line no-case-declarations
|
|
102
|
+
const percent =
|
|
103
|
+
currentState.percent < 0.85
|
|
104
|
+
? currentState.percent + (Math.random() * 0.15 + 0.01)
|
|
105
|
+
: currentState.percent;
|
|
106
|
+
return {
|
|
107
|
+
...currentState,
|
|
108
|
+
percent: percent,
|
|
109
|
+
};
|
|
110
|
+
case Action.REFRESH_PERCENT:
|
|
111
|
+
return {
|
|
112
|
+
...currentState,
|
|
113
|
+
percent: 0,
|
|
114
|
+
};
|
|
115
|
+
case Action.PROCESS_DONE:
|
|
116
|
+
return {
|
|
117
|
+
...currentState,
|
|
118
|
+
percent: 1,
|
|
119
|
+
};
|
|
95
120
|
case Action.LIST_DEVICE_TYPES:
|
|
96
121
|
if (currentState.listDevice) {
|
|
97
122
|
currentState.listDevice[action.payload.chipId] = {
|
|
@@ -266,32 +291,44 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
266
291
|
},
|
|
267
292
|
};
|
|
268
293
|
|
|
269
|
-
case Action.
|
|
294
|
+
case Action.SET_HOME_ASSISTANT_CONNECTIONS:
|
|
270
295
|
return {
|
|
271
296
|
...currentState,
|
|
272
297
|
iot: {
|
|
273
298
|
...currentState.iot,
|
|
274
|
-
|
|
275
|
-
...currentState.iot.
|
|
299
|
+
homeassistant: {
|
|
300
|
+
...currentState.iot.homeassistant,
|
|
276
301
|
connections: payload,
|
|
277
302
|
},
|
|
278
303
|
},
|
|
279
304
|
};
|
|
280
|
-
case Action.
|
|
305
|
+
case Action.CHANGE_HOME_ASSISTANT_CONN_STATE:
|
|
281
306
|
return {
|
|
282
307
|
...currentState,
|
|
283
308
|
iot: {
|
|
284
309
|
...currentState.iot,
|
|
285
|
-
|
|
286
|
-
...currentState.iot.
|
|
310
|
+
homeassistant: {
|
|
311
|
+
...currentState.iot.homeassistant,
|
|
287
312
|
connections: {
|
|
288
|
-
...currentState.iot.
|
|
313
|
+
...currentState.iot.homeassistant.connections,
|
|
289
314
|
[payload.option.chip_id]: payload.data,
|
|
290
315
|
},
|
|
291
316
|
},
|
|
292
317
|
},
|
|
293
318
|
};
|
|
294
319
|
|
|
320
|
+
case Action.SET_LG_THINQ_CONNECTED:
|
|
321
|
+
return {
|
|
322
|
+
...currentState,
|
|
323
|
+
iot: {
|
|
324
|
+
...currentState.iot,
|
|
325
|
+
lgthinq: {
|
|
326
|
+
...currentState.iot.lgthinq,
|
|
327
|
+
unitConnected: [...currentState.iot.lgthinq.unitConnected, payload],
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
|
|
295
332
|
case Action.SET_DEVICES_STATUS:
|
|
296
333
|
// eslint-disable-next-line no-case-declarations
|
|
297
334
|
let newStatuses = currentState.iot.internet.statuses;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import { withRemoteControl } from '../index';
|
|
4
|
+
import { SCProvider } from '../../context';
|
|
5
|
+
import { mockSCStore } from '../../context/mockStore';
|
|
6
|
+
|
|
7
|
+
describe('Test withRemoteControl', () => {
|
|
8
|
+
let tree;
|
|
9
|
+
|
|
10
|
+
it('test send remote command action null', async () => {
|
|
11
|
+
const Component = () => <></>;
|
|
12
|
+
const WrappedComponent = withRemoteControl(Component);
|
|
13
|
+
await act(async () => {
|
|
14
|
+
tree = renderer.create(
|
|
15
|
+
<SCProvider initState={mockSCStore({})}>
|
|
16
|
+
<WrappedComponent />
|
|
17
|
+
</SCProvider>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
const instance = tree.root;
|
|
21
|
+
const _Component = instance.findByType(Component);
|
|
22
|
+
expect(_Component.props.sendRemoteCommand).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
4
|
+
import { useAndroidTranslucentStatusBar } from '../index';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const mockedSetAction = jest.fn();
|
|
9
|
+
|
|
10
|
+
const wrapper = ({ children }) => <SCProvider>{children}</SCProvider>;
|
|
11
|
+
|
|
12
|
+
const mockUseContext = jest.fn().mockImplementation(() => ({
|
|
13
|
+
stateData: mockSCStore({}),
|
|
14
|
+
setAction: mockedSetAction,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
React.useContext = mockUseContext;
|
|
18
|
+
|
|
19
|
+
const mockAddListener = jest.fn();
|
|
20
|
+
jest.mock('@react-navigation/native', () => {
|
|
21
|
+
return {
|
|
22
|
+
...jest.requireActual('@react-navigation/native'),
|
|
23
|
+
useNavigation: () => ({
|
|
24
|
+
addListener: mockAddListener,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('test useAndroidTranslucentStatusBar', () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
mockAddListener.mockClear();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('test useAndroidTranslucentStatusBar android', () => {
|
|
35
|
+
Platform.OS = 'android';
|
|
36
|
+
renderHook(
|
|
37
|
+
() => useAndroidTranslucentStatusBar({ background: '#ffffff' }),
|
|
38
|
+
{
|
|
39
|
+
wrapper,
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
expect(mockAddListener).not.toBeCalled();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('test useAndroidTranslucentStatusBar ios', () => {
|
|
46
|
+
Platform.OS = 'ios';
|
|
47
|
+
renderHook(
|
|
48
|
+
() => useAndroidTranslucentStatusBar({ background: '#ffffff' }),
|
|
49
|
+
{
|
|
50
|
+
wrapper,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
expect(mockAddListener).not.toBeCalled();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -5,7 +5,7 @@ import useKeyboardShow from './useKeyboardShow';
|
|
|
5
5
|
import usePopover from './usePopover';
|
|
6
6
|
import useTitleHeader from './useTitleHeader';
|
|
7
7
|
import useDevicesStatus from './useDevicesStatus';
|
|
8
|
-
import
|
|
8
|
+
import useHomeAssistantDeviceConnected from './useHomeAssistantDeviceConnected';
|
|
9
9
|
import { useBlockBackAndroid } from './useBlockBackAndroid';
|
|
10
10
|
import { useIsOwnerOfUnit } from './useIsOwnerOfUnit';
|
|
11
11
|
import { useStatusBar } from './useStatusBar';
|
|
@@ -23,5 +23,5 @@ export {
|
|
|
23
23
|
useStatusBar,
|
|
24
24
|
useGetIdUser,
|
|
25
25
|
useDevicesStatus,
|
|
26
|
-
|
|
26
|
+
useHomeAssistantDeviceConnected,
|
|
27
27
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useContext } from 'react';
|
|
2
|
+
import { InteractionManager } from 'react-native';
|
|
2
3
|
import { useFocusEffect } from '@react-navigation/native';
|
|
3
4
|
import { SCContext, useSCContextSelector } from '../../context';
|
|
4
5
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
@@ -24,30 +25,33 @@ const useDevicesStatus = (unit, devices) => {
|
|
|
24
25
|
params: params,
|
|
25
26
|
}
|
|
26
27
|
);
|
|
27
|
-
|
|
28
|
-
setAction(Action.SET_DEVICES_STATUS, data);
|
|
29
|
-
}
|
|
28
|
+
success && setAction(Action.SET_DEVICES_STATUS, data);
|
|
30
29
|
timeoutId = setTimeout(() => getDevicesStatus(_unit, _devices), 10000);
|
|
31
30
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
31
|
}, []);
|
|
33
32
|
|
|
34
33
|
useFocusEffect(
|
|
35
34
|
useCallback(() => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
const task = InteractionManager.runAfterInteractions(() => {
|
|
36
|
+
if (!devices?.length || !isNetworkConnected) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const managedDevices = devices.filter(
|
|
41
|
+
(device) => device?.is_managed_by_backend
|
|
42
|
+
);
|
|
43
|
+
if (!managedDevices.length) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
timeoutId = setTimeout(
|
|
47
|
+
() => getDevicesStatus(unit, managedDevices),
|
|
48
|
+
200
|
|
49
|
+
);
|
|
50
|
+
});
|
|
48
51
|
|
|
49
52
|
return () => {
|
|
50
53
|
clearTimeout(timeoutId);
|
|
54
|
+
task.cancel();
|
|
51
55
|
};
|
|
52
56
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
57
|
}, [unit, devices, isNetworkConnected])
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useSCContextSelector } from '../../context';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const useHomeAssistantDeviceConnected = (device) => {
|
|
4
4
|
const connections = useSCContextSelector(
|
|
5
|
-
(state) => state.iot.
|
|
5
|
+
(state) => state.iot.homeassistant.connections
|
|
6
6
|
);
|
|
7
7
|
const isNetworkConnected = useSCContextSelector(
|
|
8
8
|
(state) => state.app.isNetworkConnected
|
|
@@ -20,4 +20,4 @@ const useGGHomeDeviceConnected = (device) => {
|
|
|
20
20
|
return { isConnected, isConnecting };
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export default
|
|
23
|
+
export default useHomeAssistantDeviceConnected;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { useCallback, useState, useRef } from 'react';
|
|
1
|
+
import { useCallback, useState, useRef, useContext } from 'react';
|
|
2
|
+
import { SCContext } from '../../context';
|
|
3
|
+
import { Action } from '../../context/actionType';
|
|
2
4
|
|
|
3
5
|
const usePopover = () => {
|
|
4
6
|
const [showingPopover, setShowingPopover] = useState(false);
|
|
5
7
|
const childRef = useRef(null);
|
|
8
|
+
const { setAction } = useContext(SCContext);
|
|
6
9
|
|
|
7
10
|
const showPopoverWithRef = useCallback(
|
|
8
11
|
(ref) => {
|
|
9
12
|
childRef.current = ref.current;
|
|
10
13
|
setShowingPopover(true);
|
|
14
|
+
setAction(Action.SET_POPOVER_ANIMATING, true);
|
|
11
15
|
},
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
17
|
[childRef]
|
|
13
18
|
);
|
|
14
19
|
|
package/src/hooks/IoT/__test__/{useGGHomeConnection.test.js → useHomeAssistantConnection.test.js}
RENAMED
|
@@ -3,7 +3,7 @@ import { act, renderHook } from '@testing-library/react-hooks';
|
|
|
3
3
|
import { createConnection, getStates } from 'home-assistant-js-websocket';
|
|
4
4
|
import MockAdapter from 'axios-mock-adapter';
|
|
5
5
|
import api from '../../../utils/Apis/axios';
|
|
6
|
-
import {
|
|
6
|
+
import { useHomeAssistantConnection } from '../index';
|
|
7
7
|
import { SCProvider } from '../../../context';
|
|
8
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
9
|
import { Action } from '../../../context/actionType';
|
|
@@ -39,7 +39,7 @@ const mockUseContext = jest.fn().mockImplementation(() => ({
|
|
|
39
39
|
|
|
40
40
|
React.useContext = mockUseContext;
|
|
41
41
|
|
|
42
|
-
describe('Test
|
|
42
|
+
describe('Test useHomeAssistantConnection', () => {
|
|
43
43
|
let options;
|
|
44
44
|
|
|
45
45
|
beforeEach(() => {
|
|
@@ -111,26 +111,26 @@ describe('Test useGGHomeConnection', () => {
|
|
|
111
111
|
];
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
it('test
|
|
114
|
+
it('test connectHomeAssistant all connected', async () => {
|
|
115
115
|
let conns = {};
|
|
116
116
|
options.forEach((option) => {
|
|
117
117
|
conns[option.chip_id] = connection;
|
|
118
118
|
createConnection.mockImplementationOnce(() => connection);
|
|
119
119
|
});
|
|
120
|
-
const { result } = renderHook(() =>
|
|
120
|
+
const { result } = renderHook(() => useHomeAssistantConnection(), {
|
|
121
121
|
wrapper,
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
await act(async () => {
|
|
125
|
-
await result.current.
|
|
125
|
+
await result.current.connectHomeAssistant(options);
|
|
126
126
|
});
|
|
127
127
|
expect(mockedSetAction).toBeCalledWith(
|
|
128
|
-
Action.
|
|
128
|
+
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
129
129
|
conns
|
|
130
130
|
);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
it('test
|
|
133
|
+
it('test connectHomeAssistant have chip disconnected', async () => {
|
|
134
134
|
let conns = {};
|
|
135
135
|
conns[options[0].chip_id] = connection;
|
|
136
136
|
conns[options[1].chip_id] = 0;
|
|
@@ -138,15 +138,15 @@ describe('Test useGGHomeConnection', () => {
|
|
|
138
138
|
createConnection.mockImplementationOnce(async () => {
|
|
139
139
|
throw new Error();
|
|
140
140
|
});
|
|
141
|
-
const { result } = renderHook(() =>
|
|
141
|
+
const { result } = renderHook(() => useHomeAssistantConnection(), {
|
|
142
142
|
wrapper,
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
await act(async () => {
|
|
146
|
-
await result.current.
|
|
146
|
+
await result.current.connectHomeAssistant(options);
|
|
147
147
|
});
|
|
148
148
|
expect(mockedSetAction).toBeCalledWith(
|
|
149
|
-
Action.
|
|
149
|
+
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
150
150
|
conns
|
|
151
151
|
);
|
|
152
152
|
});
|
|
@@ -159,17 +159,17 @@ describe('Test useGGHomeConnection', () => {
|
|
|
159
159
|
throw new Error();
|
|
160
160
|
});
|
|
161
161
|
});
|
|
162
|
-
const { result } = renderHook(() =>
|
|
162
|
+
const { result } = renderHook(() => useHomeAssistantConnection(), {
|
|
163
163
|
wrapper,
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
mock.onPost(API.
|
|
166
|
+
mock.onPost(API.HOME_ASSISTANT.CHECK_SEND_EMAIL()).reply(200);
|
|
167
167
|
await act(async () => {
|
|
168
|
-
await result.current.
|
|
168
|
+
await result.current.connectHomeAssistant(options);
|
|
169
169
|
});
|
|
170
170
|
expect(mockedSetAction).toBeCalledTimes(2);
|
|
171
171
|
expect(mockedSetAction).toBeCalledWith(
|
|
172
|
-
Action.
|
|
172
|
+
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
173
173
|
conns
|
|
174
174
|
);
|
|
175
175
|
expect(mockedSetAction).toBeCalledWith(Action.LIST_DEVICE_TYPES, {
|
|
@@ -178,20 +178,20 @@ describe('Test useGGHomeConnection', () => {
|
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
-
it('test
|
|
181
|
+
it('test disconnectHomeAssistant', async () => {
|
|
182
182
|
let conns = {};
|
|
183
183
|
conns[options[0].chip_id] = connection;
|
|
184
184
|
conns[options[1].chip_id] = 0;
|
|
185
185
|
|
|
186
|
-
const { result } = renderHook(() =>
|
|
186
|
+
const { result } = renderHook(() => useHomeAssistantConnection(), {
|
|
187
187
|
wrapper,
|
|
188
188
|
});
|
|
189
189
|
|
|
190
190
|
await act(async () => {
|
|
191
|
-
await result.current.
|
|
191
|
+
await result.current.disconnectHomeAssistant(conns, options);
|
|
192
192
|
});
|
|
193
193
|
expect(mockedSetAction).toBeCalledWith(
|
|
194
|
-
Action.
|
|
194
|
+
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
195
195
|
{}
|
|
196
196
|
);
|
|
197
197
|
});
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
sendCommandOverBluetooth,
|
|
6
6
|
SEND_COMMAND_OVER_BLUETOOTH_FAIL,
|
|
7
7
|
} from '../../../iot/RemoteControl/Bluetooth';
|
|
8
|
-
import {
|
|
8
|
+
import { sendCommandOverHomeAssistant } from '../../../iot/RemoteControl/HomeAssistant';
|
|
9
9
|
import { sendCommandOverInternet } from '../../../iot/RemoteControl/Internet';
|
|
10
10
|
import { sendCommandOverLGThinq } from '../../../iot/RemoteControl/LG';
|
|
11
11
|
import { SCProvider } from '../../../context';
|
|
12
12
|
import { mockSCStore } from '../../../context/mockStore';
|
|
13
13
|
|
|
14
14
|
jest.mock('../../../iot/RemoteControl/Bluetooth');
|
|
15
|
-
jest.mock('../../../iot/RemoteControl/
|
|
15
|
+
jest.mock('../../../iot/RemoteControl/HomeAssistant');
|
|
16
16
|
jest.mock('../../../iot/RemoteControl/Internet');
|
|
17
17
|
jest.mock('../../../iot/RemoteControl/LG');
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ describe('Test useRemoteControl', () => {
|
|
|
32
32
|
|
|
33
33
|
beforeEach(() => {
|
|
34
34
|
sendCommandOverBluetooth.mockClear();
|
|
35
|
-
|
|
35
|
+
sendCommandOverHomeAssistant.mockClear();
|
|
36
36
|
sendCommandOverInternet.mockClear();
|
|
37
37
|
sendCommandOverLGThinq.mockClear();
|
|
38
38
|
|
|
@@ -62,7 +62,7 @@ describe('Test useRemoteControl', () => {
|
|
|
62
62
|
sendRemoteCommand.current(sensor, action, data, userId);
|
|
63
63
|
});
|
|
64
64
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
65
|
-
expect(
|
|
65
|
+
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
66
66
|
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
67
67
|
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
68
68
|
});
|
|
@@ -83,7 +83,7 @@ describe('Test useRemoteControl', () => {
|
|
|
83
83
|
userId
|
|
84
84
|
);
|
|
85
85
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
86
|
-
expect(
|
|
86
|
+
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
87
87
|
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
88
88
|
});
|
|
89
89
|
|
|
@@ -112,7 +112,7 @@ describe('Test useRemoteControl', () => {
|
|
|
112
112
|
'bluetooth'
|
|
113
113
|
);
|
|
114
114
|
expect(sendCommandOverInternet).toBeCalledTimes(1);
|
|
115
|
-
expect(
|
|
115
|
+
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
116
116
|
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
117
117
|
});
|
|
118
118
|
|
|
@@ -135,7 +135,7 @@ describe('Test useRemoteControl', () => {
|
|
|
135
135
|
userId
|
|
136
136
|
);
|
|
137
137
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
138
|
-
expect(
|
|
138
|
+
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
139
139
|
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
140
140
|
});
|
|
141
141
|
|
|
@@ -157,22 +157,27 @@ describe('Test useRemoteControl', () => {
|
|
|
157
157
|
'internet'
|
|
158
158
|
);
|
|
159
159
|
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
160
|
-
expect(
|
|
160
|
+
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
161
161
|
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
it('test send remote command via
|
|
164
|
+
it('test send remote command via homeassistant', async () => {
|
|
165
165
|
action.command_prefer_over_bluetooth = false;
|
|
166
166
|
action.command_prefer_over_googlehome = true;
|
|
167
167
|
const { result: sendRemoteCommand } = renderHook(() => useRemoteControl(), {
|
|
168
168
|
wrapper,
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
sendCommandOverHomeAssistant.mockImplementation(async () => true);
|
|
172
172
|
act(() => {
|
|
173
173
|
sendRemoteCommand.current(sensor, action, data, userId);
|
|
174
174
|
});
|
|
175
|
-
expect(
|
|
175
|
+
expect(sendCommandOverHomeAssistant).toBeCalledWith(
|
|
176
|
+
{},
|
|
177
|
+
sensor,
|
|
178
|
+
action,
|
|
179
|
+
data
|
|
180
|
+
);
|
|
176
181
|
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
177
182
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
178
183
|
expect(sendCommandOverLGThinq).not.toBeCalled();
|
|
@@ -190,7 +195,7 @@ describe('Test useRemoteControl', () => {
|
|
|
190
195
|
sendRemoteCommand.current(sensor, action, data, userId);
|
|
191
196
|
});
|
|
192
197
|
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
193
|
-
expect(
|
|
198
|
+
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
194
199
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
195
200
|
});
|
|
196
201
|
});
|
package/src/hooks/IoT/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import useHomeAssistantConnection from './useHomeAssistantConnection';
|
|
2
2
|
import useRemoteControl from './useRemoteControl';
|
|
3
3
|
import useValueEvaluations from './useValueEvaluation';
|
|
4
4
|
import useWatchConfigs from './useWatchConfigs';
|
|
5
5
|
import useUnwatchLGDeviceConfigControl from './useUnwatchLGDeviceConfigControl';
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
useHomeAssistantConnection,
|
|
9
9
|
useRemoteControl,
|
|
10
10
|
useValueEvaluations,
|
|
11
11
|
useWatchConfigs,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useContext, useCallback } from 'react';
|
|
2
|
+
import { SCContext, useSCContextSelector } from '../../context';
|
|
3
|
+
import { Action } from '../../context/actionType';
|
|
4
|
+
import {
|
|
5
|
+
homeAssistantConnect,
|
|
6
|
+
homeAssistantDisconnect,
|
|
7
|
+
} from '../../iot/RemoteControl/HomeAssistant';
|
|
8
|
+
import { axiosPost } from '../../utils/Apis/axios';
|
|
9
|
+
import { API } from '../../configs';
|
|
10
|
+
|
|
11
|
+
const useHomeAssistantConnection = () => {
|
|
12
|
+
const { setAction } = useContext(SCContext);
|
|
13
|
+
const { connections } = useSCContextSelector(
|
|
14
|
+
(state) => state.iot.homeassistant
|
|
15
|
+
);
|
|
16
|
+
const { listDevice } = useSCContextSelector((state) => state);
|
|
17
|
+
|
|
18
|
+
const onEstablished = useCallback(
|
|
19
|
+
async (newConnections, options) => {
|
|
20
|
+
setAction(Action.SET_HOME_ASSISTANT_CONNECTIONS, newConnections);
|
|
21
|
+
|
|
22
|
+
const isConnected = options.some(
|
|
23
|
+
(option) => !!newConnections[option.chip_id]
|
|
24
|
+
);
|
|
25
|
+
let chipId = options[0].chip_id;
|
|
26
|
+
if (!isConnected) {
|
|
27
|
+
setAction(Action.LIST_DEVICE_TYPES, {
|
|
28
|
+
chipId: chipId,
|
|
29
|
+
sentEmail: true,
|
|
30
|
+
});
|
|
31
|
+
await axiosPost(API.HOME_ASSISTANT.CHECK_SEND_EMAIL(), {
|
|
32
|
+
chip_id: chipId,
|
|
33
|
+
is_connected: false,
|
|
34
|
+
});
|
|
35
|
+
} else if (isConnected && listDevice[chipId]?.sentEmail) {
|
|
36
|
+
setAction(Action.LIST_DEVICE_TYPES, {
|
|
37
|
+
chipId: chipId,
|
|
38
|
+
sentEmail: false,
|
|
39
|
+
});
|
|
40
|
+
await axiosPost(API.HOME_ASSISTANT.CHECK_SEND_EMAIL(), {
|
|
41
|
+
chip_id: chipId,
|
|
42
|
+
is_connected: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
[listDevice]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const onDisconnected = useCallback(async (option) => {
|
|
51
|
+
setAction(Action.CHANGE_HOME_ASSISTANT_CONN_STATE, { option, data: 0 });
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
const onReconnected = useCallback(async (option, connection) => {
|
|
56
|
+
setAction(Action.CHANGE_HOME_ASSISTANT_CONN_STATE, {
|
|
57
|
+
option,
|
|
58
|
+
data: connection,
|
|
59
|
+
});
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, []);
|
|
62
|
+
|
|
63
|
+
const connectHomeAssistant = useCallback(
|
|
64
|
+
async (options) => {
|
|
65
|
+
await homeAssistantConnect(
|
|
66
|
+
connections,
|
|
67
|
+
options,
|
|
68
|
+
onEstablished,
|
|
69
|
+
onDisconnected,
|
|
70
|
+
onReconnected
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
[connections, onEstablished, onDisconnected, onReconnected]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const disconnectHomeAssistant = useCallback(
|
|
77
|
+
async (options) => {
|
|
78
|
+
await homeAssistantDisconnect(connections, options);
|
|
79
|
+
setAction(Action.SET_HOME_ASSISTANT_CONNECTIONS, {});
|
|
80
|
+
},
|
|
81
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
|
+
[connections]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
connectHomeAssistant,
|
|
87
|
+
disconnectHomeAssistant,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default useHomeAssistantConnection;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { useSCContextSelector } from '../../context';
|
|
3
|
-
import {
|
|
3
|
+
import { sendCommandOverHomeAssistant } from '../../iot/RemoteControl/HomeAssistant';
|
|
4
4
|
import { sendCommandOverInternet } from '../../iot/RemoteControl/Internet';
|
|
5
5
|
import {
|
|
6
6
|
sendCommandOverBluetooth,
|
|
@@ -10,8 +10,8 @@ import { ToastBottomHelper } from '../../utils/Utils';
|
|
|
10
10
|
import { t } from 'i18n-js';
|
|
11
11
|
|
|
12
12
|
const useRemoteControl = () => {
|
|
13
|
-
const
|
|
14
|
-
(state) => state.iot.
|
|
13
|
+
const homeAssistantConnections = useSCContextSelector(
|
|
14
|
+
(state) => state.iot.homeassistant.connections
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const sendRemoteCommand = useCallback(
|
|
@@ -58,8 +58,8 @@ const useRemoteControl = () => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (action.command_prefer_over_googlehome && !result) {
|
|
61
|
-
result = await
|
|
62
|
-
|
|
61
|
+
result = await sendCommandOverHomeAssistant(
|
|
62
|
+
homeAssistantConnections,
|
|
63
63
|
sensor,
|
|
64
64
|
action,
|
|
65
65
|
data
|
|
@@ -67,7 +67,7 @@ const useRemoteControl = () => {
|
|
|
67
67
|
}
|
|
68
68
|
return result;
|
|
69
69
|
},
|
|
70
|
-
[
|
|
70
|
+
[homeAssistantConnections]
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
return sendRemoteCommand;
|