diff --git a/README.md b/README.md index ec41b495..c286ba3f 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ The following devices have been tested and confirmed as working. If your device - **Wall Switches**: S500D, S505, S505D - **Bulbs**: L510B, L510E, L530E, L630 - **Light Strips**: L900-10, L900-5, L920-5, L930-5 -- **Cameras**: C100, C210, C325WB, C520WS, TC65 +- **Cameras**: C100, C210, C325WB, C520WS, TC65, TC70 - **Hubs**: H100, H200 - **Hub-Connected Devices[^3]**: S200B, S200D, T100, T110, T300, T310, T315 diff --git a/SUPPORTED.md b/SUPPORTED.md index 8e13b656..5d26f8e9 100644 --- a/SUPPORTED.md +++ b/SUPPORTED.md @@ -269,6 +269,8 @@ All Tapo devices require authentication.
Hub-Connected Devices may work acros - Hardware: 1.0 (US) / Firmware: 1.2.8 - **TC65** - Hardware: 1.0 / Firmware: 1.3.9 +- **TC70** + - Hardware: 3.0 / Firmware: 1.3.11 ### Hubs diff --git a/kasa/smartcam/modules/camera.py b/kasa/smartcam/modules/camera.py index 1e1f4570..f1eda0f9 100644 --- a/kasa/smartcam/modules/camera.py +++ b/kasa/smartcam/modules/camera.py @@ -39,6 +39,7 @@ class Camera(SmartCamModule): self._device, id="state", name="State", + container=self, attribute_getter="is_on", attribute_setter="set_state", type=Feature.Type.Switch, @@ -50,7 +51,7 @@ class Camera(SmartCamModule): def is_on(self) -> bool: """Return the device on state.""" if lens_mask := self._device.modules.get(Module.LensMask): - return lens_mask.state + return not lens_mask.enabled return True async def set_state(self, on: bool) -> Annotated[dict, FeatureAttribute()]: @@ -60,7 +61,7 @@ class Camera(SmartCamModule): """ if lens_mask := self._device.modules.get(Module.LensMask): # Turning off enables the privacy mask which is why value is reversed. - return await lens_mask.set_state(not on) + return await lens_mask.set_enabled(not on) return {} def _get_credentials(self) -> Credentials | None: diff --git a/kasa/smartcam/modules/lensmask.py b/kasa/smartcam/modules/lensmask.py index 7a54beb1..9257b306 100644 --- a/kasa/smartcam/modules/lensmask.py +++ b/kasa/smartcam/modules/lensmask.py @@ -12,18 +12,20 @@ _LOGGER = logging.getLogger(__name__) class LensMask(SmartCamModule): """Implementation of lens mask module.""" + REQUIRED_COMPONENT = "lensMask" + QUERY_GETTER_NAME = "getLensMaskConfig" QUERY_MODULE_NAME = "lens_mask" QUERY_SECTION_NAMES = "lens_mask_info" @property - def state(self) -> bool: + def enabled(self) -> bool: """Return the lens mask state.""" - return self.data["lens_mask_info"]["enabled"] == "off" + return self.data["lens_mask_info"]["enabled"] == "on" - async def set_state(self, state: bool) -> dict: + async def set_enabled(self, enable: bool) -> dict: """Set the lens mask state.""" - params = {"enabled": "on" if state else "off"} + params = {"enabled": "on" if enable else "off"} return await self._device._query_setter_helper( "setLensMaskConfig", self.QUERY_MODULE_NAME, "lens_mask_info", params ) diff --git a/tests/fixtures/smartcam/TC70_3.0_1.3.11.json b/tests/fixtures/smartcam/TC70_3.0_1.3.11.json new file mode 100644 index 00000000..b5726982 --- /dev/null +++ b/tests/fixtures/smartcam/TC70_3.0_1.3.11.json @@ -0,0 +1,870 @@ +{ + "discovery_result": { + "error_code": 0, + "result": { + "decrypted_data": { + "connect_ssid": "#MASKED_SSID#", + "connect_type": "wireless", + "device_id": "0000000000000000000000000000000000000000", + "http_port": 443, + "last_alarm_time": "1734271551", + "last_alarm_type": "motion", + "owner": "00000000000000000000000000000000", + "sd_status": "offline" + }, + "device_id": "00000000000000000000000000000000", + "device_model": "TC70", + "device_name": "#MASKED_NAME#", + "device_type": "SMART.IPCAMERA", + "encrypt_info": { + "data": "", + "key": "", + "sym_schm": "AES" + }, + "encrypt_type": [ + "3" + ], + "factory_default": false, + "firmware_version": "1.3.11 Build 231121 Rel.39429n(4555)", + "hardware_version": "3.0", + "ip": "127.0.0.123", + "is_support_iot_cloud": true, + "mac": "5C-E9-31-00-00-00", + "mgt_encrypt_schm": { + "is_support_https": true + } + } + }, + "getAlertPlan": { + "msg_alarm_plan": { + "chn1_msg_alarm_plan": { + ".name": "chn1_msg_alarm_plan", + ".type": "plan", + "alarm_plan_1": "0000-0000,127", + "enabled": "off" + } + } + }, + "getAppComponentList": { + "app_component": { + "app_component_list": [ + { + "name": "sdCard", + "version": 1 + }, + { + "name": "timezone", + "version": 1 + }, + { + "name": "system", + "version": 3 + }, + { + "name": "led", + "version": 1 + }, + { + "name": "playback", + "version": 4 + }, + { + "name": "detection", + "version": 1 + }, + { + "name": "alert", + "version": 1 + }, + { + "name": "firmware", + "version": 2 + }, + { + "name": "account", + "version": 1 + }, + { + "name": "quickSetup", + "version": 1 + }, + { + "name": "ptz", + "version": 1 + }, + { + "name": "video", + "version": 2 + }, + { + "name": "lensMask", + "version": 2 + }, + { + "name": "lightFrequency", + "version": 1 + }, + { + "name": "dayNightMode", + "version": 1 + }, + { + "name": "osd", + "version": 2 + }, + { + "name": "record", + "version": 1 + }, + { + "name": "videoRotation", + "version": 1 + }, + { + "name": "audio", + "version": 2 + }, + { + "name": "diagnose", + "version": 1 + }, + { + "name": "msgPush", + "version": 3 + }, + { + "name": "deviceShare", + "version": 1 + }, + { + "name": "tapoCare", + "version": 1 + }, + { + "name": "blockZone", + "version": 1 + }, + { + "name": "personDetection", + "version": 1 + }, + { + "name": "targetTrack", + "version": 1 + }, + { + "name": "babyCryDetection", + "version": 1 + }, + { + "name": "needSubscriptionServiceList", + "version": 1 + }, + { + "name": "iotCloud", + "version": 1 + }, + { + "name": "recordDownload", + "version": 1 + } + ] + } + }, + "getAudioConfig": { + "audio_config": { + "microphone": { + ".name": "microphone", + ".type": "audio_config", + "channels": "1", + "encode_type": "G711alaw", + "mute": "off", + "noise_cancelling": "on", + "sampling_rate": "8", + "volume": "100" + }, + "speaker": { + ".name": "speaker", + ".type": "audio_config", + "volume": "100" + } + } + }, + "getBCDConfig": { + "sound_detection": { + "bcd": { + ".name": "bcd", + ".type": "on_off", + "digital_sensitivity": "50", + "enabled": "off", + "sensitivity": "medium" + } + } + }, + "getCircularRecordingConfig": { + "harddisk_manage": { + "harddisk": { + ".name": "harddisk", + ".type": "storage", + "loop": "on" + } + } + }, + "getClockStatus": { + "system": { + "clock_status": { + "local_time": "2024-12-18 22:59:11", + "seconds_from_1970": 1734562751 + } + } + }, + "getConnectionType": { + "link_type": "wifi", + "rssi": "4", + "rssiValue": -50, + "ssid": "I01BU0tFRF9TU0lEIw==" + }, + "getDetectionConfig": { + "motion_detection": { + "motion_det": { + ".name": "motion_det", + ".type": "on_off", + "digital_sensitivity": "50", + "enabled": "on", + "sensitivity": "medium" + } + } + }, + "getDeviceInfo": { + "device_info": { + "basic_info": { + "avatar": "camera c212", + "barcode": "", + "dev_id": "0000000000000000000000000000000000000000", + "device_alias": "#MASKED_NAME#", + "device_info": "TC70 3.0 IPC", + "device_model": "TC70", + "device_name": "#MASKED_NAME#", + "device_type": "SMART.IPCAMERA", + "features": "3", + "ffs": false, + "has_set_location_info": 1, + "hw_desc": "00000000000000000000000000000000", + "hw_version": "3.0", + "is_cal": true, + "latitude": 0, + "longitude": 0, + "mac": "5C-E9-31-00-00-00", + "oem_id": "00000000000000000000000000000000", + "sw_version": "1.3.11 Build 231121 Rel.39429n(4555)" + } + } + }, + "getFirmwareAutoUpgradeConfig": { + "auto_upgrade": { + "common": { + ".name": "common", + ".type": "on_off", + "enabled": "off", + "random_range": "120", + "time": "03:00" + } + } + }, + "getFirmwareUpdateStatus": { + "cloud_config": { + "upgrade_status": { + "lastUpgradingSuccess": false, + "state": "normal" + } + } + }, + "getLastAlarmInfo": { + "system": { + "last_alarm_info": { + "last_alarm_time": "1734271551", + "last_alarm_type": "motion" + } + } + }, + "getLdc": { + "image": { + "common": { + ".name": "common", + ".type": "para", + "area_compensation": "default", + "chroma": "50", + "contrast": "50", + "dehaze": "off", + "exp_gain": "0", + "exp_type": "auto", + "focus_limited": "600", + "focus_type": "semi_auto", + "high_light_compensation": "off", + "inf_delay": "10", + "inf_end_time": "21600", + "inf_sensitivity": "1", + "inf_start_time": "64800", + "inf_type": "auto", + "light_freq_mode": "auto", + "lock_blue_colton": "0", + "lock_blue_gain": "0", + "lock_gb_gain": "0", + "lock_gr_gain": "0", + "lock_green_colton": "0", + "lock_red_colton": "0", + "lock_red_gain": "0", + "lock_source": "local", + "luma": "50", + "saturation": "50", + "sharpness": "50", + "shutter": "1/25", + "smartir": "off", + "smartir_level": "100", + "wb_B_gain": "50", + "wb_G_gain": "50", + "wb_R_gain": "50", + "wb_type": "auto", + "wd_gain": "50", + "wide_dynamic": "off" + }, + "switch": { + ".name": "switch", + ".type": "switch_type", + "flip_type": "off", + "ldc": "off", + "night_vision_mode": "inf_night_vision", + "rotate_type": "off", + "schedule_end_time": "64800", + "schedule_start_time": "21600", + "switch_mode": "common", + "wtl_intensity_level": "5" + } + } + }, + "getLedStatus": { + "led": { + "config": { + ".name": "config", + ".type": "led", + "enabled": "on" + } + } + }, + "getLensMaskConfig": { + "lens_mask": { + "lens_mask_info": { + ".name": "lens_mask_info", + ".type": "lens_mask_info", + "enabled": "on" + } + } + }, + "getLightFrequencyInfo": { + "image": { + "common": { + ".name": "common", + ".type": "para", + "area_compensation": "default", + "chroma": "50", + "contrast": "50", + "dehaze": "off", + "exp_gain": "0", + "exp_type": "auto", + "focus_limited": "600", + "focus_type": "semi_auto", + "high_light_compensation": "off", + "inf_delay": "10", + "inf_end_time": "21600", + "inf_sensitivity": "1", + "inf_start_time": "64800", + "inf_type": "auto", + "light_freq_mode": "auto", + "lock_blue_colton": "0", + "lock_blue_gain": "0", + "lock_gb_gain": "0", + "lock_gr_gain": "0", + "lock_green_colton": "0", + "lock_red_colton": "0", + "lock_red_gain": "0", + "lock_source": "local", + "luma": "50", + "saturation": "50", + "sharpness": "50", + "shutter": "1/25", + "smartir": "off", + "smartir_level": "100", + "wb_B_gain": "50", + "wb_G_gain": "50", + "wb_R_gain": "50", + "wb_type": "auto", + "wd_gain": "50", + "wide_dynamic": "off" + } + } + }, + "getMediaEncrypt": { + "cet": { + "media_encrypt": { + ".name": "media_encrypt", + ".type": "on_off", + "enabled": "on" + } + } + }, + "getMsgPushConfig": { + "msg_push": { + "chn1_msg_push_info": { + ".name": "chn1_msg_push_info", + ".type": "on_off", + "notification_enabled": "on", + "rich_notification_enabled": "off" + } + } + }, + "getNightVisionModeConfig": { + "image": { + "switch": { + ".name": "switch", + ".type": "switch_type", + "flip_type": "off", + "ldc": "off", + "night_vision_mode": "inf_night_vision", + "rotate_type": "off", + "schedule_end_time": "64800", + "schedule_start_time": "21600", + "switch_mode": "common", + "wtl_intensity_level": "5" + } + } + }, + "getPersonDetectionConfig": { + "people_detection": { + "detection": { + ".name": "detection", + ".type": "on_off", + "enabled": "off" + } + } + }, + "getPresetConfig": { + "preset": { + "preset": { + "id": [ + "1" + ], + "name": [ + "Viewpoint 1" + ], + "position_pan": [ + "0.088935" + ], + "position_tilt": [ + "-1.000000" + ], + "read_only": [ + "0" + ] + } + } + }, + "getRecordPlan": { + "record_plan": { + "chn1_channel": { + ".name": "chn1_channel", + ".type": "plan", + "enabled": "on", + "friday": "[\"0000-2400:2\"]", + "monday": "[\"0000-2400:2\"]", + "saturday": "[\"0000-2400:2\"]", + "sunday": "[\"0000-2400:2\"]", + "thursday": "[\"0000-2400:2\"]", + "tuesday": "[\"0000-2400:2\"]", + "wednesday": "[\"0000-2400:2\"]" + } + } + }, + "getRotationStatus": { + "image": { + "switch": { + ".name": "switch", + ".type": "switch_type", + "flip_type": "off", + "ldc": "off", + "night_vision_mode": "inf_night_vision", + "rotate_type": "off", + "schedule_end_time": "64800", + "schedule_start_time": "21600", + "switch_mode": "common", + "wtl_intensity_level": "5" + } + } + }, + "getSdCardStatus": { + "harddisk_manage": { + "hd_info": [ + { + "hd_info_1": { + "detect_status": "offline", + "disk_name": "1", + "free_space": "0B", + "loop_record_status": "0", + "msg_push_free_space": "0B", + "msg_push_total_space": "0B", + "percent": "0", + "picture_free_space": "0B", + "picture_total_space": "0B", + "record_duration": "0", + "record_free_duration": "0", + "record_start_time": "0", + "rw_attr": "r", + "status": "offline", + "total_space": "0B", + "type": "local", + "video_free_space": "0B", + "video_total_space": "0B", + "write_protect": "0" + } + } + ] + } + }, + "getTamperDetectionConfig": { + "tamper_detection": { + "tamper_det": { + ".name": "tamper_det", + ".type": "on_off", + "digital_sensitivity": "50", + "enabled": "off", + "sensitivity": "medium" + } + } + }, + "getTargetTrackConfig": { + "target_track": { + "target_track_info": { + ".name": "target_track_info", + ".type": "target_track_info", + "enabled": "off" + } + } + }, + "getTimezone": { + "system": { + "basic": { + ".name": "basic", + ".type": "setting", + "timezone": "UTC-00:00", + "timing_mode": "ntp", + "zone_id": "Europe/London" + } + } + }, + "getVideoCapability": { + "video_capability": { + "main": { + ".name": "main", + ".type": "capability", + "bitrate_types": [ + "cbr", + "vbr" + ], + "bitrates": [ + "256", + "512", + "1024", + "2048" + ], + "encode_types": [ + "H264" + ], + "frame_rates": [ + "65537", + "65546", + "65551" + ], + "qualitys": [ + "1", + "3", + "5" + ], + "resolutions": [ + "1920*1080", + "1280*720", + "640*360" + ] + } + } + }, + "getVideoQualities": { + "video": { + "main": { + ".name": "main", + ".type": "stream", + "bitrate": "1024", + "bitrate_type": "vbr", + "encode_type": "H264", + "frame_rate": "65551", + "gop_factor": "2", + "name": "VideoEncoder_1", + "quality": "3", + "resolution": "1280*720", + "stream_type": "general" + } + } + }, + "getWhitelampConfig": { + "image": { + "switch": { + ".name": "switch", + ".type": "switch_type", + "flip_type": "off", + "ldc": "off", + "night_vision_mode": "inf_night_vision", + "rotate_type": "off", + "schedule_end_time": "64800", + "schedule_start_time": "21600", + "switch_mode": "common", + "wtl_intensity_level": "5" + } + } + }, + "getWhitelampStatus": { + "rest_time": 0, + "status": 0 + }, + "get_audio_capability": { + "get": { + "audio_capability": { + "device_microphone": { + ".name": "device_microphone", + ".type": "capability", + "aec": "1", + "channels": "1", + "echo_cancelling": "0", + "encode_type": [ + "G711alaw" + ], + "half_duplex": "1", + "mute": "1", + "noise_cancelling": "1", + "sampling_rate": [ + "8" + ], + "volume": "1" + }, + "device_speaker": { + ".name": "device_speaker", + ".type": "capability", + "channels": "1", + "decode_type": [ + "G711" + ], + "mute": "0", + "sampling_rate": [ + "8" + ], + "volume": "1" + } + } + } + }, + "get_audio_config": { + "get": { + "audio_config": { + "microphone": { + ".name": "microphone", + ".type": "audio_config", + "channels": "1", + "encode_type": "G711alaw", + "mute": "off", + "noise_cancelling": "on", + "sampling_rate": "8", + "volume": "100" + }, + "speaker": { + ".name": "speaker", + ".type": "audio_config", + "volume": "100" + } + } + } + }, + "get_cet": { + "get": { + "cet": { + "vhttpd": { + ".name": "vhttpd", + ".type": "server", + "port": "8800" + } + } + } + }, + "get_function": { + "get": { + "function": { + "module_spec": { + ".name": "module_spec", + ".type": "module-spec", + "ae_weighting_table_resolution": "5*5", + "ai_enhance_capability": "1", + "app_version": "1.0.0", + "audio": [ + "speaker", + "microphone" + ], + "audioexception_detection": "0", + "auth_encrypt": "1", + "backlight_coexistence": "1", + "change_password": "1", + "client_info": "1", + "cloud_storage_version": "1.0", + "custom_area_compensation": "1", + "custom_auto_mode_exposure_level": "0", + "device_share": [ + "preview", + "playback", + "voice", + "motor", + "cloud_storage" + ], + "download": [ + "video" + ], + "events": [ + "motion", + "tamper" + ], + "greeter": "1.0", + "http_system_state_audio_support": "1", + "intrusion_detection": "1", + "led": "1", + "lens_mask": "1", + "linecrossing_detection": "1", + "linkage_capability": "1", + "local_storage": "1", + "media_encrypt": "1", + "msg_alarm": "1", + "msg_alarm_list": [ + "sound", + "light" + ], + "msg_alarm_separate_list": [ + "light", + "sound" + ], + "msg_push": "1", + "multi_user": "0", + "multicast": "0", + "network": [ + "wifi" + ], + "ota_upgrade": "1", + "p2p_support_versions": [ + "1.1" + ], + "playback": [ + "local", + "p2p", + "relay" + ], + "playback_scale": "1", + "preview": [ + "local", + "p2p", + "relay" + ], + "privacy_mask_api_version": "1.0", + "ptz": "1", + "record_max_slot_cnt": "10", + "record_type": [ + "timing", + "motion" + ], + "relay_support_versions": [ + "1.3" + ], + "reonboarding": "1", + "smart_detection": "1", + "smart_msg_push_capability": "1", + "ssl_cer_version": "1.0", + "storage_api_version": "2.2", + "stream_max_sessions": "10", + "streaming_support_versions": [ + "1.0" + ], + "target_track": "1.0", + "timing_reboot": "1", + "verification_change_password": "1", + "video_codec": [ + "h264" + ], + "video_detection_digital_sensitivity": "1", + "wifi_cascade_connection": "1", + "wifi_connection_info": "1", + "wireless_hotspot": "1" + } + } + } + }, + "get_motor": { + "get": { + "motor": { + "capability": { + ".name": "capability", + ".type": "ptz", + "absolute_move_supported": "1", + "calibrate_supported": "1", + "continuous_move_supported": "1", + "eflip_mode": [ + "off", + "on" + ], + "home_position_mode": "none", + "limit_supported": "0", + "manual_control_level": [ + "low", + "normal", + "high" + ], + "manual_control_mode": [ + "compatible", + "pedestrian", + "motor_vehicle", + "non_motor_vehicle", + "self_adaptive" + ], + "park_supported": "0", + "pattern_supported": "0", + "plan_supported": "0", + "position_pan_range": [ + "-1.000000", + "1.000000" + ], + "position_tilt_range": [ + "-1.000000", + "1.000000" + ], + "poweroff_save_supported": "1", + "poweroff_save_time_range": [ + "10", + "600" + ], + "preset_number_max": "8", + "preset_supported": "1", + "relative_move_supported": "1", + "reverse_mode": [ + "off", + "on", + "auto" + ], + "scan_supported": "0", + "speed_pan_max": "1.00000", + "speed_tilt_max": "1.000000", + "tour_supported": "0" + } + } + } + } +}