JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
1.1k stars 88 forks source link

Feature Request: HDR Switch #480

Closed oscarsiles closed 3 months ago

oscarsiles commented 10 months ago

Is your feature request related to a problem? Please describe. I have a C325WB camera which works fine, but is missing a few features (e.g. #433). In particular of interest to me would be the ability to enable/disable the HDR functionality, as Tapo indicates it is best to keep it disabled at night. The firmware has no auto mode for this setting, and so it would be helpful to be able to automate this via HA.

Describe the solution you'd like Add support for the new features of C225/C325WB cameras (HDR, new AI detection modes)

Describe alternatives you've considered n/a - no firmware support for scheduling HDR mode

Additional context Happy to provide any logs/data that is needed. Have played around with pytapo a bit but didn't get very far.

richilp commented 9 months ago

The AI detection mode it would be really appreciated, yes

JurajNyiri commented 9 months ago

https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues/304

JurajNyiri commented 9 months ago

Someone will need to document the https call for HDR switch on / off. Then it can be added.

oscarsiles commented 9 months ago

I intercepted the HTTPS request/responses (to the usual stok=/ds endpoint):

HDR on: {"method":"multipleRequest","params":{"requests":[{"method":"setHDR","params":{"video":{"set_hdr":{"hdr":1,"secname":"main"}}}}]}}

{"result":{"responses":[{"method":"setHDR","result":{},"error_code":0}]},"error_code":0}

HDR off: {"method":"multipleRequest","params":{"requests":[{"method":"setHDR","params":{"video":{"set_hdr":{"hdr":0,"secname":"main"}}}}]}}

{"result":{"responses":[{"method":"setHDR","result":{},"error_code":0}]},"error_code":0}

I also extracted the response of getVideoQualities method which shows the status of HDR for the camera: {"method":"getVideoQualities","params":{"video":{"name":["main"]}}}

{"method":"getVideoQualities","result":{"video":{"main":{"quality":"3","bitrate":"3072","frame_rate":"65556","smart_codec":"off","encode_type":"H264","resolution":"2688*1520","bitrate_type":"vbr","name":"VideoEncoder_1","default_bitrate":"3072","hdr":"1"}}},"error_code":0}

as well as getVideoCapability which references HDR as well ("hdrs"): {"method":"getVideoCapability","params":{"video_capability":{"name":"main"}}}

{"method":"getVideoCapability","result":{"video_capability":{"main":{"encode_types":["H264","H265"],"frame_rates":["65537","65546","65551","65556"],"bitrates":["256","512","1024","1536","3072"],"bitrate_types":["cbr","vbr"],"resolutions":["2688*1520","1920*1080","1280*720"],"qualitys":["1","3","5"],"hdrs":["0","1"],"minor_stream_support":"1"}}},"error_code":0}

Hopefully this is all that is needed!

JurajNyiri commented 3 months ago

@oscarsiles Looking into this now. We need to find one more call - to determine what is the HDR current state.

JurajNyiri commented 3 months ago

In the meantime, I pushed the above functions into pytapo, you can test them now by manually downloading this branch and using it with python.

https://github.com/JurajNyiri/pytapo/tree/hdr

Once we have the function to get HDR state, I will implement it here as well. Unfortunately, none of my cameras support HDR so I cannot even guess the GET call or test this.

oscarsiles commented 3 months ago

Thanks for this - I'll try to test it over the next couple of days.

We need to find one more call - to determine what is the HDR current state.

Would the getVideoQualities not work for this, as it has an hdr field at the very end?

JurajNyiri commented 3 months ago

You are right, I missed that! Let me implement it here. I will open new branch in upcoming hours for you to test.

JurajNyiri commented 3 months ago

Deployed pytapo 3.3.23, should make it a lot easier to test now.

JurajNyiri commented 3 months ago

@oscarsiles Try downloading manually https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/tree/hdr , it should have the HDR switch. I was not able to test so I was developing blind, let me know if it works. Thank you!

oscarsiles commented 3 months ago

Just tested it by changing HDR on the Tapo app and via HA. Both work and reflect any changes from another source correctly. Thanks so much!

JurajNyiri commented 3 months ago

Released in https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/releases/tag/5.4.26. Thank you!