home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.31k stars 30.26k forks source link

Reolink Doorbell does not snap sub-stream properly - main stream image is snapped #118617

Closed user45876 closed 4 months ago

user45876 commented 4 months ago

The problem

When using the service camera.snapshot to make a snapshot of the substream, instead of the image being 630480 (substream), it is 25601920:

service: camera.snapshot
data: {}
target:
  entity_id: camera.doorbell_sub

This was already mentioned here: https://github.com/home-assistant/core/issues/9486 starkillerOG says here: https://github.com/home-assistant/core/issues/94868#issuecomment-1620252350

@angrycatmeowmeow the video stream is RTSP, RTMP or FLV depending on what you selected in the config options of the integration (default is RTSP). However the snapshots (also loaded as the first image while the stream is still loading, and what you get if you use the snapshot service) are obtained through the HTTP API (so CGI command).

Note that the HTTP API command {"cmd": "Snap", "channel": channel, "snapType": "sub"} is supposed to return the low resolution sub stream snapshot. This works on other camera's, so if that is not working on the E1 outdoor, the Reolink firmware engineers should fix this in the firmware.

However, Reolink has a documentation, which states:

For example, if your IP address is 192.168.2.119, the username is admin and the password is 123456, then the URL should be: http://192.168.2.119/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=123456 If you want to get the JPEG snap of the substream, please add resolution (width and height) at the end of the URL. The link is as below: http://192.168.2.119/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=123456&width=640&height=480

The article is valid for these cameras:

Applies to: All Reolink IP cameras (B800, B400, D800, D400, Reolink battery-powered cameras, Reolink Lumus, Reolink E1, and Reolink E1 Pro excluded).

I worked around it by creating a shell_command which does the CURL and stores the image (for main and sub for options). The channel does not seem to get honored, replacing it with sub, 1, 2, whatever does nothing for me. To get the substream, a height and width seems to be mandatory, as per the Reolink documentation:

snap_doorbell_sub: "curl 'http://192.168.230.236/cgi-bin/api.cgi?cmd=Snap&channel=**sub**&rs=hihahu&user=admin&password=password&**width=640&height=480**' --output /config/www/doorbell/snapshot_latest.jpg"
snap_doorbell_main: "curl 'http://192.168.230.236/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=hihahu&user=admin&password=password' --output /config/www/doorbell/snapshot_latest.jpg"

While working perfectly fine, this is less than ideal ;) I came to know of the issue, as I was getting to play with some WT32-SC01 Plus Plates and OpenHASP - every KB counts ;) There is another shell_command to convert the jpg to a png for openHASP - a whole different can of worms:

convert_doorbell: ssh -i /config/ssh/id_ed25519 -o StrictHostKeyChecking=no hassio@127.0.0.1 sudo /usr/bin/convert /homeassistant/www/doorbell/snapshot_latest.jpg -resize 320x410^ -gravity center -extent 320x410 PNG:/homeassistant/www/doorbell/snapshot_latest.png

Would there be a way to integrate the width / height into the http request the reolink integration is doing - at least for some models? Or make it an option?

I also opened a ticket with Reolink, linking starkillerOGs issue mentioned above.

Thank you very much and best regards :) Hubert

What version of Home Assistant Core has the issue?

core-2024.05

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

reolink

Link to integration documentation on our website

https://www.home-assistant.io/integrations/reolink/

Diagnostics information

No response

Example YAML snippet

Using a Reolink camera - affected models unclear, doorbell on current firmware is affected:

service: camera.snapshot
data: {}
target:
  entity_id: camera.doorbell_sub


### Anything in the logs that might be useful for us?

_No response_

### Additional information

_No response_
home-assistant[bot] commented 4 months ago

Hey there @starkillerog, mind taking a look at this issue as it has been labeled with an integration (reolink) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `reolink` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign reolink` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


reolink documentation reolink source (message by IssueLinks)

starkillerOG commented 4 months ago

I just added the width and heigth parameters to the snapshot call when using the sub stream. You can see the commit here: https://github.com/starkillerOG/reolink_aio/commit/d8f6263641c6e2d330fadaaa789274e635d494e9

This will make its way into homeassistant in the comming two weeks or so (maybe faster, I am going to do a new reolink-aio release today).

Thank you for this detailed bug report and already figuring out what the solution would be!

starkillerOG commented 3 months ago

@user45876 this will be available in HA 2024.7.0 which will be released on July 3th. Please let me know if it is fixed once you have updated to HA 2024.7.0

If you appreciate the reolink integration and want to support its development, please consider sponsering the upstream library or purchase Reolink products through this affiliate link.

user45876 commented 3 months ago

Working since about three weeks ago, as you were so quick 🖖 thanks again!