### POST /login Source: https://context7.com/persandstrom/python-verisure/llms.txt Authenticates the user with credentials and returns available installations. ```APIDOC ## POST /login ### Description Authenticates the user using email and password. Returns a list of installations associated with the account. ### Method POST ### Endpoint /login ### Request Body - **username** (string) - Required - User email address - **password** (string) - Required - User account password ### Response #### Success Response (200) - **installations** (array) - List of installation objects containing giid and alias #### Response Example { "data": { "account": { "installations": [ { "giid": "123456789000", "alias": "MY HOME" } ] } } } ``` -------------------------------- ### Install Verisure Library Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Commands to install the python-verisure library using pip, either from PyPI or directly from the GitHub repository. ```shell pip install vsure pip install git+https://github.com/persandstrom/python-verisure.git@version-2 ``` -------------------------------- ### Verisure CLI Usage Examples Source: https://context7.com/persandstrom/python-verisure/llms.txt Provides examples of using the `vsure` command-line interface to interact with the Verisure system. Covers basic operations like reading alarm status, arming/disarming, controlling doors, managing smart plugs, and advanced options like MFA and debug logging. ```bash # Basic usage - read alarm status vsure user@example.com mypassword --arm-state # Read multiple statuses vsure user@example.com mypassword --arm-state --door-window --climate # Arm the alarm (away mode) vsure user@example.com mypassword --arm-away 1234 # Arm the alarm (home mode) vsure user@example.com mypassword --arm-home 1234 # Disarm the alarm vsure user@example.com mypassword --disarm 1234 # Lock/unlock door vsure user@example.com mypassword --door-lock "ABCD EFGH" 1234 vsure user@example.com mypassword --door-unlock "ABCD EFGH" 1234 # Smart plug control vsure user@example.com mypassword --set-smartplug "ABCD EFGH" true vsure user@example.com mypassword --set-smartplug "ABCD EFGH" false # Use MFA authentication vsure user@example.com mypassword --mfa --arm-state # Use custom cookie file vsure user@example.com mypassword -c /path/to/cookie --arm-state # Select specific installation (default is 0) vsure user@example.com mypassword -i 1 --arm-state # Enable debug logging vsure user@example.com mypassword --log-level DEBUG --arm-state # Get event log vsure user@example.com mypassword --event-log # Camera operations vsure user@example.com mypassword --cameras vsure user@example.com mypassword --cameras-last-image ``` -------------------------------- ### GET /door-window Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Reads the status of all door and window sensors in the installation. ```APIDOC ## GET --door-window ### Description Retrieves the open/closed status of all configured door and window sensors. ### Method CLI Flag: --door-window ### Parameters #### Required - **USERNAME** (string) - Verisure account email - **PASSWORD** (string) - Verisure account password ### Request Example vsure user@example.com mypassword --door-window ``` -------------------------------- ### POST /arm-state Source: https://context7.com/persandstrom/python-verisure/llms.txt Retrieves the current arming status of the selected installation. ```APIDOC ## POST /arm-state ### Description Queries the current status of the alarm system, including whether it is ARMED_AWAY, ARMED_HOME, or DISARMED. ### Method POST ### Endpoint /arm-state ### Response #### Success Response (200) - **statusType** (string) - Current state of the alarm - **date** (string) - Timestamp of the last state change - **name** (string) - User who performed the last change #### Response Example { "data": { "installation": { "armState": { "statusType": "DISARMED", "date": "2024-01-15T10:30:00.000Z", "name": "John Doe" } } } } ``` -------------------------------- ### Authenticate and Initialize Session Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Demonstrates how to initialize a Verisure session, handle login, and perform MFA validation to retrieve installation identifiers (giid). ```python import verisure USERNAME = "example@domain.org" PASSWORD = "MySuperSecretP@ssword" session = verisure.Session(USERNAME, PASSWORD) # Login without Multifactor Authentication installations = session.login() # Or with Multicator Authentication session.request_mfa() installations = session.validate_mfa(input("code:")) # Get the `giid` for your installation giids = { inst['alias']: inst['giid'] for inst in installations['data']['account']['installations'] } # Set the giid session.set_giid(giids["MY STREET"]) ``` -------------------------------- ### Query Climate Sensor Data with Python Source: https://context7.com/persandstrom/python-verisure/llms.txt This example demonstrates how to query temperature and humidity data from climate sensors. It retrieves readings and shows how to access individual temperature and humidity values for each sensor, grouped by area. The 'verisure' library is a prerequisite. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Get climate sensor readings climate_data = session.request(session.climate()) print(json.dumps(climate_data, indent=2)) # Access temperature and humidity values for sensor in climate_data['data']['installation']['climates']: area = sensor['device']['area'] temp = sensor['temperatureValue'] humidity = sensor.get('humidityValue') print(f"{area}: {temp}°C, Humidity: {humidity}%") ``` -------------------------------- ### GET /arm-state Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Retrieves the current arming status of the Verisure installation. ```APIDOC ## GET --arm-state ### Description Reads the current arm state of the alarm system (e.g., DISARMED, ARMED_HOME, ARMED_AWAY). ### Method CLI Flag: --arm-state ### Parameters #### Required - **USERNAME** (string) - Verisure account email - **PASSWORD** (string) - Verisure account password ### Request Example vsure user@example.com mypassword --arm-state ### Response #### Success Response (200) - **statusType** (string) - The current arming status - **date** (string) - Timestamp of the last status change #### Response Example { "data": { "installation": { "armState": { "statusType": "DISARMED", "date": "2020-03-11T21:04:40.000Z" } } } } ``` -------------------------------- ### Manage Smart Plugs with Python Source: https://context7.com/persandstrom/python-verisure/llms.txt This code snippet shows how to read the status of and control smart plugs connected to your Verisure system. It includes functions to get the status of all plugs or a specific one, and to turn them ON or OFF. The 'verisure' library is required. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) DEVICE_LABEL = "ABCD EFGH" # Get status of all smart plugs all_plugs = session.request(session.smartplugs()) print(json.dumps(all_plugs, indent=2)) # Get status of a specific smart plug single_plug = session.request(session.smartplug(DEVICE_LABEL)) print(json.dumps(single_plug, indent=2)) # Turn smart plug ON result = session.request(session.set_smartplug(DEVICE_LABEL, True)) print(f"Smart plug turned ON: {result}") # Turn smart plug OFF result = session.request(session.set_smartplug(DEVICE_LABEL, False)) print(f"Smart plug turned OFF: {result}") ``` -------------------------------- ### GET /system-status Source: https://context7.com/persandstrom/python-verisure/llms.txt Retrieves multiple system statuses including arm state, door/window sensors, climate, and smart plugs in a single request. ```APIDOC ## GET /system-status ### Description Executes multiple queries in a single API call for improved efficiency. ### Method GET ### Endpoint /installation/{giid}/status ### Parameters #### Path Parameters - **giid** (string) - Required - The Global Installation ID ### Response #### Success Response (200) - **armState** (object) - Current alarm status - **doorWindows** (array) - Status of door/window sensors - **climate** (object) - Temperature and humidity data - **smartplugs** (array) - Status of connected smart plugs ``` -------------------------------- ### Query Door and Window Sensor Status with Python Source: https://context7.com/persandstrom/python-verisure/llms.txt This snippet demonstrates how to query the status of all door and window sensors. It retrieves their current state (OPEN/CLOSE), location, and last report time using the Verisure Python library. Ensure you have the 'verisure' library installed. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Get door/window sensor status door_window_status = session.request(session.door_window()) print(json.dumps(door_window_status, indent=2)) ``` -------------------------------- ### GET /user-tracking Source: https://context7.com/persandstrom/python-verisure/llms.txt Queries the location tracking status for users associated with the Verisure installation. ```APIDOC ## GET /user-tracking ### Description Retrieves the current location and status of users tracked by the system. ### Method GET ### Endpoint /installation/{giid}/userTracking ### Response #### Success Response (200) - **userTrackings** (array) - List of users with their location and status #### Response Example { "data": { "installation": { "userTrackings": [{"name": "John", "currentLocationName": "Home", "status": "PRESENT"}] } } } ``` -------------------------------- ### GET /event-log Source: https://context7.com/persandstrom/python-verisure/llms.txt Retrieves the security event log containing arm/disarm actions, lock/unlock events, and sensor triggers. ```APIDOC ## GET /event-log ### Description Retrieves the historical event log for the selected installation. ### Method GET ### Endpoint /installation/{giid}/eventLog ### Parameters #### Path Parameters - **giid** (string) - Required - The Global Installation ID ### Response #### Success Response (200) - **pagedList** (array) - List of security events #### Response Example { "data": { "installation": { "eventLog": { "pagedList": [{"eventType": "ARM", "eventTime": "2023-10-01T10:00:00Z", "userName": "Admin"}] } } } } ``` -------------------------------- ### Perform Camera Operations with Python Source: https://context7.com/persandstrom/python-verisure/llms.txt This snippet covers various camera operations, including getting camera status, capturing new images, and retrieving image series history. It involves a two-step process for capturing images: obtaining a request ID and then polling for capture status. The 'verisure' library is required. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) CAMERA_LABEL = "ABCD EFGH" # Get all cameras status cameras = session.request(session.cameras()) print(json.dumps(cameras, indent=2)) # Get latest camera image last_image = session.request(session.cameras_last_image()) print(json.dumps(last_image, indent=2)) # Get image series history image_series = session.request(session.cameras_image_series(limit=10, offset=0)) print(json.dumps(image_series, indent=2)) # Capture a new image (two-step process) # Step 1: Get request ID request_result = session.request(session.camera_get_request_id(CAMERA_LABEL)) request_id = request_result['data']['ContentProviderCaptureImageRequest']['requestId'] # Step 2: Poll for capture status capture_status = session.request(session.camera_capture(CAMERA_LABEL, request_id)) print(json.dumps(capture_status, indent=2)) ``` -------------------------------- ### Query User Tracking Status Source: https://context7.com/persandstrom/python-verisure/llms.txt Fetches user location tracking status within the Verisure installation. It retrieves user information and iterates through it to display names, current locations, and status. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Get user tracking information user_trackings = session.request(session.user_trackings()) print(json.dumps(user_trackings, indent=2)) # Process user locations for user in user_trackings['data']['installation']['userTrackings']: name = user['name'] location = user.get('currentLocationName', 'Unknown') status = user['status'] print(f"{name}: {location} ({status})") ``` -------------------------------- ### Initialize Session and Authenticate Source: https://context7.com/persandstrom/python-verisure/llms.txt Demonstrates how to initialize a Verisure session and authenticate using standard credentials. ```python import verisure USERNAME = "user@example.com" PASSWORD = "MySuperSecretPassword" session = verisure.Session(USERNAME, PASSWORD, cookie_file_name='~/.verisure-cookie') try: installations = session.login() print("Login successful") except verisure.LoginError as e: print(f"Login failed: {e}") giids = { inst['alias']: inst['giid'] for inst in installations['data']['account']['installations'] } session.set_giid(giids["MY HOME"]) ``` -------------------------------- ### Query Alarm and Device Status Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Shows how to request the current arm state of the alarm system and retrieve statuses for door and window sensors. ```python # Read alarm status arm_state = session.request(session.arm_state()) # Read status from alarm and door-window output = session.request(session.arm_state(), session.door_window()) ``` -------------------------------- ### Execute Multiple Queries in Single Request Source: https://context7.com/persandstrom/python-verisure/llms.txt Demonstrates how to send multiple API requests in a single call for improved efficiency. It retrieves alarm status, door/window sensor data, climate information, and smart plug status. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Request multiple statuses at once results = session.request( session.arm_state(), session.door_window(), session.climate(), session.smartplugs() ) # Results is a list of responses in order arm_state_result = results[0] door_window_result = results[1] climate_result = results[2] smartplugs_result = results[3] print("Alarm Status:", arm_state_result['data']['installation']['armState']['statusType']) print("Number of sensors:", len(door_window_result['data']['installation']['doorWindows'])) ``` -------------------------------- ### Download Image to File Source: https://context7.com/persandstrom/python-verisure/llms.txt Downloads an image from a given URL to a local file. This is useful for capturing images from security cameras. ```python image_url = "https://example.com/image.jpg" # URL from camera response session.download_image(image_url, "camera_capture.jpg") ``` -------------------------------- ### Read alarm and door-window status via CLI Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Retrieves both the alarm arm state and the status of all door and window sensors simultaneously using the CLI. ```shell vsure user@example.com mypassword --arm-state --door-window ``` -------------------------------- ### Control Smart Lock with Python Source: https://context7.com/persandstrom/python-verisure/llms.txt This section covers controlling smart door locks, including locking, unlocking, retrieving configuration, and managing auto-lock functionality. It requires the device label and PIN code for the smart lock. The 'verisure' library is a dependency. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) DEVICE_LABEL = "ABCD EFGH" # Your lock's device label PIN_CODE = "1234" # Get smart lock status lock_status = session.request(session.smart_lock()) print(json.dumps(lock_status, indent=2)) # Lock the door result = session.request(session.door_lock(DEVICE_LABEL, PIN_CODE)) print(f"Lock result: {result}") # Unlock the door result = session.request(session.door_unlock(DEVICE_LABEL, PIN_CODE)) print(f"Unlock result: {result}") # Get lock configuration config = session.request(session.door_lock_configuration(DEVICE_LABEL)) print(json.dumps(config, indent=2)) # Enable/disable auto-lock result = session.request(session.set_autolock_enabled(DEVICE_LABEL, True)) print(f"Auto-lock enabled: {result}") ``` -------------------------------- ### Manage Cookie-Based Session Persistence Source: https://context7.com/persandstrom/python-verisure/llms.txt Demonstrates how to use cookies to maintain an active session and avoid frequent re-authentication. ```python import verisure session = verisure.Session("user@example.com", "password") try: installations = session.login_cookie() session.set_giid(installations['data']['account']['installations'][0]['giid']) except verisure.LoginError: installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) session.update_cookie() ``` -------------------------------- ### Perform Multi-Factor Authentication Login Source: https://context7.com/persandstrom/python-verisure/llms.txt Shows the workflow for authenticating accounts that have MFA enabled by requesting and validating a verification code. ```python import verisure session = verisure.Session("user@example.com", "password") session.request_mfa() verification_code = input("Enter verification code: ") installations = session.validate_mfa(verification_code) session.set_giid(installations['data']['account']['installations'][0]['giid']) ``` -------------------------------- ### Read alarm status via CLI Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Demonstrates how to retrieve the current arm state of the Verisure alarm system using the command line interface. The output is provided in JSON format. ```shell vsure user@example.com mypassword --arm-state ``` ```json { "data": { "installation": { "armState": { "type": null, "statusType": "DISARMED", "date": "2020-03-11T21:04:40.000Z", "name": "Alex Poe", "changedVia": "CODE", "__typename": "ArmState" }, "__typename": "Installation" } } } ``` -------------------------------- ### Query System Information Source: https://context7.com/persandstrom/python-verisure/llms.txt Retrieves various system information, including broadband connection status, firmware versions, remaining SMS balance, user permissions, and capability information. Each query is made individually. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Get broadband connection status broadband = session.request(session.broadband()) print(f"Broadband connected: {broadband['data']['installation']['broadband']['isBroadbandConnected']}") # Get firmware information firmware = session.request(session.firmware()) print(json.dumps(firmware, indent=2)) # Get remaining SMS balance sms = session.request(session.remaining_sms()) print(f"Remaining SMS: {sms['data']['installation']['remainingSms']}") # Get user permissions permissions = session.request(session.permissions()) print(json.dumps(permissions, indent=2)) # Get capability information capability = session.request(session.capability()) print(json.dumps(capability, indent=2)) ``` -------------------------------- ### Session Logout and Cleanup Source: https://context7.com/persandstrom/python-verisure/llms.txt This snippet demonstrates how to properly terminate a Verisure session by logging out and cleaning up stored cookies and trust tokens. It ensures a secure and clean exit from the system. ```python import verisure session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Perform operations... arm_state = session.request(session.arm_state()) # Logout and cleanup session.logout() # Removes cookie file and invalidates trust token ``` -------------------------------- ### Error Handling Patterns Source: https://context7.com/persandstrom/python-verisure/llms.txt Standard practices for handling authentication, response, and general library exceptions. ```APIDOC ## Error Handling ### Description Guidelines for managing exceptions during Verisure API interactions, including login failures and server-side errors. ### Exception Types - **verisure.LoginError** - Raised when credentials are invalid or MFA is required. - **verisure.ResponseError** - Raised when the API returns an error status code. - **verisure.Error** - Base class for general library exceptions. ### Implementation Example ```python try: session.login() except verisure.LoginError as e: # Handle auth failure except verisure.ResponseError as e: # Handle API error finally: session.logout() ``` ``` -------------------------------- ### Retrieve and Process Event Log Source: https://context7.com/persandstrom/python-verisure/llms.txt Fetches the event log, which includes security events like arm/disarm actions, lock/unlock events, and sensor triggers. The log is then printed and iterated to display event type and time. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) # Get event log events = session.request(session.event_log()) print(json.dumps(events, indent=2)) # Process events for event in events['data']['installation']['eventLog']['pagedList']: event_type = event['eventType'] event_time = event['eventTime'] user = event.get('userName', 'System') print(f"{event_time}: {event_type} by {user}") ``` -------------------------------- ### Error Handling in Verisure Operations Source: https://context7.com/persandstrom/python-verisure/llms.txt This code illustrates how to handle various exceptions that may occur during Verisure operations, including login failures, API response errors, and general Verisure-related exceptions. It ensures graceful failure and cleanup. ```python import verisure session = verisure.Session("user@example.com", "password") try: installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) result = session.request(session.arm_state()) print(result) except verisure.LoginError as e: print(f"Authentication failed: {e}") # Handle MFA requirement or invalid credentials except verisure.ResponseError as e: print(f"API response error: {e}") # Handle server-side errors except verisure.Error as e: print(f"General Verisure error: {e}") finally: try: session.logout() except: pass ``` -------------------------------- ### POST /door-lock Source: https://github.com/persandstrom/python-verisure/blob/version-2/README.md Locks a specific door using the provided device label and security code. ```APIDOC ## POST --door-lock ### Description Locks a specific door lock device. ### Method CLI Flag: --door-lock ### Parameters - **DEVICELABEL** (string) - The identifier for the lock device - **CODE** (string) - The security code required to lock the door ``` -------------------------------- ### POST /arm-disarm Source: https://context7.com/persandstrom/python-verisure/llms.txt Changes the alarm state to armed or disarmed using a PIN. ```APIDOC ## POST /arm-disarm ### Description Updates the alarm system state. Supported actions include arm_away, arm_home, and disarm. ### Method POST ### Endpoint /arm-disarm ### Request Body - **pin** (string) - Required - 4-6 digit PIN code for the alarm system ### Response #### Success Response (200) - **result** (object) - Confirmation of the state change request ``` -------------------------------- ### Query Alarm System State Source: https://context7.com/persandstrom/python-verisure/llms.txt Retrieves the current arming status of the alarm system, including details on the last state change. ```python import verisure import json session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) arm_state = session.request(session.arm_state()) print(json.dumps(arm_state, indent=2)) ``` -------------------------------- ### POST /session/logout Source: https://context7.com/persandstrom/python-verisure/llms.txt Terminates the active Verisure session and cleans up local authentication artifacts. ```APIDOC ## POST /session/logout ### Description Terminates the current session, invalidates the trust token, and removes stored cookie files. ### Method POST ### Endpoint /session/logout ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **status** (string) - Confirmation of successful logout. #### Response Example { "status": "success" } ``` -------------------------------- ### Control Alarm System Arming and Disarming Source: https://context7.com/persandstrom/python-verisure/llms.txt Uses the PIN code to change the alarm system state to arm away, arm home, or disarm. ```python import verisure session = verisure.Session("user@example.com", "password") installations = session.login() session.set_giid(installations['data']['account']['installations'][0]['giid']) PIN_CODE = "1234" result = session.request(session.arm_away(PIN_CODE)) result = session.request(session.arm_home(PIN_CODE)) result = session.request(session.disarm(PIN_CODE)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.