Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C420 - Automatic Alarm, NightVision and spotlight intensity missing #637

Closed
marcosngomezi opened this issue Jul 21, 2024 · 13 comments
Closed

Comments

@marcosngomezi
Copy link
Contributor

Description

Description
Automatic Alarm and NightVision selects are not anymore provided on C420 camera.

Reproduction Steps

Entities go missing after update to 5.5.1
image

Expected behavior

Entity is present

If applicable, add error logs.

No response

Device Firmware

1.2.17 Build 20240305 rel.75572

Integration Version

5.5.1

Using stream component

No

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

HA OS

Search for similar issues

Yes

Additional information

No response

@marcosngomezi
Copy link
Contributor Author

marcosngomezi commented Jul 21, 2024

Night Vision:
found out that is working for one camera but not for another, and found the next log:
2024-07-21 11:17:51.086 INFO (MainThread) [custom_components.tapo_control] Camera does not support TapoNightVisionSelect: Error: Invalid stok value, Response: {"error_code": -40401, "result": {"data": {"code": -40401}}}
that I understand that is not finding it in raw, and getting an authentication error on query.
similar log not sure if related:
2024-07-21 13:01:44.582 INFO (MainThread) [custom_components.tapo_control] Camera does not support TapoFloodlight: Invalid authentication data

What is strange is that is consistent through restarts, both on same fw version.

@marcosngomezi
Copy link
Contributor Author

marcosngomezi commented Jul 21, 2024

Spotlight Intensity:
there is a new number entity for spotlight intensity but is not working
image
its because of range, select had 1 to 5, and new number one has up to 100

@marcosngomezi
Copy link
Contributor Author

Automatic Alarm:
Not sure why dissapeared now and before was available, but is because getAlarm maps to getLastAlarmInfo, that is not supported on C420, adding a second option with getAlarmConfig solves

@JurajNyiri
Copy link
Owner

@JurajNyiri
Copy link
Owner

@marcosngomezi could you please look into and verify the rest of reported issues? I think you have C420

@JurajNyiri
Copy link
Owner

I just noticed @marcosngomezi you are the author here!

Spotlight Intensity:

For the new entity I was trying to find what is different between cameras with 1-5 and 1-100. I found something that worked for my set of C200s and C520WS, but I guess it is not the right thing.

Could you check what is inside here for C420? Something else needs to be selected. I am looking for something that tells the official app to use 1-100 vs 1-5.

I will need your help with the rest, or alternatively if you want you could provide me access to the camera and I can check / test, but I would need it port forwarded with the acc creds.

@marcosngomezi
Copy link
Contributor Author

marcosngomezi commented Jul 21, 2024

This is what C420 has on getNightVisionCapability:

"getNightVisionCapability": [
            {
                "image_capability": {
                    "supplement_lamp": {
                        "supplement_lamp_type": ["infrared_lamp", "white_lamp"],
                        "night_vision_mode_range": [
                            "inf_night_vision",
                            "wtl_night_vision",
                            "md_night_vision",
                        ],
                    }
                }
            }
        ],
And this is the full data object:
{
    "raw": {
        "getAlertTypeList": [False],
        "getNightVisionCapability": [
            {
                "image_capability": {
                    "supplement_lamp": {
                        "supplement_lamp_type": ["infrared_lamp", "white_lamp"],
                        "night_vision_mode_range": [
                            "inf_night_vision",
                            "wtl_night_vision",
                            "md_night_vision",
                        ],
                    }
                }
            }
        ],
        "getDeviceInfo": [
            {
                "device_info": {
                    "basic_info": {
                        "device_model": "C420",
                        "device_name": "C420 1.0",
                        "device_alias": "Frente",
                        "avatar": "Outdoor",
                        "sw_version": "1.2.17 Build 20240305 rel.75572",
                        "hw_version": "1.0",
                        "mac": "**********",
                        "device_type": "SMART.IPCAMERA",
                        "dev_id": "**********",
                        "oem_id": "**********",
                        "system_time": 1721591177,
                        "led_status": "off",
                        "updating": False,
                        "online": True,
                        "status": "configured",
                        "resolution": "2560*1440",
                        "camera_switch": "on",
                        "firmware_status": "OK",
                        "parent_device_id": "**********",
                        "parent_link_type": "ethernet",
                        "power": "BATTERY",
                        "battery_percent": 55,
                        "battery_charging": "NO",
                        "battery_overheated": False,
                        "low_battery": False,
                        "power_save_mode": "auto",
                        "power_save_status": "off",
                        "c_opt": [0, 1],
                        "a_type": 3,
                        "last_activity_timestamp": 1721558758,
                        "rssi": -52,
                    }
                }
            }
        ],
        "getDetectionConfig": [
            {
                "motion_detection": {
                    "motion_det": {
                        "enabled": "off",
                        "sensitivity": "high",
                        "digital_sensitivity": "80",
                    },
                    "region_info": [
                        {
                            "region_info_1": {
                                "x_coor": "0",
                                "y_coor": "0",
                                "width": "10000",
                                "height": "10000",
                            }
                        }
                    ],
                }
            }
        ],
        "getPersonDetectionConfig": [
            {"people_detection": {"detection": {"enabled": "off", "sensitivity": "60"}}}
        ],
        "getVehicleDetectionConfig": [
            {
                "vehicle_detection": {
                    "detection": {"enabled": "off", "sensitivity": "60"}
                }
            }
        ],
        "getBCDConfig": [False],
        "getPetDetectionConfig": [
            {"pet_detection": {"detection": {"enabled": "off", "sensitivity": "60"}}}
        ],
        "getBarkDetectionConfig": [False],
        "getMeowDetectionConfig": [False],
        "getGlassDetectionConfig": [False],
        "getTamperDetectionConfig": [False],
        "getLensMaskConfig": [{"lens_mask": {"lens_mask_info": {"enabled": "off"}}}],
        "getLdc": [{"image": {"switch": {"ldc": "off"}}}],
        "getLastAlarmInfo": [False],
        "getLedStatus": [{"led": {"config": {"enabled": "off"}}}],
        "getTargetTrackConfig": [False],
        "getPresetConfig": [False],
        "getFirmwareUpdateStatus": [
            {
                "cloud_config": {
                    "upgrade_status": {"state": "normal", "lastUpgradingSuccess": True}
                }
            }
        ],
        "getMediaEncrypt": [{"cet": {"media_encrypt": {"enabled": "on"}}}],
        "getConnectionType": [False],
        "getAlarmConfig": [
            {
                "enabled": "off",
                "alarm_mode": ["siren"],
                "siren_type": "Siren",
                "light_type": "flicker",
                "siren_volume": "normal",
                "siren_duration": 5,
            }
        ],
        "getAlarmPlan": [{"enabled": "off", "alarm_plan": "0000-0000,127"}],
        "getSirenTypeList": [
            {"siren_type_list": ["Siren", "Tone", "Red Alert"]},
            False,
        ],
        "getSirenConfig": [False],
        "getAlertConfig": [False],
        "getLightTypeList": [{"light_type_list": ["flicker"]}],
        "getSirenStatus": [{"status": "off"}, False],
        "getLightFrequencyInfo": [{"image": {"common": {"light_freq_mode": "50"}}}],
        "getLightFrequencyCapability": [
            {"image": {"light_frequency_capability": ["50", "60"]}}
        ],
        "getChildDeviceList": [False],
        "getRotationStatus": [{"image": {"switch": {"flip_type": "off"}}}],
        "getNightVisionModeConfig": [
            {"image": {"switch": {"night_vision_mode": "inf_night_vision"}}}
        ],
        "getWhitelampStatus": [{"status": 0, "rest_time": 0}],
        "getWhitelampConfig": [
            {"image": {"switch": {"wtl_intensity_level": "2", "wtl_force_time": "300"}}}
        ],
        "getMsgPushConfig": [
            {
                "msg_push": {
                    "chn1_msg_push_info": {
                        "notification_enabled": "on",
                        "rich_notification_enabled": "on",
                    }
                }
            }
        ],
        "getSdCardStatus": [
            {
                "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": "56.79 GB",
                                "video_total_space": "55.31 GB",
                                "video_free_space": "53.88 GB",
                            }
                        }
                    ]
                }
            }
        ],
        "getCircularRecordingConfig": [
            {"harddisk_manage": {"harddisk": {"loop": "on"}}}
        ],
        "getRecordPlan": [
            {
                "record_plan": {
                    "chn1_channel": {
                        "enabled": "on",
                        "sunday": '["0000-2400:2"]',
                        "monday": '["0000-2400:2"]',
                        "tuesday": '["0000-2400:2"]',
                        "wednesday": '["0000-2400:2"]',
                        "thursday": '["0000-2400:2"]',
                        "friday": '["0000-2400:2"]',
                        "saturday": '["0000-2400:2"]',
                    }
                }
            }
        ],
        "getAudioConfig": [
            {
                "audio_config": {
                    "speaker": {"volume": "85"},
                    "microphone": {
                        "sampling_rate": "8",
                        "encode_type": "G711ulaw",
                        "channels": "1",
                        "volume": "100",
                    },
                    "record_audio": {"enabled": "on"},
                    "speaker_algo": {"ns": "off", "hs": "on"},
                    "microphone_algo": {
                        "ns": "on",
                        "hs": "on",
                        "aec": "on",
                        "sys_aec": "on",
                    },
                }
            }
        ],
        "getFirmwareAutoUpgradeConfig": [False],
        "getVideoQualities": [
            {
                "video": {
                    "main": {
                        "resolution": "2560*1440",
                        "bitrate_type": "vbr",
                        "encode_type": "H264",
                        "frame_rate": "65551",
                        "quality": "5",
                        "bitrate": "1457",
                    }
                }
            }
        ],
        "getVideoCapability": [
            {
                "video_capability": {
                    "main": {
                        "encode_types": ["H264"],
                        "frame_rates": [65556, 65551],
                        "bitrate_types": ["vbr"],
                        "resolutions": ["2560*1440"],
                        "qualities": ["5"],
                        "bitrates": ["1457"],
                        "change_fps_support": "1",
                        "minor_stream_support": "1",
                    }
                }
            }
        ],
    },
    "user": "admin",
    "basic_info": {
        "device_model": "C420",
        "device_name": "C420 1.0",
        "device_alias": "Frente",
        "avatar": "Outdoor",
        "sw_version": "1.2.17 Build 20240305 rel.75572",
        "hw_version": "1.0",
        "mac": "**********",
        "device_type": "SMART.IPCAMERA",
        "dev_id": "**********",
        "oem_id": "**********",
        "system_time": 1721591177,
        "led_status": "off",
        "updating": False,
        "online": True,
        "status": "configured",
        "resolution": "2560*1440",
        "camera_switch": "on",
        "firmware_status": "OK",
        "parent_device_id": "**********",
        "parent_link_type": "ethernet",
        "power": "BATTERY",
        "battery_percent": 55,
        "battery_charging": "NO",
        "battery_overheated": False,
        "low_battery": False,
        "power_save_mode": "auto",
        "power_save_status": "off",
        "c_opt": [0, 1],
        "a_type": 3,
        "last_activity_timestamp": 1721558758,
        "rssi": -52,
    },
    "motion_detection_enabled": "off",
    "motion_detection_sensitivity": "high",
    "motion_detection_digital_sensitivity": "80",
    "person_detection_enabled": "off",
    "person_detection_sensitivity": "normal",
    "vehicle_detection_enabled": "off",
    "vehicle_detection_sensitivity": "normal",
    "babyCry_detection_enabled": None,
    "babyCry_detection_sensitivity": None,
    "pet_detection_enabled": "off",
    "pet_detection_sensitivity": "normal",
    "bark_detection_enabled": None,
    "bark_detection_sensitivity": None,
    "meow_detection_enabled": None,
    "meow_detection_sensitivity": None,
    "glass_detection_enabled": None,
    "glass_detection_sensitivity": None,
    "tamper_detection_enabled": None,
    "tamper_detection_sensitivity": None,
    "privacy_mode": "off",
    "notifications": "on",
    "rich_notifications": "on",
    "lens_distrotion_correction": "off",
    "light_frequency_mode": "50",
    "day_night_mode": "on",
    "force_white_lamp_state": None,
    "flip": "off",
    "alarm_user_start_id": None,
    "alarm_user_sounds": None,
    "alarm_config": {
        "typeOfAlarm": "getAlarmConfig",
        "mode": ["siren"],
        "automatic": "off",
        "light_type": "flicker",
        "siren_type": "Siren",
        "siren_duration": 5,
        "siren_volume": "normal",
    },
    "alarm_status": "off",
    "alarm_is_hubSiren": False,
    "alarm_siren_type_list": ["Siren", "Tone", "Red Alert"],
    "nightVisionCapability": {
        "supplement_lamp_type": ["infrared_lamp", "white_lamp"],
        "night_vision_mode_range": [
            "inf_night_vision",
            "wtl_night_vision",
            "md_night_vision",
        ],
    },
    "led": "off",
    "auto_track": None,
    "presets": {},
    "firmwareUpdateStatus": {
        "upgrade_status": {"state": "normal", "lastUpgradingSuccess": True}
    },
    "childDevices": False,
    "whitelampConfigForceTime": "300",
    "whitelampConfigIntensity": "2",
    "whitelampStatus": 0,
    "sdCardData": [
        {
            "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": "56.79 GB",
            "video_total_space": "55.31 GB",
            "video_free_space": "53.88 GB",
        }
    ],
    "recordPlan": {
        "enabled": "on",
        "sunday": '["0000-2400:2"]',
        "monday": '["0000-2400:2"]',
        "tuesday": '["0000-2400:2"]',
        "wednesday": '["0000-2400:2"]',
        "thursday": '["0000-2400:2"]',
        "friday": '["0000-2400:2"]',
        "saturday": '["0000-2400:2"]',
    },
    "microphoneVolume": "100",
    "microphoneMute": None,
    "microphoneNoiseCancelling": None,
    "speakerVolume": "85",
    "autoUpgradeEnabled": None,
    "connectionInformation": False,
    "videoCapability": {
        "video_capability": {
            "main": {
                "encode_types": ["H264"],
                "frame_rates": [65556, 65551],
                "bitrate_types": ["vbr"],
                "resolutions": ["2560*1440"],
                "qualities": ["5"],
                "bitrates": ["1457"],
                "change_fps_support": "1",
                "minor_stream_support": "1",
            }
        }
    },
    "videoQualities": {
        "video": {
            "main": {
                "resolution": "2560*1440",
                "bitrate_type": "vbr",
                "encode_type": "H264",
                "frame_rate": "65551",
                "quality": "5",
                "bitrate": "1457",
            }
        }
    },
}

I already have the fix for Automatic Alarm, will look deeper on the authentication error of NightMode, is rare to always have the error on the same method and only on one camera right? anything that you could think of to debug that could be causing it?

@marcosngomezi
Copy link
Contributor Author

About identifing cameras by parameters, I think that in the long term the best is to start having some configs by model name, otherwise with each change by infering from other data is very prone to break other already working devices

@marcosngomezi
Copy link
Contributor Author

I think that also would be nice to do a raw data repository of different models to be able to do some tests, today it depends a lot on issue reporting to know if changes where ok for all the models that are being supported

@JurajNyiri
Copy link
Owner

Thank you, with the above PR we have only spotlight sensitivity left to figure out right?

For that, I would like to prevent keeping a model list, so far there was always a good solution using the API, we just have to find the right method / data that the app uses for determination. That way it will always work even for new models (and possibly work for cameras not officially supported via app, we already have some functions like that).

@JurajNyiri
Copy link
Owner

Found it (probably).

"getLdc": [
        {
            "image": {
                "switch": {
                    "schedule_end_time": "64800",
                    "schedule_start_time": "21600",
                    "clear_licence_plate_mode": "off",
                    "switch_mode": "common",
                    "rotate_type": "off",
                    "flip_type": "off",
                    "ldc": "off",
                    "night_vision_mode": "md_night_vision",
                    "full_color_people_enhance": "off",
                    "full_color_min_keep_time": "5",
                    "wtl_intensity_level": "56",
                    "wtl_force_time": "300",
                    "overexposure_people_suppression": "off",
                    "best_view_distance": "0",
                    "image_scene_mode": "normal",
                    "image_scene_mode_common": "normal",
                    "image_scene_mode_shedday": "normal",
                    "image_scene_mode_shednight": "normal",
                    "image_scene_mode_autoday": "normal",
                    "image_scene_mode_autonight": "normal"
                },
                "common": {
                    "chroma": "50",
                    "luma": "50",
                    "sharpness": "50",
                    "saturation": "50",
                    "contrast": "50",
                    "inf_delay": "5",
                    "wd_gain": "50",
                    "exp_gain": "0",
                    "smartir_level": "0",
                    "auto_exp_gain_max": "0",
                    "wb_R_gain": "50",
                    "wb_B_gain": "50",
                    "wb_G_gain": "50",
                    "wtl_sensitivity": "4",
                    "wtl_delay": "5",
                    "wtl_sensitivity_day2night": "1400",
                    "wtl_sensitivity_night2day": "9100",
                    "iris_level": "160",
                    "lock_red_gain": "0",
                    "lock_gr_gain": "0",
                    "lock_gb_gain": "0",
                    "lock_blue_gain": "0",
                    "lock_red_colton": "0",
                    "lock_green_colton": "0",
                    "lock_blue_colton": "0",
                    "focus_limited": "10",
                    "inf_start_time": "64800",
                    "inf_end_time": "21600",
                    "wtl_start_time": "64800",
                    "wtl_end_time": "21600",
                    "inf_sensitivity_day2night": "1400",
                    "inf_sensitivity_night2day": "9100",
                    "wide_dynamic": "off",
                    "high_light_compensation": "off",
                    "dehaze": "off",
                    "eis": "off",
                    "auto_exp_antiflicker": "off",
                    "inf_type": "auto",
                    "inf_sensitivity": "4",
                    "wtl_type": "auto",
                    "backlight": "off",
                    "area_compensation": "default",
                    "smartir": "auto_ir",
                    "exp_type": "auto",
                    "exp_level": "0",
                    "shutter": "1/25",
                    "style": "original",
                    "focus_type": "manual",
                    "wb_type": "auto",
                    "lock_source": "local",
                    "smartwtl": "auto_wtl",
                    "smartwtl_level": "5",
                    "smartwtl_digital_level": "100",
                    "light_freq_mode": "auto"
                }
            }
        }
    ]

smartwtl_digital_level

@JurajNyiri
Copy link
Owner

Fixed in https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/releases/tag/5.5.4 .

@marcosngomezi
Copy link
Contributor Author

Confirmed working as expected on 5.5.4 for C420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants