tomasbedrich / home-assistant-hikconnect

A Home Assistant integration to communicate with Hikvision smart doorbells via Hik-Connect cloud.
40 stars 9 forks source link

Add live view from Hik-Connect connected cameras #6

Open tomasbedrich opened 2 years ago

tomasbedrich commented 2 years ago

I would love to implement it, but I haven’t reverse-engineered the protocol yet (lacking time).

sidlauskaslukas commented 2 years ago

@tomasbedrich what about RTSP stream? Or you're only talking about cloud based live stream?

tomasbedrich commented 2 years ago

I'm only looking for cloud-based camera stream. My goal is to mirror functionality available through Hik-Connect mobile application.

Focusing of local connection, you may be interested in the official integration or this thread.

pepsonEL commented 2 years ago

How we can use camera in version 1.1.1 ? I see only lock for door.

pergolafabio commented 2 years ago

thats not added , where do you see it added? it only is a version numbering change?

pepsonEL commented 2 years ago

https://github.com/tomasbedrich/home-assistant-hikconnect/releases/tag/1.1.1

Fix #6

pergolafabio commented 2 years ago

Look at code change, nothing there

pergolafabio commented 2 years ago

he made a type error, it fixes 16 instead of 6

tomasbedrich commented 2 years ago

Pardon guys, it's a typo in changelog. Version 1.1.1 fixes #16, not #6. No sensation here.

pergolafabio commented 2 years ago

:-)

scetu commented 2 years ago

It would be great to have camera entites created. I am looking forward to have them added, but anyway thanks for your effort!

pepsonEL commented 2 years ago

Is any chance to add live view from camera door station ? Now i have add my camera localy by rtps but in 1 generation video intercom to view by rtsp i also myst add rtsp address to still_image_url and for stream_source. And in this configuration i can not take a snapshoot from camera when somebody was ringing. When rtsp is set for still_image_url take snapshoot is unavailable. Live view by cloud will be good to take a snapshoot. Thanks.

pergolafabio commented 2 years ago

I don't think technical possible to capture feed from cloud, I didn't see any trace of it...

Have you tried the ffmpeg camera, as I suggested on forum? Then you don't need to define a still image... The snapshot is taken differently

pepsonEL commented 2 years ago

No i dont try. But how put address input to configure it ? camera:

pergolafabio commented 2 years ago

Look here for examples

https://community.home-assistant.io/t/ffmpeg-live-stream-not-work/135090

Or search on the forum, examples enough

pepsonEL commented 2 years ago

Ok added by ffmpeg and i can live view from it.... but also can not take snapshoot. File is create when run service take a snapshoot but file has 0KB and can not open it.

pergolafabio commented 2 years ago

Yeah, seems some discussion going on forum, discuss it there... Someone claimed it worked, wait for his feedback...

tomasbedrich commented 2 years ago

Can we please keep this issue focused on adding live view to Hik-Connect?

palfrey commented 2 years ago

I followed the instructions at https://www.home-assistant.io/integrations/generic/#secured-access-to-the-camera and was able to get a camera view in the UI. Would be nice to get the config folded into this though, rather than needing manual setup.

pergolafabio commented 2 years ago

That's not related , that url is local access, while this integration is based on hikconnect cloud

pepsonEL commented 2 years ago

I followed the instructions at https://www.home-assistant.io/integrations/generic/#secured-access-to-the-camera and was able to get a camera view in the UI. Would be nice to get the config folded into this though, rather than needing manual setup.

But my cam don't have address to still image

scorpioRED commented 2 years ago

Hi! Is it possible to get livestream video from cameras?

pergolafabio commented 2 years ago

From cloud, probably not

pergolafabio commented 1 year ago

hey @tomasbedrich , i found this..

https://github.com/ACKspace/hikkup

maybe it can be used to intecept the camera traffic? maybe also other stuff, so you dont need polling anymore?

barcus commented 11 months ago

Hi @tomasbedrich good job, unlock button and call status work like a charm !

Is there any way finally to display camera like within hikvision app ? My camera is not connected to my LAN unfortunately but i can access the video intercom (indoor station) IP I see many cameras available as a device using your integration, but there is no entities linked Thank you :)

tomasbedrich commented 11 months ago

@barcus if you can access your indoor station via LAN, use the solution provided by @pergolafabio - this way you can get both unlock and camera steam.

otherwise, we don’t have a video stream available from cloud yet

gsainsbury86 commented 11 months ago

Hi @tomasbedrich , thanks for your work on this. I am from a research facility and we plan to use hikvision's solar panel cameras to monitor a remote field site with the 4G backup option. I've registered the devices and have been able to access list them using using your package here. Do you have any further information on how we might be able to implement viewing/downloading image snapshots?

I had a go at guessing API endpoints (or the location of the OpenAPI.json file) and didn't have much luck.

pergolafabio commented 11 months ago

It's not possible using hikconnect, it's a unofficial API... It probably only works local by using rtsp streams

They probably work with webrtc and tokens, as we don't have

gsainsbury86 commented 11 months ago

Thanks @pergolafabio .

Sorry for the off-topic follow-up, but another option I considered is spinning up my own version of the Cloud Storage Solution . It seems on the device I can configure a custom server address and access id / key, which sounds like potentially S3 protocol, but I haven't been able to confirm.

pergolafabio commented 11 months ago

yeah, i think thats indeed possible, there are API listed for that on the tpp website: https://tpp.hikvision.com/tpp/IntegrationCenter

DanBrezeanu commented 10 months ago

Thanks and good job @tomasbedrich. Do we have any clues about the API endpoints used for streaming the camera feed?

If not, could you please detail how you found the endpoints you've already implemented?

pergolafabio commented 7 months ago

Hey @tomasbedrich, i found something interesting maybe With Ezviz you can also add Hikvision devices in their app, they have an API to get the live view address:

But i think to test you need to unlick your indoor from hikconnect app, then link to ezviz app

https://open.ys7.com/help/en/534

Probably Hikconnect also have an play interface, we just need to know the correct one? /api/lapp/v2/live/address/get

UberDudePL commented 7 months ago

Hello @pergolafabio and @tomasbedrich,

I was trying to find something in the API and potentially use it for RTSP over cloud as Hik Connect app does it.

I've reviewed ISAPI documents provided here: HIK Local Integration but I couldn't find anything about replies for call: https://apiieu.hik-connect.com/v3/userdevices/v1/cameras/info?deviceSerial=QXXXXX

To be precise I wonder about this response: "streamBizUrl": "biz=1", "vtmInfo": { "domain": "xxxaaa.ezvizlife.com", "externalIp": "98.xxx.xxx.xx", "internalIp": null, "port": 8554, "forceStreamType": 0, "isBackup": 0

I wonder if that could be used for RTSP connection? I've tried to use: rtsp://username:md5password@98.xxx.xxx.xx:8554/Streaming/Channels/101 or rtsp://username:md5password@98.xxx.xxx.xx:8554/ISAPI/Streaming/Channels/101 Unfortunately it did not work. Any suggestions how else I can try? For username I've tired my email address, admin, hik username.

UberDudePL commented 7 months ago

Hey @tomasbedrich, i found something interesting maybe With Ezviz you can also add Hikvision devices in their app, they have an API to get the live view address:

But i think to test you need to unlick your indoor from hikconnect app, then link to ezviz app

https://open.ys7.com/help/en/534

Probably Hikconnect also have an play interface, we just need to know the correct one? /api/lapp/v2/live/address/get

Hi, that is correct, I've tired this and I have my cameras in ezviz app but I could't get appKey to try to get API. The web page does not work when I try to register. Will keep you posted if I will be able to get anything

pergolafabio commented 7 months ago

How did you find that response?

As for RTSP local, you need to use port 554 not 8554 , but you need to have access to your outdoor device, then it works

UberDudePL commented 7 months ago

How did you find that response?

As for RTSP local, you need to use port 554 not 8554 , but you need to have access to your outdoor device, then it works

I've call over API to login:

curl --location 'https://apiieu.hik-connect.com/v3/users/login/v2' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'clientType: 55' \ --header 'lang: en-US' \ --header 'featureCode: deadbeef' \ --data-urlencode 'account=e@mail.com' \ --data-urlencode 'password=md5password'

and I've used:

curl --location 'https://apiieu.hik-connect.com/v3/userdevices/v1/cameras/info?deviceSerial=QXXXXX' \ --header 'Content-Type: application/json' \ --header 'clientType: 55' \ --header 'lang: en-US' \ --header 'featureCode: deadbeef' \ --header 'sessionId: lalalar'

That is the problem, I do not have access to local LAN network where cameras are set up. in theory I have one used RJ45 cable for second screen, maybe I can access it but for sure do not have any login or passwords apart from HIK account.

do you know how to reset admin password on device? I have this one and company that installed them all does not want to give it to me :)

My frontend device DS-KH6320-WTE1

pergolafabio commented 7 months ago

No, dont reset your device, then you are not able to register it on your outdoor panel, it will ask for admin password thgere too... I researched the SDK on port 8000 with my local integration, but i could find a way to retrieve the RTSP from indoor to outdooir When i sniffed my indoor, when prssing live view, it just opens an RTSP to outdoor, so its just an RTSP client

If you do that curl on this one:'https://apiieu.hik-connect.com/v3/userdevices/v1/cameras/info?deviceSerial=QXXXXX'

You also see a RTSP response with 8554 ?

pergolafabio commented 7 months ago

ok, i checked my old traces also, it seems indeed a response for me with:

domain=vtmuceu.ezvizlife.com , and 10554 for RTSP port

UberDudePL commented 7 months ago

I can paste my whole response but it is 1909 lines :) Whole response for one device is: "cameraInfos": [ { "cameraId": "c4879609af3a40088af1ad0b3b4c82f7", "cameraName": "Main Door Station", "channelNo": 1, "cameraCover": "https://ieu.ezvizlife.com/assets/imgs/public/homeDevice.jpeg", "deviceSerial": "QXXXXX", "isShow": 1, "videoLevel": 0, "videoQualityInfos": [ { "streamType": 2, "videoLevel": 0 }, { "streamType": 1, "videoLevel": 2 } ], "streamBizUrl": "biz=1", "vtmInfo": { "domain": "xxaaa.ezvizlife.com", "externalIp": "98.xx.xxx.xx", "internalIp": null, "port": 8554, "forceStreamType": 0, "isBackup": 0 }, "deviceChannelInfo": { "channelDeviceSerial": "QXXXXX", "channelNo": 1, "privacyStatus": 0, "powerStatus": 0, "globalStatus": 0, "signalStatus": 1 }, "cameraShareInfo": null, "extPermission": null },

pergolafabio commented 7 months ago

yeah, i see the same, those other 19 are virtual cameras, no need for it :-)

UberDudePL commented 7 months ago

yeah, i see the same, those other 19 are virtual cameras, no need for it :-)

under curl --location 'https://apiieu.hik-connect.com/v3/userdevices/v1/devices/pagelist?groupId=-1&limit=50&offset=0&filter=TIME_PLAN%2CCONNECTION%2CSWITCH%2CSTATUS%2CSTATUS_EXT%2CWIFI%2CNODISTURB%2CP2P%2CKMS%2CHIDDNS' \ --header 'Content-Type: application/json' \ --header 'clientType: 55' \ --header 'lang: en-US' \ --header 'featureCode: deadbeef' \ --header 'sessionId: a'

I can see this: { "connectionInfos": { "QXXXX": { "localIp": "192.168.50.182", "netIp": "83.21.10.203", "localRtspPort": 0, "netRtspPort": 0, "localCmdPort": 9010, "netCmdPort": 0, "localStreamPort": 9020, "netHttpPort": 0, "localHttpPort": 0, "netStreamPort": 0, "netType": 3, "wanIp": "83.21.10.203", "upnp": false }

pergolafabio commented 7 months ago

Have you now added your indoor device to Ezviz app? I see in HA they have Ezviz integration using same API i think https://www.home-assistant.io/integrations/ezviz/

You can disconnect your indoor very easy hikconnect and then link to ezviz mobile app

Maye it works?

https://github.com/BaQs/pyEzviz/issues/3

UberDudePL commented 7 months ago

Wanted to say that. I did but I’ve put it back as I have automations depending on HIK integration :) like opening my doors and gate. Have to go back to work for a meeting but I will add it back later to EZVIZ and see if it appears in HA. Any suggestions where to look after it appears in HA? I have 4 cameras two were not loading at all, the live view I mean. My ultimate goal is to get it recorded on my hdd via rtsp

pergolafabio commented 7 months ago

Yeah, i think if it works with ezviz, it should be possible with hikconnect too, i think both use the same API my guess you can open doors too with Ezviz integration, maybe just drop hikconnect completely then :-)

UberDudePL commented 7 months ago

it worked partially: image

UberDudePL commented 7 months ago

any suggestions what to use?

I've used my Md5hased password with admin and it worked but it does not appear a live view and it created only one camera

pergolafabio commented 7 months ago

no, thats a local camera, i think ezviz also can use the cloud integrataion??

UberDudePL commented 7 months ago

It does not say anything about this here: https://www.home-assistant.io/integrations/ezviz

pergolafabio commented 7 months ago

maybe its indeed a local integration the text is indeed misleading:

As there is no official documentation for the API, the integration retrieves data from the API used in the EZVIZ mobile app, hosted here.

pergolafabio commented 7 months ago

maybe try direct pyEzviz? Seems when hikvision device is added to ezviz cloud, it works?

https://github.com/BaQs/pyEzviz/pull/9

pergolafabio commented 7 months ago

Look here;

https://github.com/RenierM26/ha-ezviz

Especially the note;

Hassio makes use of rtsp for camera streaming. This function will only work on the local network. (Mabe we'll be able to reverse engineer the ezviz cloud rtsp proxy in the future)

So probably not possible!