diff --git a/custom_components/hikvision_next/config_flow.py b/custom_components/hikvision_next/config_flow.py index 0cd3c53..46d984c 100755 --- a/custom_components/hikvision_next/config_flow.py +++ b/custom_components/hikvision_next/config_flow.py @@ -54,15 +54,19 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Flo if user_input is not None: try: - host = user_input[CONF_HOST] + host = user_input[CONF_HOST].rstrip("/") username = user_input[CONF_USERNAME] password = user_input[CONF_PASSWORD] + user_input_validated = { + **user_input, + CONF_HOST: host, + } isapi = ISAPI(host, username, password) await isapi.get_device_info() if self._reauth_entry: - self.hass.config_entries.async_update_entry(self._reauth_entry, data=user_input) + self.hass.config_entries.async_update_entry(self._reauth_entry, data=user_input_validated) self.hass.async_create_task(self.hass.config_entries.async_reload(self._reauth_entry.entry_id)) return self.async_abort(reason="reauth_successful") @@ -82,7 +86,7 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Flo _LOGGER.error("Unexpected %s %s", {type(ex).__name__}, ex) errors["base"] = f"Unexpected {type(ex).__name__}: {ex}" else: - return self.async_create_entry(title=isapi.device_info.name, data=user_input) + return self.async_create_entry(title=isapi.device_info.name, data=user_input_validated) schema = await self.get_schema(user_input or {}) return self.async_show_form(step_id="user", data_schema=schema, errors=errors) diff --git a/tests/fixtures/devices/DS-2CD2146G2-ISU.json b/tests/fixtures/devices/DS-2CD2146G2-ISU.json new file mode 100644 index 0000000..e63ce3f --- /dev/null +++ b/tests/fixtures/devices/DS-2CD2146G2-ISU.json @@ -0,0 +1,1773 @@ +{ + "data": { + "ISAPI": { + "System/deviceInfo": { + "response": { + "DeviceInfo": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "deviceName": "IP CAMERA", + "deviceID": "d2d94000-f70b-00b0-00a0-acb00f000000", + "deviceDescription": "IPCamera", + "deviceLocation": "hangzhou", + "systemContact": "Hikvision.China", + "model": "DS-2CD2146G2-ISU", + "serialNumber": "DS-2CD2146G2-ISU00000000AAWRG00000000", + "macAddress": "cb:6e:4f:d0:7b:1f", + "firmwareVersion": "V5.7.17", + "firmwareReleasedDate": "build 240606", + "encoderVersion": "V7.3", + "encoderReleasedDate": "build 240516", + "bootVersion": "V1.3.4", + "bootReleasedDate": "100316", + "hardwareVersion": "0x0", + "deviceType": "IPCamera", + "telecontrolID": "88", + "supportBeep": "false", + "supportVideoLoss": "false", + "firmwareVersionInfo": "B-R-G5-0", + "manufacturer": "hikvision", + "subSerialNumber": "G00000000", + "OEMCode": "1" + } + } + }, + "System/capabilities": { + "response": { + "DeviceCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "SysCap": { + "isSupportDst": "true", + "NetworkCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "isSupportWireless": "false", + "isSupportPPPoE": "true", + "isSupportBond": "false", + "isSupport802_1x": "true", + "isSupportNtp": "true", + "isSupportFtp": "true", + "isSupportUpnp": "true", + "isSupportDdns": "true", + "isSupportHttps": "true", + "SnmpCap": { + "isSupport": "true" + }, + "isSupportExtNetCfg": "false", + "isSupportIPFilter": "true", + "isSupportEZVIZ": "true", + "isSupportEhome": "true", + "isSupportWirelessDial": "false", + "isSupportWirelessServer": "false", + "isSupportWPS": "false", + "isWirelessMutexWithWirelessServer": "false", + "isSupportMACFilter": "true", + "isSupportRFIDData": "false", + "isSupportwifiProbeSSID": "false", + "isSupportWifiProbe": "false", + "verificationCode": { + "@min": "6", + "@max": "12" + }, + "VerificationCodeModification": { + "verificationCodeType": { + "@opt": "normal,empty", + "#text": "normal" + }, + "isSupportDeclarationURL": "true", + "isSupportPrivacyPolicyURL": "true", + "verificationCodeModify": { + "@opt": "true,false", + "#text": "true" + }, + "Hyperlinks": { + "declarationURL": "https://www.hik-connect.com/views/terms/termsofservice.html", + "privacyPolicyURL": "https://www.hik-connect.com/views/terms/privacypolicy.html" + } + }, + "isSupportIntegrate": "true", + "isSupportPlatformAccess": "false", + "isSupportGetLinkSocketIP": "true", + "isSupportWebSocket": "true", + "isSupportWebSocketS": "true", + "isSupportVideoImgDB": "false", + "isSupportDynamicHostName": "true", + "isSupportEmailEncrypt": "true" + }, + "IOCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "IOInputPortNums": "1", + "IOOutputPortNums": "1", + "isSupportStrobeLamp": "false" + }, + "SerialCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "rs485PortNums": "0", + "supportRS232Config": "true", + "rs422PortNums": "0", + "rs232PortNums": "1" + }, + "VideoCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "videoInputPortNums": "0", + "videoOutputPortNums": "0", + "isSupportHeatmap": "false", + "isSupportCounting": "false", + "isSupportPicture": "false", + "isSupportPrivacyMask": "true", + "isSupportBinocularPreviewSwitch": "false", + "isSupportCalibCheck": "false", + "isSupportPIP": "false", + "OSDLanguage": { + "@opt": "GBK,EUC-KR,Hebrew", + "@def": "GBK" + }, + "isSupportVideoOutputMode": "false" + }, + "AudioCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "audioInputNums": "1", + "audioOutputNums": "1" + }, + "isSupportExternalDevice": "false", + "isSupportSubscribeEvent": "true", + "isSupportDiagnosedData": "true", + "isSupportMetadata": "true", + "supportSmartOverlapChannles": { + "@opt": "1" + } + }, + "voicetalkNums": "1", + "isSupportSnapshot": "true", + "SecurityCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "supportUserNums": "32", + "userBondIpNums": "0", + "userBondMacNums": "0", + "isSupCertificate": "true", + "issupIllegalLoginLock": "true", + "isSupportOnlineUser": "true", + "isSupportAnonymous": "false", + "isSupportStreamEncryption": "false", + "securityVersion": { + "@opt": "1" + }, + "keyIterateNum": "100", + "isSupportUserCheck": "true", + "isSupportSecurityQuestionConfig": "true", + "supportSecurityNode": { + "@opt": "wirelessDial" + }, + "SecurityLimits": { + "LoginPasswordLenLimit": { + "@min": "1", + "@max": "16" + }, + "SecurityAnswerLenLimit": { + "@min": "1", + "@max": "128" + } + }, + "RSAKeyLength": { + "@opt": "1024,2048", + "@def": "2048" + }, + "isSupportONVIFUserManagement": "true", + "isSupportGB35114Certificate": "false", + "isSupportSIPCertificatesManagement": "false", + "WebCertificateCap": { + "CertificateType": { + "@opt": "digest,digest/basic" + }, + "SecurityAlgorithm": { + "algorithmType": { + "@opt": "MD5,SHA256,MD5/SHA256" + } + } + }, + "isSupportConfigFileImport": "true", + "isSupportConfigFileExport": "true", + "cfgFileSecretKeyLenLimit": { + "@min": "1", + "@max": "16" + }, + "isSupportPasswordProtection": ["true", "true"], + "isIrreversible": "true", + "salt": "3d45e398cf30552e35c756c66cc7e788b498cc316901108ab95a9af6885b6f19", + "isSupportOnvifInfo": "true", + "isSupportDeviceCertificatesManagement": "true", + "isSupportDeviceSelfSignCertExport": "true", + "isSupportSecurityEmail": "true", + "maxIllegalLoginTimes": { + "@min": "3", + "@max": "20", + "@def": "7" + }, + "SecurityAdvanced": { + "noOperationEnabled": "true", + "noOperationTime": { + "@min": "1", + "@max": "60", + "@def": "15" + } + }, + "LoginLinkNum": { + "maxLinkNum": { + "@min": "1", + "@max": "128", + "@def": "50" + } + }, + "isSupportCertificateCustomID": "true", + "isSupportEncryptCertificate": "true", + "maxIllegalLoginLockTime": { + "@min": "1", + "@max": "120", + "@def": "30" + }, + "isSupportSoftwareLicense": "true" + }, + "EventCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "isSupportHDFull": "true", + "isSupportHDError": "true", + "isSupportNicBroken": "true", + "isSupportIpConflict": "true", + "isSupportIllAccess": "true", + "isSupportViException": "false", + "isSupportViMismatch": "false", + "isSupportRecordException": "false", + "isSupportTriggerFocus": "false", + "isSupportMotionDetection": "true", + "isSupportVideoLoss": "false", + "isSupportTamperDetection": "true", + "isSupportStudentsStoodUp": "false", + "isSupportFramesPeopleCounting": "false", + "isSupportPersonQueueDetection": "false", + "isSupportFaceContrast": "false", + "isSupportFaceLib": "false", + "isSupportFaceSnap": "false", + "isSupportPersonDensityDetection": "false", + "isSupportTeacherBehaviorDetect": "false", + "isSupportCityManagement": "false", + "isSupportMixedTargetDetection": "false", + "isSupportFaceSnapModeling": "false", + "isSupportIntersectionAnalysis": "false", + "isSupportLuma": "false", + "isSupportChroma": "false", + "isSupportSnow": "false", + "isSupportStreak": "false", + "isSupportFreeze": "false", + "isSupportSigLose": "false", + "isSupportClarity": "false", + "isSupportJitter": "false", + "isSupportBlock": "false", + "isSupportFlowers": "false", + "isSupportNoise": "false", + "isSupportGhost": "false", + "isSupportPurple": "false", + "isSupportICR": "false", + "isSupportProtectiveFilm": "false" + }, + "RacmCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "nasNums": "8", + "pictureSearchType": { + "@opt": "allPic,CMR,MOTION,ALARM,LineDetection,FieldDetection,scenechangedetection,regionEntrance,regionExiting" + }, + "recordSearchType": { + "@opt": "CMR,MOTION,ALARM,EDR,ALARMANDMOTION,LineDetection,FieldDetection,scenechangedetection,regionEntrance,regionExiting,AllEvent" + }, + "SecurityLog": { + "isSupportSecurityLog": "true", + "isSupportLogServer": "true", + "isSupportLogServerTest": "true", + "SecurityLogTypeList": { + "SecurityLogType": [ + { + "primaryType": "All", + "secondaryType": { + "@opt": "all" + } + }, + { + "primaryType": "Operation", + "secondaryType": { + "@opt": "all,alarmSmsSend,callOnline,devicePowerOff,devicePowerOn,deviceRecycle,localAddIpc,localAddNas,localUserManagement,localCfgSecurity,localCfgNetwork,localCfgTime,localCfgPara,localCtrlPtz,localDelIpc,localDelNas,localDial,localDialParaSet,localDialScheduleSet,localDownloadCfgFile,localDownloadCountingFile,localDownloadHeatMapFile,localDownloadPicFile,localDownloadRecFile,localExportBlackWhiteListFile,localExportIpcCfg,localFormatDisk,localHdTest,localImportBlackWhiteListFile,localImportIpcCfg,localIpcUpgrade,localLock,localLockFile,localLogOut,localLogin,localManulAlarm,localPin,localPlayByFile,localPlayByTime,localResetPasswd,localSetIpc,localSetNas,localSetSIPServer,localSetSnmp,localSmsRead,localSmsSearch,localSmsSend,localSpareOperate,localStartPicRec,localStartRec,localStopPicRec,localStopRec,localTagOperation,localUnlock,localUnlockFile,localUpdate,localUploadCfgFile,localWhitelistSet,platOper,remoteAddIpc,remoteAddNas,remoteArm,remotecfgauditpolicy,remoteUserManagement,remoteCfgSecurity,remoteCfgNetwork,remoteCfgTime,remoteCfgPara,remoteCreateCloudStoragePool,remoteCtrlPtz,remoteDelHdisk,remoteDelIpc,remoteDelNas,remoteDeleteCloudStoragePool,remoteDeletePic,remoteDeleteRecord,remoteDialConnect,remoteDialDisconn,remoteDialParaSet,remoteDialScheduleSet,remoteDisArm,remoteDisableCloudStorage,remoteDownloadCfgFile,remoteDownloadRecFile,remoteEnableCloudStorage,remoteExportBlackWhiteListFile,remoteExportIpcCfg,remoteFormatHd,remoteGetParaSecurity,remoteGetParaNetwork,remoteGetPara,remoteGetStatus,remoteImportBlackWhiteListFile,VcaLibRestore,remoteImportIpcCfg,remoteLoadHdisk,remoteLockFile,remoteLogin,remoteLogout,remoteManulAlarm,remoteModCloudStorageParam,remoteModCloudStorageVolume,remotePicBackUp,remotePin,remotePlayByFile,remotePlayByTime,remotePowerOff,remotePowerRecycle,remoteSetIpc,remoteSetNas,remoteSetSIPServer,remoteSetSnmp,remoteSmsRead,remoteSmsSearch,remoteSmsSend,remoteSpareOperate,remoteStartPicRec,remoteStartRec,remoteStartTransChan,remoteStopPicRec,remoteStopRec,remoteStopTransChan,remoteTagOperation,remoteUnloadHdisk,remoteUnlockFile,remoteUpgrade,remoteUploadCfgFile,remoteWhitelistSet,remotelIpcUpgrade,smsControl,smsRecv,startVoiceTalk,stopAbnormal,stopVoiceTalk,localSetDeviceActive,localParamSimpleDefault,localParamFactoryDefault,remoteSetDeviceActive,remoteParamSimpleDefault,remoteParamFactoryDefault,localWPSLink,remoteWPSLink,localResetLoginPassWord,remoteResetLoginPassWord,localfaceBaseCreate,localfaceBaseModify,localfaceBaseDelete,localfaceDataAppend,localfaceDataEdit,localfaceDataDelete,localVcaAnalysisConfig,remotefaceBaseCreate,remotefaceBaseModify,remotefaceBaseDelete,remotefaceDataAppend,remotefaceDataEdit,remotefaceDataDelete,remoteVcaAnalysisConfig,localClusterNetworkConfig,localClusterAddDevice,localClusterDelDevice,remoteClusterNetworkConfig,remoteClusterAddDevice,remoteClusterDelDevice,localSetPoeWorkMode,remoteSetPoeWorkMode,localClusterModeConfig,remoteClusterModeConfig,localIOTCfgFileInput,localIOTCfgFileOutput,localIOTAdd,localIOTDelete,localIOTSet,remoteIOTCfgFileInput,remoteIOTCfgFileOutput,remoteIOTAdd,remoteIOTDelete,remoteIOTSet,localCheckTime,remoteCheckTime,remoteFaceContrastTask,unlockSession,terminateHttp,terminateHttps,terminateSSH,selfTest,remoterecplan,singlecertification" + } + }, + { + "primaryType": "Event", + "secondaryType": { + "@opt": "all,anrRecordException,dialException,hdError,hdFull,illlegealAccess,ipConflict,ipcDisconnect,ipcIpConfilict,ipcmCrash,netBroken,poePowerException,recordError,recordOverFLow,spareException,startIpcMasException,uploadDataCsException,viAndResMismatch,videoException,videoFormatMismatch,videoLost,syncIPCPasswd,ezvizOffline,SDCardAbnormal,SDCardDamage,plateAbnormal,abnormalPort,POC,vcaCameraAngleAnomaly,dataDiskError,intelligentSystemRunningError,facesnapResolutionOverflow,SMDResolutionOverflow,clusterConfigFailed,clusterStorFullException,clusterOfflineNodeException,clusterRecordCycleException,clusterIPCTransferException,vcaSenceException,ClusterDeviceOffline,clusterDisasterToleranceExcept,clusterVersionException,getSubStreamFailure,locked,hddSHMDetectException,safetyHelmetException,faceModelException,validateCert,establishSecSession,replayAttacks,ntpCheckTime,lowAuditLogStorage,httpConnect,httpsConnect,sshConnect,httpDisconnect,httpsDisconnect,sshDisconnect,signcheck35114" + } + }, + { + "primaryType": "Other", + "secondaryType": { + "@opt": "all" + } + } + ] + } + }, + "isSupportRacmChannelsCap": { + "@opt": "true,false", + "#text": "true" + } + }, + "SmartCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "isSupportROI": "true", + "isSupportAudioDetection": "false", + "isSupportFaceDetect": "false", + "isSupportLineDetection": "true", + "isSupportFieldDetection": "true", + "isSupportRegionEntrance": "true", + "isSupportRegionExiting": "true", + "isSupportLoitering": "false", + "isSupportGroup": "false", + "isSupportRapidMove": "false", + "isSupportParking": "false", + "isSupportUnattendedBaggage": "false", + "isSupportAttendedBaggage": "false", + "isSupportSmartCalibration": "true", + "isSupportIntelliTrace": "false", + "isSupportPeopleDetection": "false", + "isSupportDefocusDetection": "false", + "isSupportSceneChangeDetection": "true", + "isSupportStorageDetection": "false", + "isSupportChannelResource": "false" + }, + "WLAlarmCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "isSupportTeleControl": "false", + "isSupportPIR": "false", + "isSupportWLSensors": "false", + "isSupportCallHelp": "false", + "WLSensorsNum": "8" + }, + "isSupportGIS": "false", + "isSupportCompass": "false", + "isSupportRoadInfoOverlays": "false", + "TestCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "isSupportFTPTest": "true", + "isSupportPingTest": "true", + "isSupportNTPTest": "true", + "isSupportNASTest": "true", + "isSupportEmailTest": "true" + }, + "PanoramaCap": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "isSupportGeneratePanorama": "false", + "isSupportPanoramaPosition3D": "false", + "isSupportPreset": "false" + }, + "isSupportFaceCaptureStatistics": "false", + "isSupportElectronicsEnlarge": "true", + "isSupportTraffic": "false", + "isSupportRtspOverHTTPS": "true", + "isSupportFirmwareVersionInfo": "true", + "isSupportLaserSpotManual": "false", + "isSupportSetupCalibration": "false", + "isSupportPicInfoOverlap": "true", + "isOnlySupportAnalogChannel": "true", + "isSupportChannelEventCap": "true", + "isSupportChannelEventListCap": "true", + "VCAResourceChannelsCap": { + "ChannelsList": { + "channelsID": "1" + } + }, + "supportSnapshotChannel": { + "@opt": "1", + "#text": "1" + }, + "isSupportGPSCalibratation": "false", + "isSupportGPSLabelTracking": "false", + "isSupportCalibrationStream": "false", + "isSupportActiveMulticast": "true", + "isSupportChannelFullEventCap": "true", + "isSupportAUXInfoCap": "true", + "isSupportVehicleMonitor": "false", + "isSupportManualVehicleMonitor": "false", + "isSupportSnapshotAsync": "true", + "isSupportConvergenceCloud": "true", + "isSupportAutoMaintenance": "true", + "isSupportSIMCardStatus": "false", + "isSupportISUPHttpPassthrough": "true", + "DualVCA": { + "overlapRangeType": { + "@opt": "ruleRegion,fullScreen", + "#text": "ruleRegion" + } + }, + "isSupportPosOverlayTest": "true", + "isSupportFullScreenPosOverlay": "true", + "isSupportFullScreenPosOverlayCap": "true", + "isSupportTOFShelterAlarm": "false", + "isSupportT1Test": "true" + } + } + }, + "System/IO/inputs/1/status": { + "response": { + "IOPortStatus": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "ioPortID": "1", + "ioPortType": "input", + "ioState": "inactive" + } + } + }, + "System/IO/outputs/1/status": { + "response": { + "IOPortStatus": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "ioPortID": "1", + "ioPortType": "output", + "ioState": "inactive" + } + } + }, + "System/Holidays": { + "status_code": 404 + }, + "System/Video/inputs/channels": { + "response": { + "VideoInputChannelList": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "VideoInputChannel": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "inputPort": "1", + "name": "Terrasse", + "videoFormat": "PAL" + } + } + } + }, + "ContentMgmt/InputProxy/channels": { + "status_code": 403 + }, + "ContentMgmt/Storage": { + "response": { + "storage": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "hddList": { + "@version": "1.0", + "@xmlns": "http://www.hikvision.com/ver10/XMLSchema", + "@size": "8" + }, + "nasList": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "nas": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "9", + "addressingFormatType": "ipaddress", + "ipAddress": "1.0.0.127", + "portNo": "0", + "nasType": "NFS", + "path": "/volume2/Cameras", + "status": "offline", + "capacity": "0", + "freeSpace": "0", + "property": "RW", + "mountType": "NFS", + "Encryption": { + "encryptionStatus": { + "@opt": "unencrypted,encrypted,verfyFailed", + "#text": "unencrypted" + } + } + }, + "supportMountType": { + "@opt": "NFS,SMB/CIFS" + }, + "authentication": { + "@opt": "SMB/CIFS" + } + }, + "workMode": "quota" + } + } + }, + "Security/adminAccesses": { + "response": { + "AdminAccessProtocolList": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "AdminAccessProtocol": [ + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "enabled": "true", + "protocol": "HTTP", + "portNo": "80" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "2", + "enabled": "true", + "protocol": "HTTPS", + "redirectToHttps": "false", + "portNo": "443", + "TLS1_1Enable": "false", + "TLS1_2Enable": "true", + "TLS1_3Enable": "true" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "3", + "enabled": "true", + "protocol": "DEV_MANAGE", + "portNo": "8000" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "4", + "enabled": "true", + "protocol": "RTSP", + "portNo": "554" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "5", + "enabled": "true", + "protocol": "SDK_OVER_TLS", + "portNo": "8443" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "6", + "enabled": "true", + "protocol": "WebSocket", + "portNo": "7681" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "7", + "enabled": "false", + "protocol": "WebSocketS", + "portNo": "7682" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "8", + "enabled": "false", + "protocol": "SRTP", + "portNo": "322" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "10", + "enabled": "true", + "protocol": "Bonjour" + } + ] + } + } + }, + "Event/triggers": { + "response": { + "EventTriggerList": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "EventTrigger": [ + { + "id": "IO-1", + "eventType": "IO", + "eventDescription": "IO Event trigger Information", + "inputIOPortID": "1", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + } + }, + { + "id": "VMD-1", + "eventType": "VMD", + "eventDescription": "VMD Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + }, + { + "id": "FTP", + "notificationMethod": "FTP", + "notificationRecurrence": "beginning" + } + ] + } + }, + { + "id": "tamper-1", + "eventType": "tamperdetection", + "eventDescription": "shelteralarm Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + } + }, + { + "id": "diskfull", + "eventType": "diskfull", + "eventDescription": "exception Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + } + }, + { + "id": "diskerror", + "eventType": "diskerror", + "eventDescription": "exception Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + } + }, + { + "id": "nicbroken", + "eventType": "nicbroken", + "eventDescription": "exception Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": null + }, + { + "id": "ipconflict", + "eventType": "ipconflict", + "eventDescription": "exception Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": null + }, + { + "id": "illaccess", + "eventType": "illaccess", + "eventDescription": "exception Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + } + }, + { + "id": "linedetection-1", + "eventType": "linedetection", + "eventDescription": "Linedetection Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + }, + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + }, + { + "id": "FTP", + "notificationMethod": "FTP", + "notificationRecurrence": "beginning" + } + ] + } + }, + { + "id": "fielddetection-1", + "eventType": "fielddetection", + "eventDescription": "fielddetection Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + }, + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + }, + { + "id": "FTP", + "notificationMethod": "FTP", + "notificationRecurrence": "beginning" + } + ] + } + }, + { + "id": "badvideo", + "eventType": "badvideo", + "eventDescription": "exception Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + }, + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + ] + } + }, + { + "id": "regionEntrance-1", + "eventType": "regionEntrance", + "eventDescription": "RegionEntrance Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + }, + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + }, + { + "id": "FTP", + "notificationMethod": "FTP", + "notificationRecurrence": "beginning" + } + ] + } + }, + { + "id": "regionExiting-1", + "eventType": "regionExiting", + "eventDescription": "RegionExiting Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + }, + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + }, + { + "id": "FTP", + "notificationMethod": "FTP", + "notificationRecurrence": "beginning" + } + ] + } + }, + { + "id": "storageDetection-1", + "eventType": "storageDetection", + "eventDescription": "storageDetection Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + } + } + } + ] + } + } + }, + "Event/triggers/scenechangedetection-1": { + "response": { + "EventTrigger": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "scenechangedetection-1", + "eventType": "scenechangedetection", + "eventDescription": "scenechangedetection Event trigger Information", + "videoInputChannelID": "1", + "dynVideoInputChannelID": "1", + "EventTriggerNotificationList": { + "EventTriggerNotification": [ + { + "id": "record-1", + "notificationMethod": "record", + "notificationRecurrence": "beginning", + "videoInputID": "1" + }, + { + "id": "center", + "notificationMethod": "center", + "notificationRecurrence": "beginning" + } + ] + } + } + } + }, + "Event/notification/httpHosts": { + "response": { + "HttpHostNotificationList": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "HttpHostNotification": [ + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "url": "/api/hikvision", + "protocolType": "HTTP", + "parameterFormatType": "XML", + "addressingFormatType": "ipaddress", + "ipAddress": "1.0.0.144", + "portNo": "8123", + "userName": null, + "httpAuthenticationMethod": "none", + "httpBroken": "true" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "2", + "url": "/", + "protocolType": "HTTP", + "parameterFormatType": "XML", + "addressingFormatType": "ipaddress", + "ipAddress": "0.0.0.0", + "portNo": "80", + "userName": null, + "httpAuthenticationMethod": "none", + "httpBroken": "true" + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "3", + "url": "/", + "protocolType": "HTTP", + "parameterFormatType": "XML", + "addressingFormatType": "ipaddress", + "ipAddress": "0.0.0.0", + "portNo": "80", + "userName": null, + "httpAuthenticationMethod": "none", + "httpBroken": "true" + } + ] + } + } + }, + "Streaming/channels/101": { + "response": { + "StreamingChannel": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "101", + "channelName": "Terrasse", + "enabled": "true", + "Transport": { + "maxPacketSize": "1000", + "ControlProtocolList": { + "ControlProtocol": [ + { + "streamingTransport": "RTSP" + }, + { + "streamingTransport": "HTTP" + }, + { + "streamingTransport": "SHTTP" + }, + { + "streamingTransport": "SRTP" + } + ] + }, + "Unicast": { + "enabled": "true", + "rtpTransportType": "RTP/TCP" + }, + "Multicast": { + "enabled": "true", + "destIPAddress": "0.0.0.0", + "videoDestPortNo": "8860", + "audioDestPortNo": "8862" + }, + "Security": { + "enabled": "true", + "certificateType": "digest/basic", + "SecurityAlgorithm": { + "algorithmType": "MD5" + } + }, + "SRTPMulticast": { + "SRTPVideoDestPortNo": "18860", + "SRTPAudioDestPortNo": "18862" + } + }, + "Video": { + "enabled": "true", + "videoInputChannelID": "1", + "videoCodecType": "H.264", + "videoScanType": "progressive", + "videoResolutionWidth": "2688", + "videoResolutionHeight": "1520", + "videoQualityControlType": "VBR", + "constantBitRate": "8192", + "fixedQuality": "100", + "vbrUpperCap": "8192", + "vbrLowerCap": "32", + "maxFrameRate": "2500", + "keyFrameInterval": "1000", + "snapShotImageType": "JPEG", + "H264Profile": "Main", + "GovLength": "25", + "SVC": { + "enabled": "false" + }, + "PacketType": ["PS", "RTP"], + "smoothing": "50", + "H265Profile": "Main", + "SmartCodec": { + "enabled": "false" + } + }, + "Audio": { + "enabled": "true", + "audioInputChannelID": "1", + "audioCompressionType": "AAC" + } + } + } + }, + "Streaming/channels/102": { + "response": { + "StreamingChannel": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "102", + "channelName": "Terrasse", + "enabled": "true", + "Transport": { + "maxPacketSize": "1000", + "ControlProtocolList": { + "ControlProtocol": [ + { + "streamingTransport": "RTSP" + }, + { + "streamingTransport": "HTTP" + }, + { + "streamingTransport": "SHTTP" + }, + { + "streamingTransport": "SRTP" + } + ] + }, + "Unicast": { + "enabled": "true", + "rtpTransportType": "RTP/TCP" + }, + "Multicast": { + "enabled": "true", + "destIPAddress": "0.0.0.0", + "videoDestPortNo": "8866", + "audioDestPortNo": "8868" + }, + "Security": { + "enabled": "true", + "certificateType": "digest/basic", + "SecurityAlgorithm": { + "algorithmType": "MD5" + } + }, + "SRTPMulticast": { + "SRTPVideoDestPortNo": "18866", + "SRTPAudioDestPortNo": "18868" + } + }, + "Video": { + "enabled": "true", + "videoInputChannelID": "1", + "videoCodecType": "H.264", + "videoScanType": "progressive", + "videoResolutionWidth": "1280", + "videoResolutionHeight": "720", + "videoQualityControlType": "VBR", + "constantBitRate": "8192", + "fixedQuality": "80", + "vbrUpperCap": "8192", + "vbrLowerCap": "32", + "maxFrameRate": "1000", + "keyFrameInterval": "500", + "snapShotImageType": "JPEG", + "H264Profile": "Main", + "GovLength": "5", + "SVC": { + "enabled": "false" + }, + "PacketType": ["PS", "RTP"], + "smoothing": "50", + "H265Profile": "Main" + }, + "Audio": { + "enabled": "true", + "audioInputChannelID": "1", + "audioCompressionType": "AAC" + } + } + } + }, + "Streaming/channels/103": { + "response": { + "StreamingChannel": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "103", + "channelName": "Terrasse", + "enabled": "true", + "Transport": { + "maxPacketSize": "1000", + "ControlProtocolList": { + "ControlProtocol": [ + { + "streamingTransport": "RTSP" + }, + { + "streamingTransport": "HTTP" + }, + { + "streamingTransport": "SHTTP" + }, + { + "streamingTransport": "SRTP" + } + ] + }, + "Unicast": { + "enabled": "true", + "rtpTransportType": "RTP/TCP" + }, + "Multicast": { + "enabled": "true", + "destIPAddress": "0.0.0.0", + "videoDestPortNo": "8860", + "audioDestPortNo": "8862" + }, + "Security": { + "enabled": "true", + "certificateType": "digest/basic", + "SecurityAlgorithm": { + "algorithmType": "MD5" + } + }, + "SRTPMulticast": { + "SRTPVideoDestPortNo": "18860", + "SRTPAudioDestPortNo": "18862" + } + }, + "Video": { + "enabled": "true", + "videoInputChannelID": "1", + "videoCodecType": "H.264", + "videoScanType": "progressive", + "videoResolutionWidth": "2688", + "videoResolutionHeight": "1520", + "videoQualityControlType": "VBR", + "constantBitRate": "8192", + "fixedQuality": "100", + "vbrUpperCap": "8192", + "vbrLowerCap": "32", + "maxFrameRate": "2500", + "keyFrameInterval": "1000", + "snapShotImageType": "JPEG", + "H264Profile": "Main", + "GovLength": "25", + "SVC": { + "enabled": "false" + }, + "PacketType": ["PS", "RTP"], + "smoothing": "50", + "H265Profile": "Main", + "SmartCodec": { + "enabled": "false" + } + }, + "Audio": { + "enabled": "true", + "audioInputChannelID": "1", + "audioCompressionType": "AAC" + } + } + } + }, + "Streaming/channels/104": { + "response": { + "StreamingChannel": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "104", + "channelName": "Terrasse", + "enabled": "true", + "Transport": { + "maxPacketSize": "1000", + "ControlProtocolList": { + "ControlProtocol": [ + { + "streamingTransport": "RTSP" + }, + { + "streamingTransport": "HTTP" + }, + { + "streamingTransport": "SHTTP" + }, + { + "streamingTransport": "SRTP" + } + ] + }, + "Unicast": { + "enabled": "true", + "rtpTransportType": "RTP/TCP" + }, + "Multicast": { + "enabled": "true", + "destIPAddress": "0.0.0.0", + "videoDestPortNo": "8860", + "audioDestPortNo": "8862" + }, + "Security": { + "enabled": "true", + "certificateType": "digest/basic", + "SecurityAlgorithm": { + "algorithmType": "MD5" + } + }, + "SRTPMulticast": { + "SRTPVideoDestPortNo": "18860", + "SRTPAudioDestPortNo": "18862" + } + }, + "Video": { + "enabled": "true", + "videoInputChannelID": "1", + "videoCodecType": "H.264", + "videoScanType": "progressive", + "videoResolutionWidth": "2688", + "videoResolutionHeight": "1520", + "videoQualityControlType": "VBR", + "constantBitRate": "8192", + "fixedQuality": "100", + "vbrUpperCap": "8192", + "vbrLowerCap": "32", + "maxFrameRate": "2500", + "keyFrameInterval": "1000", + "snapShotImageType": "JPEG", + "H264Profile": "Main", + "GovLength": "25", + "SVC": { + "enabled": "false" + }, + "PacketType": ["PS", "RTP"], + "smoothing": "50", + "H265Profile": "Main", + "SmartCodec": { + "enabled": "false" + } + }, + "Audio": { + "enabled": "true", + "audioInputChannelID": "1", + "audioCompressionType": "AAC" + } + } + } + }, + "System/IO/inputs/1": { + "response": { + "IOInputPort": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "enabled": "false", + "triggering": "high", + "name": null + } + } + }, + "System/Video/inputs/channels/1/motionDetection": { + "response": { + "MotionDetection": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "enabled": "false", + "enableHighlight": "false", + "samplingInterval": "2", + "startTriggerTime": "500", + "endTriggerTime": "500", + "regionType": "grid", + "Grid": { + "rowGranularity": "18", + "columnGranularity": "22" + }, + "MotionDetectionLayout": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "sensitivityLevel": "40", + "layout": { + "gridMap": "0000000000000000000001c01ffff81ffffc3ffffc7ffffc7ffffcfffffcfffffcfffffcfffffcfffffcfffffcfffffcfffffc000000", + "RegionList": { + "@size": "4", + "Region": { + "id": "1", + "RegionCoordinatesList": { + "RegionCoordinates": [ + { + "positionX": "1", + "positionY": "832" + }, + { + "positionX": "1000", + "positionY": "832" + }, + { + "positionX": "1000", + "positionY": "56" + }, + { + "positionX": "1", + "positionY": "56" + } + ] + } + } + } + }, + "targetType": "human" + } + } + } + }, + "System/Video/inputs/channels/1/tamperDetection": { + "response": { + "TamperDetection": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "enabled": "false", + "normalizedScreenSize": { + "normalizedScreenWidth": "704", + "normalizedScreenHeight": "576" + }, + "tampersensitivityLevel": "60", + "TamperDetectionRegionList": { + "TamperDetectionRegion": { + "id": "1", + "enabled": "false", + "sensitivityLevel": "60", + "RegionCoordinatesList": { + "RegionCoordinates": [ + { + "positionX": "197", + "positionY": "78" + }, + { + "positionX": "557", + "positionY": "78" + }, + { + "positionX": "557", + "positionY": "268" + }, + { + "positionX": "197", + "positionY": "268" + } + ] + } + } + } + } + } + }, + "Smart/LineDetection/1": { + "response": { + "LineDetection": { + "id": "1", + "enabled": "false", + "enableDualVca": "true", + "normalizedScreenSize": { + "normalizedScreenWidth": "1000", + "normalizedScreenHeight": "1000" + }, + "LineItemList": { + "@size": "4", + "LineItem": [ + { + "id": "1", + "enabled": "false", + "sensitivityLevel": "50", + "directionSensitivity": "any", + "CoordinatesList": { + "Coordinates": [ + { + "positionX": "607", + "positionY": "631" + }, + { + "positionX": "748", + "positionY": "723" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "2", + "enabled": "false", + "sensitivityLevel": "50", + "directionSensitivity": "any", + "CoordinatesList": { + "Coordinates": [ + { + "positionX": "491", + "positionY": "690" + }, + { + "positionX": "643", + "positionY": "758" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "3", + "enabled": "false", + "sensitivityLevel": "50", + "directionSensitivity": "any", + "CoordinatesList": { + "Coordinates": [ + { + "positionX": "605", + "positionY": "635" + }, + { + "positionX": "477", + "positionY": "697" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "4", + "enabled": "false", + "sensitivityLevel": "50", + "directionSensitivity": "any", + "CoordinatesList": { + "Coordinates": [ + { + "positionX": "752", + "positionY": "728" + }, + { + "positionX": "646", + "positionY": "760" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + } + ] + }, + "isSupportMultiScene": "false", + "recogRuleType": "vectorMode" + } + } + }, + "Smart/FieldDetection/1": { + "response": { + "FieldDetection": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "enabled": "false", + "enableDualVca": "true", + "startTriggerTime": "500", + "endTriggerTime": "500", + "normalizedScreenSize": { + "normalizedScreenWidth": "1000", + "normalizedScreenHeight": "1000" + }, + "FieldDetectionRegionList": { + "@size": "4", + "FieldDetectionRegion": [ + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "enabled": "false", + "sensitivityLevel": "60", + "timeThreshold": "0", + "RegionCoordinatesList": { + "RegionCoordinates": [ + { + "positionX": "14", + "positionY": "31" + }, + { + "positionX": "14", + "positionY": "800" + }, + { + "positionX": "700", + "positionY": "896" + }, + { + "positionX": "699", + "positionY": "34" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "2", + "enabled": "false", + "sensitivityLevel": "60", + "timeThreshold": "0", + "RegionCoordinatesList": { + "RegionCoordinates": [ + { + "positionX": "697", + "positionY": "914" + }, + { + "positionX": "984", + "positionY": "759" + }, + { + "positionX": "978", + "positionY": "26" + }, + { + "positionX": "698", + "positionY": "26" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "3", + "enabled": "false", + "sensitivityLevel": "50", + "timeThreshold": "0", + "detectionTarget": "human,vehicle", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "4", + "enabled": "false", + "sensitivityLevel": "50", + "timeThreshold": "0", + "detectionTarget": "human,vehicle", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + } + ] + }, + "isSupportMultiScene": "false", + "isSupportHumanMisinfoFilter": "true", + "isSupportVehicleMisinfoFilter": "true" + } + } + }, + "Smart/regionEntrance/1": { + "response": { + "RegionEntrance": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "enabled": "false", + "normalizedScreenSize": { + "normalizedScreenWidth": "1000", + "normalizedScreenHeight": "1000" + }, + "RegionEntranceRegionList": { + "@size": "4", + "RegionEntranceRegion": [ + { + "id": "1", + "sensitivityLevel": "50", + "RegionCoordinatesList": { + "RegionCoordinates": [ + { + "positionX": "456", + "positionY": "699" + }, + { + "positionX": "608", + "positionY": "628" + }, + { + "positionX": "774", + "positionY": "728" + }, + { + "positionX": "649", + "positionY": "771" + } + ] + }, + "detectionTarget": "human,vehicle", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "2", + "sensitivityLevel": "50", + "RegionCoordinatesList": null, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "3", + "sensitivityLevel": "50", + "RegionCoordinatesList": null, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "4", + "sensitivityLevel": "50", + "RegionCoordinatesList": null, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + } + ] + }, + "isSupportMultiScene": "false", + "isSupportHumanMisinfoFilter": "true", + "isSupportVehicleMisinfoFilter": "true", + "isSupportTargetMultiSelect": "true" + } + } + }, + "Smart/regionExiting/1": { + "response": { + "RegionExiting": { + "@version": "2.0", + "@xmlns": "http://www.hikvision.com/ver20/XMLSchema", + "id": "1", + "enabled": "false", + "normalizedScreenSize": { + "normalizedScreenWidth": "1000", + "normalizedScreenHeight": "1000" + }, + "RegionExitingRegionList": { + "@size": "4", + "RegionExitingRegion": [ + { + "id": "1", + "sensitivityLevel": "50", + "RegionCoordinatesList": { + "RegionCoordinates": [ + { + "positionX": "16", + "positionY": "801" + }, + { + "positionX": "71", + "positionY": "322" + }, + { + "positionX": "942", + "positionY": "288" + }, + { + "positionX": "980", + "positionY": "903" + } + ] + }, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "2", + "sensitivityLevel": "50", + "RegionCoordinatesList": null, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "3", + "sensitivityLevel": "50", + "RegionCoordinatesList": null, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + }, + { + "id": "4", + "sensitivityLevel": "50", + "RegionCoordinatesList": null, + "detectionTarget": "human", + "alarmConfidence": { + "@opt": "low,mediumLow,mediumHigh,high", + "#text": "low" + } + } + ] + }, + "isSupportMultiScene": "false", + "isSupportHumanMisinfoFilter": "true", + "isSupportVehicleMisinfoFilter": "true", + "isSupportTargetMultiSelect": "true" + } + } + } + } + } +} diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index a7963e9..089bcd6 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -6,6 +6,7 @@ from custom_components.hikvision_next.const import DOMAIN from homeassistant.data_entry_flow import FlowResultType from homeassistant.config_entries import SOURCE_USER +from homeassistant.const import CONF_HOST from tests.conftest import TEST_CONFIG, TEST_HOST @@ -73,3 +74,23 @@ async def test_unexpeced_exception_config_flowget_device_info_mock(get_device_in result = await hass.config_entries.flow.async_configure(result["flow_id"], user_input=TEST_CONFIG) assert result.get("type") == FlowResultType.FORM assert result.get("errors") == {"base": "Unexpected Exception: Something went wrong"} + + +@respx.mock +@pytest.mark.parametrize("mock_isapi_device", ["DS-2CD2386G2-IU"], indirect=True) +async def test_user_input_validation(hass, mock_isapi_device): + """Test a successful config flow.""" + + result = await hass.config_entries.flow.async_init(DOMAIN, context={"source": SOURCE_USER}) + + assert result["type"] == FlowResultType.FORM + assert result["step_id"] == "user" + + user_input = { + **TEST_CONFIG, + CONF_HOST: TEST_HOST + "/" + } + result = await hass.config_entries.flow.async_configure(result["flow_id"], user_input=user_input) + + assert result["type"] == FlowResultType.CREATE_ENTRY + assert result["data"] == TEST_CONFIG diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 84bd070..cca234f 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -3,6 +3,7 @@ import pytest from homeassistant.core import HomeAssistant from pytest_homeassistant_custom_component.common import MockConfigEntry +import homeassistant.helpers.entity_registry as er @pytest.mark.parametrize("init_integration", ["DS-7608NXI-I2"], indirect=True) @@ -21,3 +22,33 @@ async def test_sensor_value( ]: assert (sensor := hass.states.get(entity_id)) assert sensor.state == state + + +@pytest.mark.parametrize("init_integration", ["DS-2CD2146G2-ISU", "DS-7608NXI-I2"], indirect=True) +async def test_scenechange_support( + hass: HomeAssistant, + init_integration: MockConfigEntry, +) -> None: + """Test sensors value.""" + + device_data = { + "DS-7608NXI-I2": { + "serial_no": "ds_7608nxi_i0_0p_s0000000000ccrrj00000000wcvu", + "disabled": False, + }, + "DS-2CD2146G2-ISU": { + "serial_no": "ds_2cd2146g2_isu00000000aawrg00000000", + "disabled": False, + }, + } + + data = device_data[init_integration.title] + entities = [ + f"binary_sensor.{data['serial_no']}_1_scenechangedetection", + f"switch.{data['serial_no']}_1_scenechangedetection" + ] + + entity_registry = er.async_get(hass) + for entity_id in entities: + assert (entity := entity_registry.async_get(entity_id)) + assert entity.disabled == data["disabled"]