JurajNyiri / pytapo

Python library for communication with Tapo Cameras
MIT License
277 stars 58 forks source link

Extra methods for H200 and C420S2 battery cameras #105

Closed marcosngomezi closed 4 months ago

marcosngomezi commented 6 months ago

Hi there, I have found several missing methods, that would be nice to add to pytapo and the HA assistant integration

Hub H200: method params result description
setSirenStatus {"siren":{"status":"on"}} {"time_left":60} triggers the siren sound on the hub, maybe a HA service of the hub device?
getSirenStatus {"siren":{}} {"status":"off","time_left":0} status of siren and remaining time for change(only when on I think)
getSirenConfig {"siren":{}} {"siren_type":"Doorbell Ring 5","volume":"6","duration":300} syren type value from possible ones from getSirenTypeList method, volume [1-10], duration in seconds
getSirenTypeList {"siren":{}} {"siren_type_list":["Doorbell Ring 1","Doorbell Ring 2","Doorbell Ring 3","Doorbell Ring 4","Doorbell Ring 5","Doorbell Ring 6","Doorbell Ring 7","Doorbell Ring 8","Doorbell Ring 9","Doorbell Ring 10","Phone Ring","Alarm 1","Alarm 2","Alarm 3","Alarm 4","Dripping Tap","Alarm 5","Connection 1","Connection 2"]} possible sounds for siren
setSirenConfig {"siren":{"duration":60,"siren_type":"Doorbell Ring 5","volume":"6"}} {} for changing siren config
getSdCardStatus {"harddisk_manage":{"table":["hd_info"]}} {"harddisk_manage":{"hd_info":[{"hd_info_1":{"disk_name":"1","loop_record_status":"1","rw_attr":"rw","total_space":"58.23 GB","write_protect":"0","type":"local","status":"normal","detect_status":"normal","percent":"100","free_space":"58.03 GB","video_total_space":"55.31 GB","video_free_space":"55.12 GB"}}]}} I think video_free_space coudl be useful to know when the sd is getting full
getSdCardChildUsedSpace {"harddisk_manage":{"device_list":[]}} {"harddisk_manage":{"device_list":[{"device_id":"80219A4604220FB13B5F559EC66882BA21C95CAD","used_space":"140.50 MB"},{"device_id":"80218F1DD507CADEC90325A7CD348EF421C9CDFF","used_space":"47.62 MB"}]}} sd space used by device, don't sure if really useful

C420S2 Cameras:

method params result description
getBatteryStatus {"battery":{"name":"status"}} {"battery":{"status":{"power_mode":"BATTERY","battery_percent":87,"battery_charging":"NO","battery_voltage":4061,"battery_capacity":6700,"battery_temperature":28,"battery_vendor":"tp","battery_model":"tp","low_battery":false,"battery_overheated":false}}} really useful data of battery
setLensMaskConfig {"lens_mask":{"lens_mask_info":{"enabled":"on"}}} {} method to set privacy mode(cameras turn off)
getLensMaskConfig {"lens_mask":{"name":["lens_mask_info"]}} {"lens_mask":{"lens_mask_info":{"enabled":"off"}}} get privacy mode status
searchDetectionList {"playback":{"search_detection_list":{"channel":0,"end_index":99,"end_time":1710298799,"start_index":0,"start_time":1710212400}}} {'playback': {'total_num': 5, 'search_detection_list': [{'start_time': 1709902381, 'end_time': 1709902404, 'alarm_type': 6}, {'start_time': 1709902460, 'end_time': 1709902473, 'alarm_type': 6}, {'start_time': 1709902490, 'end_time': 1709902508, 'alarm_type': 6}, {'start_time': 1709954426, 'end_time': 1709954447, 'alarm_type': 6}, {'start_time': 1710025659, 'end_time': 1710025687, 'alarm_type': 6}], 'snapshot_enable': True}} detections search by timestamp, type 6 is person detection, I have to do more research to find out the other types, it could be polled to generate HA events?

Those are I think the most useful ones, let me know if there is any feature request for any other configuration, there are a lot of other methods available. I could find time to make a pull request for pytapo methods support but I'm a bit lost on HA custom components.

JurajNyiri commented 6 months ago

Thank you!

What is time_left on siren? What change? What are possible values for duration on siren config? getSdCardStatus is already implemented. getLensMaskConfig, setLensMaskConfig is already implemented. searchDetectionList is already implemented.

JurajNyiri commented 6 months ago

Please feel free to open PR for pytapo, I can then handle the HA part.

marcosngomezi commented 6 months ago

time_left is the remaining time to finish the configured siren duration when its on, the duration at the app allows from 1 to 600 seconds about already available methods, I don't see those methods/functionalities at HA maybe they don't map to entities on HA integration? the most useful I think is the detections as currently the only way to integrate detections that i found was through IFTT and webhooks which requires IFTT pro subscription

JurajNyiri commented 6 months ago

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

SD card status is exposed via sensor entities. Lens mask is privacy mode switch.

Please open feature request on ha if you wish some new entities or functionality.

marcosngomezi commented 5 months ago

Give it a look an let me know what you think, I will be doing an issue and PR also on HA Tapo Control to add/fix the missing entities for H200 and C420S2

marcosngomezi commented 4 months ago

Hi there @JurajNyiri there are both PRs related to tests and new entitities for H200 and C420S2, do you see it ok to merge?

JurajNyiri commented 4 months ago

Thank you very much for the prs!

I have been very busy lately but I will try to review this soon.