### Example Usage with Custom Endpoint Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md An example demonstrating how to use the pyezvizapi with a specific username, password, and a custom regional endpoint, such as the US endpoint. ```bash pyezvizapi -u username@domain.com -p PASS@123 -r apius.ezvizlife.com devices status ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Install necessary packages for development or local usage of the pyezvizapi library. ```bash pip install requests paho-mqtt pycryptodome pandas ``` -------------------------------- ### Install pyezvizapi Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Install the pyezvizapi package using pip. This command makes the `pyezvizapi` command-line tool available. ```bash pip install pyezvizapi ``` -------------------------------- ### Quick Start: First-time Login and Save Token Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Perform an initial login using username and password, saving the session token for future use. This command also fetches and displays device status. ```bash pyezvizapi -u YOUR_EZVIZ_USERNAME -p YOUR_EZVIZ_PASSWORD --save-token devices status ``` -------------------------------- ### PyEzvizAPI CLI Usage Examples Source: https://context7.com/renierm26/pyezvizapi/llms.txt Command-line interface for quick device operations. Supports login, device status, camera control, light operations, and debugging. ```bash # First-time login and save token pyezvizapi -u YOUR_USERNAME -p YOUR_PASSWORD --save-token devices status # Reuse saved token for subsequent commands pyezvizapi devices status --json # List all devices with connection info pyezvizapi devices connection # Get device switches pyezvizapi devices switch # Camera operations pyezvizapi camera --serial ABC123 status pyezvizapi camera --serial ABC123 move --direction up --speed 5 pyezvizapi camera --serial ABC123 move_coords --x 0.5 --y 0.5 pyezvizapi camera --serial ABC123 switch --switch privacy --enable 1 pyezvizapi camera --serial ABC123 switch --switch sleep --enable 0 pyezvizapi camera --serial ABC123 alarm --notify 1 --sound 1 --sensibility 3 pyezvizapi camera --serial ABC123 select --battery_work_mode HIGH_PERFORMANCE # Door lock operations pyezvizapi camera --serial DOORBELL_SERIAL unlock-door pyezvizapi camera --serial DOORBELL_SERIAL unlock-gate # Light bulb operations pyezvizapi devices_light status pyezvizapi light --serial LIGHT_SERIAL toggle pyezvizapi light --serial LIGHT_SERIAL status # Set home defense mode pyezvizapi home_defence_mode --mode HOME_MODE pyezvizapi home_defence_mode --mode AWAY_MODE # MQTT push notifications (debug mode) pyezvizapi --debug mqtt # Dump raw API data for debugging pyezvizapi pagelist > pagelist.json pyezvizapi device_infos > device_infos.json pyezvizapi device_infos --serial ABC123 > single_device.json # Unified message list (alarm feed) pyezvizapi unifiedmsg --limit 20 --urls-only # Use different region pyezvizapi -u user@example.com -p pass -r apiius.ezvizlife.com devices status ``` -------------------------------- ### CLI Command: Set Home Defence Mode Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Set the global defence mode for the account or home, for example, to 'HOME_MODE'. ```bash pyezvizapi home_defence_mode --mode HOME_MODE ``` -------------------------------- ### CLI Command: Get Device Status (Table View) Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Fetch and display the status of all connected devices in a human-readable table format. ```bash pyezvizapi devices status ``` -------------------------------- ### Quick Start: Reuse Saved Token Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Use the previously saved session token to fetch device status in JSON format without needing credentials. ```bash pyezvizapi devices status --json ``` -------------------------------- ### Trigger IoT Action Source: https://context7.com/renierm26/pyezvizapi/llms.txt Initiate an IoT action on a device, like starting auto-tracking. Requires serial number, resource identifiers, and action details. ```python client.set_iot_action( serial, resource_identifier="Video", local_index="1", domain_id="PTZ", action_id="StartTrack", value={"trackingMode": "auto"} ) ``` -------------------------------- ### Get Single Device Information Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Use this command to retrieve information about a single Ezviz device by its serial number. The output is saved to a JSON file. ```bash pyezvizapi device_infos --serial ABC123 > ABC123.json ``` -------------------------------- ### Get Storage Status Source: https://context7.com/renierm26/pyezvizapi/llms.txt Retrieve the current storage status information for a specified device. ```python storage = client.get_storage_status(serial) print(f"Storage: {storage}") ``` -------------------------------- ### Get Detection Sensitivity Source: https://context7.com/renierm26/pyezvizapi/llms.txt Retrieve the current detection sensitivity settings for a device, specifying the type value. ```python sensitivity = client.get_detection_sensibility(serial, type_value="0") print(f"Sensitivity: {sensitivity}") ``` -------------------------------- ### Get and Set Port Security Configuration Source: https://context7.com/renierm26/pyezvizapi/llms.txt Retrieve the current port security settings and then configure SSH and Telnet access. Requires the device serial number. ```python port_security = client.get_port_security(serial) print(f"Port security: {port_security}") ``` ```python client.set_port_security(serial, value={"ssh": False, "telnet": False}) ``` -------------------------------- ### Get Group Defense Mode Status Source: https://context7.com/renierm26/pyezvizapi/llms.txt Retrieve the current group defense mode status. ```python mode = client.get_group_defence_mode() print(f"Current defense mode: {mode}") ``` -------------------------------- ### Get Tracking Status Source: https://context7.com/renierm26/pyezvizapi/llms.txt Retrieve the tracking status for a specific video resource. Requires serial number and detailed resource identifiers. ```python tracking = client.get_tracking_status( serial, resource_identifier="Video", local_index="1", domain_id="PTZ", action_id="TrackingStatus" ) ``` -------------------------------- ### Initialize EzvizClient and Login Source: https://context7.com/renierm26/pyezvizapi/llms.txt Initialize the EzvizClient with account credentials and log in to obtain a session token. The token can be reused for subsequent sessions. Always close the session when done. ```python from pyezvizapi import EzvizClient # Initialize with username and password client = EzvizClient( account="your_email@example.com", password="your_password", url="apiieu.ezvizlife.com", # EU region, use "apiius.ezvizlife.com" for US timeout=25 ) # Login to obtain session token token = client.login() print(f"Logged in as: {token['username']}") print(f"Session ID: {token['session_id']}") # Reuse token for subsequent sessions saved_token = client.export_token() # Initialize client with existing token (no credentials needed) client_reuse = EzvizClient(token=saved_token) client_reuse.login() # Refreshes the session # Always close the session when done client.close_session() ``` -------------------------------- ### Set up MQTT Client for Real-time Notifications Source: https://context7.com/renierm26/pyezvizapi/llms.txt Initialize an MQTTClient to receive real-time push notifications from Ezviz devices. Requires an EzvizClient instance and a message callback function. ```python from pyezvizapi import EzvizClient, MQTTClient def handle_message(message: dict): """Callback for incoming MQTT messages.""" ext = message.get("ext", {}) device_serial = ext.get("device_serial") alert_type = ext.get("alert_type_code") image_url = ext.get("default_pic_url") print(f"Alert from {device_serial}: Type {alert_type}") if image_url: print(f" Image: {image_url}") client = EzvizClient(account="user@example.com", password="password") client.login() # Get MQTT client with callback mqtt_client = client.get_mqtt_client(on_message_callback=handle_message) # Connect to MQTT broker mqtt_client.connect(clean_session=True, keepalive=60) ``` -------------------------------- ### Configure Device Settings by Key Source: https://context7.com/renierm26/pyezvizapi/llms.txt Set specific device configurations using a key-value pair, where the value is typically a JSON string. ```python client.set_device_config_by_key(serial, value='{"type":1}', key="Alarm_DetectHumanCar") ``` -------------------------------- ### CLI Command: Connect to MQTT Notifications Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Establish a connection to receive Ezviz MQTT push notifications using the current session token. Use `--debug` for detailed connection information. ```bash pyezvizapi mqtt ``` -------------------------------- ### Initialize and Control Ezviz Light Bulb Source: https://context7.com/renierm26/pyezvizapi/llms.txt Initialize an EzvizLightBulb instance and control its power, brightness, and retrieve its status. Requires client login and bulb serial number. ```python client = EzvizClient(account="user@example.com", password="password") client.login() # Create light bulb instance bulb = EzvizLightBulb(client, "LIGHT_BULB_SERIAL") # Get light bulb status status = bulb.status() print(f"Light: {status['name']}") print(f"Is On: {status['is_on']}") print(f"Brightness: {status['brightness']}") print(f"Color Temperature: {status['color_temperature']}") print(f"Product ID: {status['productId']}") # Power control bulb.power_on() bulb.power_off() bulb.toggle_switch() # Toggle current state # Set brightness (1-100) bulb.set_brightness(75) ``` -------------------------------- ### CLI Command: Light Bulb Status Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Retrieve the status of connected Ezviz light bulbs. ```bash pyezvizapi devices_light status ``` -------------------------------- ### Development: Run Tests Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Execute project tests using tox. This command ensures that all functionalities are working as expected. ```bash tox ``` -------------------------------- ### Development: Code Formatting and Checking Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Use Ruff for code checking and formatting, and mypy for type checking. These commands ensure code quality and adherence to standards. ```bash ruff check . ``` ```bash mypy config/custom_components/ezviz_cloud/pyezvizapi ``` -------------------------------- ### MQTT Push Test Script: Interactive Login and Save Token Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Run the MQTT test script interactively, prompting for credentials if needed (including MFA), and saving the session token for future use. ```python python config/custom_components/ezviz_cloud/pyezvizapi/test_mqtt.py --save-token ``` -------------------------------- ### Reboot and Upgrade Device Source: https://context7.com/renierm26/pyezvizapi/llms.txt Reboot a camera with an optional delay or initiate a firmware upgrade for a device. ```python # Reboot camera client.reboot_camera(serial, delay=1) # Upgrade device firmware client.upgrade_device(serial) ``` -------------------------------- ### CLI Command: Camera Alarm Settings Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Configure alarm settings for a camera, including push notification preferences, sound levels, and do-not-disturb status. ```bash pyezvizapi camera --serial ABC123 alarm --notify 1 --sound 2 --do_not_disturb 0 ``` -------------------------------- ### CLI Command: Dump Device Infos JSON Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Output the processed device information mapping, used by integrations, in JSON format. Optionally filter for a specific device serial. ```bash pyezvizapi device_infos > device_infos.json ``` -------------------------------- ### Set Defense Schedule Source: https://context7.com/renierm26/pyezvizapi/llms.txt Configure a defense schedule for a device using a JSON formatted string. The schedule can be enabled or disabled. ```python # Set defense schedule (JSON format) schedule = '{"monday":"00:00-23:59","tuesday":"00:00-23:59"}' client.api_set_defence_schedule(serial, schedule=schedule, enable=1) ``` -------------------------------- ### MQTT Push Test Script: Use Saved Token Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Run the standalone MQTT push test script using a previously saved token file. ```python python config/custom_components/ezviz_cloud/pyezvizapi/test_mqtt.py --token-file ezviz_token.json ``` -------------------------------- ### CLI Command: Camera Move by Coordinates Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Move a camera to a specific position defined by X and Y coordinates. ```bash pyezvizapi camera --serial ABC123 move_coords --x 0.4 --y 0.6 ``` -------------------------------- ### Control Light Bulb via Client Methods Source: https://context7.com/renierm26/pyezvizapi/llms.txt Control light bulb status and brightness directly using EzvizClient methods, specifying the device serial number. ```python client.switch_light_status(serial="LIGHT_BULB_SERIAL", enable=1) client.set_brightness(serial="LIGHT_BULB_SERIAL", luminance=50) ``` -------------------------------- ### Set Global Defense Mode Source: https://context7.com/renierm26/pyezvizapi/llms.txt Configure the global defense mode for all connected devices. Use constants like DefenseModeType.HOME_MODE or DefenseModeType.AWAY_MODE. ```python client.api_set_defence_mode(DefenseModeType.HOME_MODE) client.api_set_defence_mode(DefenseModeType.AWAY_MODE) ``` -------------------------------- ### Load Devices and Status Source: https://context7.com/renierm26/pyezvizapi/llms.txt Load all devices, cameras, or light bulbs associated with the account. Displays details like name, serial, status, local IP, privacy mode, motion detection, last alarm time, and battery level for cameras. For light bulbs, it shows if they are on, brightness, and color temperature. ```python from pyezvizapi import EzvizClient client = EzvizClient(account="user@example.com", password="password") client.login() # Load all devices (cameras, light bulbs, smart plugs) all_devices = client.load_devices(refresh=True) # Load only cameras cameras = client.load_cameras(refresh=True) for serial, camera_data in cameras.items(): print(f"Camera: {camera_data['name']}") print(f" Serial: {serial}") print(f" Status: {'Online' if camera_data['status'] == 1 else 'Offline'}") print(f" Local IP: {camera_data['local_ip']}") print(f" Privacy Mode: {camera_data['switches'].get(7, False)}" ) # Switch 7 = Privacy print(f" Motion Detected: {camera_data['Motion_Trigger']}") print(f" Last Alarm: {camera_data['last_alarm_time']}") print(f" Battery Level: {camera_data['battery_level']}") # Load only light bulbs light_bulbs = client.load_light_bulbs(refresh=True) for serial, bulb_data in light_bulbs.items(): print(f"Light Bulb: {bulb_data['name']}") print(f" Is On: {bulb_data['is_on']}") print(f" Brightness: {bulb_data['brightness']}") print(f" Color Temperature: {bulb_data['color_temperature']}") client.close_session() ``` -------------------------------- ### Control Advanced IoT Features Source: https://context7.com/renierm26/pyezvizapi/llms.txt Manage advanced IoT features like intelligent fill light. Requires device serial and specific parameters for each feature. ```python from pyezvizapi import EzvizClient client = EzvizClient(account="user@example.com", password="password") client.login() serial = "DEVICE_SERIAL" # Set intelligent fill light mode client.set_intelligent_fill_light(serial, enabled=True, local_index="1") ``` -------------------------------- ### Manage Video Encryption and Authentication Source: https://context7.com/renierm26/pyezvizapi/llms.txt Handles video encryption keys, authentication codes, and enables/disables encryption. Requires handling `EzvizAuthVerificationCode` exceptions for 2FA. ```python from pyezvizapi import EzvizClient from pyezvizapi.exceptions import EzvizAuthVerificationCode client = EzvizClient(account="user@example.com", password="password") client.login() serial = "DEVICE_SERIAL" # Get camera encryption key (requires elevated permissions) try: encrypt_key = client.get_cam_key(serial) print(f"Encryption key: {encrypt_key}") except EzvizAuthVerificationCode: # 2FA required - request code first response = client.get_2fa_check_code(biz_type="DEVICE_ENCRYPTION", username="user@example.com") print(f"2FA code sent to: {response['contact']['fuzzyContact']}") # Retry with SMS code sms_code = input("Enter 2FA code: ") encrypt_key = client.get_cam_key(serial, smscode=int(sms_code)) # Get device authentication code (sticker code) try: auth_code = client.get_cam_auth_code(serial) print(f"Auth code: {auth_code}") except EzvizAuthVerificationCode: # 2FA required client.get_2fa_check_code(biz_type="DEVICE_AUTH_CODE", username="user@example.com") sms_code = input("Enter 2FA code: ") auth_code = client.get_cam_auth_code(serial, msg_auth_code=int(sms_code), sender_type=3) # Enable/disable video encryption client.set_video_enc( serial=serial, enable=1, # 0=disable, 1=enable, 2=change password camera_verification_code="VERIFICATION_CODE" ) # Change encryption password client.set_video_enc( serial=serial, enable=2, old_password="old_pass", new_password="new_pass" ) client.close_session() ``` -------------------------------- ### CLI Command: Dump Raw Pagelist JSON Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Output the complete raw pagelist data in JSON format, which is useful for exploring unknown fields in an editor. ```bash pyezvizapi pagelist > pagelist.json ``` -------------------------------- ### CLI Command: Camera Switch Setter Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Enable or disable specific camera features like privacy mode, sleep mode, or IR LEDs using a switch and enable/disable flags. ```bash pyezvizapi camera --serial ABC123 switch --switch privacy --enable 1 ``` -------------------------------- ### Configure Camera Alarm Settings Source: https://context7.com/renierm26/pyezvizapi/llms.txt Enable or disable alarm notifications, set alarm sound types, adjust detection sensitivity, and manage do-not-disturb settings for cameras. ```python camera.alarm_notify(enable=True) # Enable alarm notifications camera.alarm_sound(sound_type=1) # 0=soft, 1=intensive, 2=silent camera.alarm_detection_sensitivity(sensitivity=3, type_value=0) # 1-6 for type 0 camera.do_not_disturb(enable=False) # Disable do-not-disturb ``` -------------------------------- ### CLI Command: Camera PTZ Move Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Control the Pan-Tilt-Zoom (PTZ) functionality of a camera by specifying direction and speed. ```bash pyezvizapi camera --serial ABC123 move --direction up --speed 5 ``` -------------------------------- ### MQTT Push Test Script: Explicit Credentials Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Run the MQTT test script using explicit username and password. This method is not recommended for shared terminals. ```python python config/custom_components/ezviz_cloud/pyezvizapi/test_mqtt.py -u USER -p PASS --save-token ``` -------------------------------- ### Set Display Mode Source: https://context7.com/renierm26/pyezvizapi/llms.txt Adjust the display mode of the device, options include original, soft, and vivid. ```python client.set_display_mode(serial, mode=1) # 1=Original, 2=Soft, 3=Vivid ``` -------------------------------- ### Comprehensive Ezviz API Error Handling Source: https://context7.com/renierm26/pyezvizapi/llms.txt Demonstrates robust error handling for various PyEzviz API exceptions, including authentication, network, and device-specific errors. Ensure to import necessary exception types. ```python from pyezvizapi import EzvizClient from pyezvizapi.exceptions import ( PyEzvizError, HTTPError, InvalidURL, EzvizAuthTokenExpired, EzvizAuthVerificationCode, DeviceException ) client = EzvizClient(account="user@example.com", password="password") try: client.login() cameras = client.load_cameras() except EzvizAuthVerificationCode as e: # MFA code required print(f"MFA required: {e}") mfa_code = input("Enter MFA code: ") client.login(sms_code=int(mfa_code)) except EzvizAuthTokenExpired as e: # Token expired, need fresh login print(f"Token expired: {e}") client.login() except InvalidURL as e: # Invalid URL or proxy error print(f"Connection error: {e}") except HTTPError as e: # HTTP request failed print(f"HTTP error: {e}") except DeviceException as e: # Device-specific error (offline, unreachable) print(f"Device error: {e}") except PyEzvizError as e: # General API error print(f"API error: {e}") finally: client.close_session() ``` -------------------------------- ### Manage Intelligent Detection App Source: https://context7.com/renierm26/pyezvizapi/llms.txt Add or remove intelligent detection applications like human or car detection from a device. Requires device resource ID, app name, and action. ```python client.manage_intelligent_app( serial, resource_id="VIDEO_RESOURCE_ID", app_name="app_human_detect", # or app_car_detect, app_video_change action="add" # or "remove" ) ``` -------------------------------- ### Configure Detection Sensitivity Source: https://context7.com/renierm26/pyezvizapi/llms.txt Set the sensitivity level for device detection, specifying a type value and a sensitivity level from 1 to 6. ```python client.detection_sensibility(serial, sensibility=3, type_value=0) # 1-6 for type 0 ``` -------------------------------- ### CLI Command: Battery Camera Work Mode Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Set the operating mode for a battery-powered camera, such as 'POWER_SAVE' mode. ```bash pyezvizapi camera --serial ABC123 select --battery_work_mode POWER_SAVE ``` -------------------------------- ### Configure Device Detection Mode Source: https://context7.com/renierm26/pyezvizapi/llms.txt Set the detection mode for a specific device, such as human, vehicle, or PIR detection. Use integer values for configuration. ```python client.set_alarm_detect_human_car(serial, value=1) # 1=human, 5=PIR, 3=image change ``` -------------------------------- ### Set Battery Camera Work Mode Source: https://context7.com/renierm26/pyezvizapi/llms.txt Configure the work mode for battery-powered cameras to optimize performance. ```python camera.set_battery_camera_work_mode(BatteryCameraWorkMode.HIGH_PERFORMANCE) ``` -------------------------------- ### RTSP Authentication Test Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Tests RTSP credentials by issuing a DESCRIBE request. It automatically falls back from Basic to Digest authentication. On success, it prints a confirmation; on failure, it raises specific exceptions. ```python python -c "from config.custom_components.ezviz_cloud.pyezvizapi.test_cam_rtsp import TestRTSPAuth as T; T('', '', '', '/Streaming/Channels/101').main()" ``` -------------------------------- ### Set Floodlight Brightness Source: https://context7.com/renierm26/pyezvizapi/llms.txt Adjust the brightness of a device's floodlight, with values ranging from 1 to 100. ```python client.set_floodlight_brightness(serial, luminance=50) ``` -------------------------------- ### Set Image Flip via IoT Feature Source: https://context7.com/renierm26/pyezvizapi/llms.txt Use this to enable or disable image flipping on a device using the IoT feature. Requires the device serial number and a boolean for enabling. ```python client.set_image_flip_iot(serial, enabled=True, local_index="1") ``` -------------------------------- ### Development: Apply Style Fixes Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Automatically apply style fixes to the code using Ruff. This command helps maintain consistent code style across the project. ```bash ruff check --fix config/custom_components/ezviz_cloud/pyezvizapi ``` -------------------------------- ### CLI Command: Camera Status Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Retrieve the current status of a specific camera using its serial number. ```bash pyezvizapi camera --serial ABC123 status ``` -------------------------------- ### Retrieve Device Alarms and Messages Source: https://context7.com/renierm26/pyezvizapi/llms.txt Use this method to fetch alarm history and unified messages from devices. Specify device serials, a limit, and a date. The `end_time` parameter is used for pagination. ```python from pyezvizapi import EzvizClient import datetime client = EzvizClient(account="user@example.com", password="password") client.login() # Get unified message list (alarm feed) messages = client.get_device_messages_list( serials="DEVICE_SERIAL", # Optional: comma-separated serials or None for all limit=20, # Max 50 date=datetime.date.today().strftime("%Y%m%d"), end_time="" # Pagination token from previous call ) for msg in messages.get("message", []): print(f"Device: {msg.get('deviceSerial')}") print(f"Time: {msg.get('timeStr')}") print(f"Type: {msg.get('subType')}") print(f"Title: {msg.get('title')}") print(f"Image: {msg.get('pic')}") print("---") # Get alarm info for specific camera alarm_info = client.get_alarminfo(serial="DEVICE_SERIAL", limit=5) print(f"Alarm data: {alarm_info}") # Cancel active alarm on device client.cancel_alarm_device(serial="DEVICE_SERIAL") # Sound alarm on device client.sound_alarm(serial="DEVICE_SERIAL", enable=1) client.close_session() ``` -------------------------------- ### Control Door Lock and Gate Source: https://context7.com/renierm26/pyezvizapi/llms.txt Unlock door locks and gates using the provided methods. Ensure device compatibility before use. ```python camera.door_unlock() camera.gate_unlock() ``` -------------------------------- ### Control Ezviz Camera Features Source: https://context7.com/renierm26/pyezvizapi/llms.txt Control individual camera features including PTZ movement, privacy mode, sleep mode, audio, IR LED, status LED, and motion tracking. Generic switch control is also available using DeviceSwitchType. ```python from pyezvizapi import EzvizClient, EzvizCamera from pyezvizapi.constants import DeviceSwitchType, BatteryCameraWorkMode client = EzvizClient(account="user@example.com", password="password") client.login() # Create camera instance camera = EzvizCamera(client, "DEVICE_SERIAL_NUMBER") # Get camera status status = camera.status(refresh=True) print(f"Camera: {status['name']}") print(f"Firmware: {status['version']}") print(f"Upgrade Available: {status['upgrade_available']}") print(f"Encrypted: {status['encrypted']}") # PTZ Control - Move camera camera.move(direction="up", speed=5) camera.move(direction="down", speed=5) camera.move(direction="left", speed=3) camera.move(direction="right", speed=3) # Move to specific coordinates (0.0 to 1.0) camera.move_coordinates(x_axis=0.5, y_axis=0.5) # Toggle device switches camera.switch_privacy_mode(enable=True) # Enable privacy mode camera.switch_sleep_mode(enable=False) # Disable sleep mode camera.switch_device_audio(enable=True) # Enable audio camera.switch_device_ir_led(enable=True) # Enable infrared LED camera.switch_device_state_led(enable=False) # Disable status LED camera.switch_follow_move(enable=True) # Enable motion tracking # Generic switch control camera.set_switch(DeviceSwitchType.PRIVACY, enable=True) ``` -------------------------------- ### Set IoT Feature Value Source: https://context7.com/renierm26/pyezvizapi/llms.txt Set a specific IoT feature value for a device, such as image flip. Requires detailed resource and action identifiers along with the value. ```python client.set_iot_feature( serial, resource_identifier="Video", local_index="1", domain_id="VideoAdjustment", action_id="ImageFlip", value={"value": {"enabled": True}} ) ``` -------------------------------- ### Set Night Vision Mode Source: https://context7.com/renierm26/pyezvizapi/llms.txt Configure the night vision mode for a device, choosing between black and white, color, or smart modes. Luminance can also be adjusted. ```python client.set_night_vision_mode(serial, mode=2, luminance=100) # 0=B&W, 1=Color, 2=Smart ``` -------------------------------- ### Close Ezviz Client Session Source: https://context7.com/renierm26/pyezvizapi/llms.txt Properly close the session with the Ezviz client to release resources. ```python client.close_session() ``` -------------------------------- ### Access and Decode MQTT Messages Source: https://context7.com/renierm26/pyezvizapi/llms.txt Retrieve the last MQTT message for a specific device or manually decode raw MQTT payloads. ```python # Messages are stored per device # Access last message for a specific device last_msg = mqtt_client.messages_by_device.get("DEVICE_SERIAL") if last_msg: print(f"Last message: {last_msg}") # Decode raw MQTT payload manually if needed raw_payload = b'{"id":"123","ext":"1,1234567890,ABC123,1,2402,..."}' decoded = mqtt_client.decode_mqtt_message(raw_payload) print(f"Decoded: {decoded}") # Stop MQTT client when done mqtt_client.stop() client.close_session() ``` -------------------------------- ### Set Lens Defog Mode Source: https://context7.com/renierm26/pyezvizapi/llms.txt Configure the lens defog mode for a device. Accepts a value representing auto (0), on (1), or off (2). Returns the enabled status and the mode set. ```python enabled, mode = client.set_lens_defog_mode(serial, value=0) print(f"Defog: enabled={enabled}, mode={mode}") ``` -------------------------------- ### Remote Door and Gate Unlock Source: https://github.com/renierm26/pyezvizapi/blob/main/README.md Commands to remotely unlock a door or gate for compatible CS-HPD7 devices. Ensure the correct serial number is provided. ```bash pyezvizapi camera --serial BAXXXXXXX-BAYYYYYYY unlock-door ``` ```bash pyezvizapi camera --serial BAXXXXXXX-BAYYYYYYY unlock-gate ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.