A python module for reading and changing status of verisure devices through verisure app api.

persandstrom, updated 🕥 2023-03-19 14:48:15

python-verisure

A python3 module for reading and changing status of verisure devices through verisure app API.

Legal Disclaimer

This software is not affiliated with Verisure Holding AB and the developers take no legal responsibility for the functionality or security of your Verisure Alarms and devices.

Version History

txt 2.6.1 Move to automation subdomain 2.6.0 Add Get Firmware Version 2.5.6 Fix docstring, cookie lasts 15 minutes 2.5.5 Solved bug during response error except using CLI 2.5.4 Add possibility to set giid to all queries, refactoring and resolve lint warnings 2.5.3 Refactor login 2.5.2 Fix XBN Database is not activated 2.5.1 Update CLI, split cookie login to separate function, rename mfa functions 2.5.0 Add MFA login 2.4.1 Add download_image 2.4.0 Add camera support 2.3.0 Add event-log command 2.2.0 Add set-autolock-enabled command 2.1.2 Installation instructions for m-api branch 2.1.1 Cleaned up readme 2.1.0 Add door-lock-configuration command 2.0.0 Move to GraphQL API, major changes 1.0.0 Move to app-API, major changes

Installation

sh pip install vsure

or

sh pip install git+https://github.com/persandstrom/[email protected]

Usage

```py

example_usage.py

import verisure

USERNAME = "[email protected]" PASSWORD = "[email protected]"

session = verisure.Session(USERNAME, PASSWORD)

Login without Multifactor Authentication

installations = session.login()

Or with Multicator Authentication, check your phone and mailbox

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'] } print(giids)

{'MY STREET': '123456789000'}

Set the giid

session.set_giid(giids["MY STREET"]) ```

Read alarm status (py)

py arm_state = session.request(session.arm_state())

output

json { "data": { "installation": { "armState": { "type": null, "statusType": "DISARMED", "date": "2020-03-11T21:04:40.000Z", "name": "Alex Poe", "changedVia": "CODE", "__typename": "ArmState" }, "__typename": "Installation" } } }

Read status from alarm and door-window (py)

py output = session.request(session.arm_state(), session.door_window())

output

json [ { "data": { "installation": { "armState": { "type": null, "statusType": "DISARMED", "date": "2022-01-01T00:00:00.000Z", "name": "Alex Poe", "changedVia": "CODE", "__typename": "ArmState" }, "__typename": "Installation" } } }, { "data": { "installation": { "doorWindows": [ { "device": { "deviceLabel": "ABCD EFGH", "__typename": "Device" }, "type": null, "area": "Front Door", "state": "CLOSE", "wired": false, "reportTime": "2022-01-01T00:00:00.000Z", "__typename": "DoorWindow" }, { "device": { "deviceLabel": "IJKL MNOP", "__typename": "Device" }, "type": null, "area": "Back Door", "state": "CLOSE", "wired": false, "reportTime": "2022-01-01T00:00:00.000Z", "__typename": "DoorWindow" } ], "__typename": "Installation" } } } ]

Command line usage

```txt Usage: python -m verisure [OPTIONS] USERNAME PASSWORD

Read and change status of verisure devices through verisure app API

Options: -i, --installation INTEGER Installation number -c, --cookie TEXT File to store cookie in --mfa Login using MFA --arm-away CODE Set arm status away --arm-home CODE Set arm state home --arm-state Read arm state --broadband Get broadband status --camera-capture ... Capture a new image from a camera --camera-get-request-id DEVICELABEL Get requestId for camera_capture --cameras Get cameras state --cameras-image-series Get the cameras image series --cameras-last-image Get cameras last image --capability Get capability --charge-sms Charge SMS --climate Get climate --disarm CODE Disarm alarm --door-lock ... Lock door --door-lock-configuration DEVICELABEL Get door lock configuration --door-unlock ... Unlock door --door-window Read status of door and window sensors --event-log Read event log --fetch-all-installations Fetch installations --firmware Get firmware information --guardian-sos Guardian SOS --is-guardian-activated Is guardian activated --permissions Permissions --poll-arm-state ... Poll arm state --poll-lock-state ... Poll lock state --remaining-sms Get remaing number of SMS --set-autolock-enabled ... Enable or disable autolock --set-smartplug ... Set state of smart plug --smart-button Get smart button state --smart-lock Get smart lock state --smartplug DEVICELABEL Read status of a single smart plug --smartplugs Read status of all smart plugs --user-trackings Read user tracking status --help Show this message and exit. ```

Read alarm status (cli)

sh vsure [email protected] mypassword --arm-state

The output is the same as above Read alarm status (py)

json { "data": { "installation": { "armState": { "type": null, "statusType": "DISARMED", "date": "2020-03-11T21:04:40.000Z", "name": "Alex Poe", "changedVia": "CODE", "__typename": "ArmState" }, "__typename": "Installation" } } }

Read status from alarm and door-window (cli)

sh vsure [email protected] mypassword --arm-state --door-window

Issues

Query type

opened on 2023-03-19 14:36:31 by persandstrom

Use typed return values for query functions

"Device not claimed" when doing camera-get-request-id

opened on 2022-11-09 13:20:56 by joszz

When I try to do an image capture from a camera, I first need to have a request id. When I try vsure [username] [password] --camera-get-request-id "[device_label]" ([device_label] I acquired through --cameras. It needs quotes I believe since there's a space in the label. Tried without quotes, and single quotes to no avail)

I get the following output; { "errors": [ { "message": "Request Failed", "locations": [ { "line": 2, "column": 3 } ], "path": [ "ContentProviderCaptureImageRequest" ], "data": { "status": 400, "logTraceId": "<retracted>", "errorCode": "CCCP_DEVICE_NOT_CLAIMED", "errorMessage": "Device not claimed" } } ], "data": { "ContentProviderCaptureImageRequest": null } }

what am I missing here or doing wrong? The capture is always allowed on any arm state. The output of cameras is; { "data": { "installation": { "cameras": [ { "visibleOnCard": true, "initiallyConfigured": true, "imageCaptureAllowed": "ALWAYS", "imageCaptureAllowedByArmstate": null, "device": { "deviceLabel": "<retracted>", "area": "<retracted>", "__typename": "Device" }, "latestCameraSeries": null }, { "visibleOnCard": true, "initiallyConfigured": true, "imageCaptureAllowed": "ALWAYS", "imageCaptureAllowedByArmstate": null, "device": { "deviceLabel": "<retracted>, "area": "<retracted>", "__typename": "Device" }, "latestCameraSeries": null } ] } } }

Read autolock status

opened on 2022-05-21 09:45:35 by jacobhallgren

Would be nice like in the verisure app to see the state of the lock. If autolock is enabled or not.

Verisure 2 step verification auth

opened on 2021-03-11 10:55:07 by thomasgermain

Hello,

I just received a email from verisure (from Belgium) about 2 step verification:

It sounds you can disable it, but I think it should be handled.

``` Information to users with a third-party integration to Verisure Our system indicates that you are using a third-party integration to connect to Verisure functionality. If this is not the case, you can ignore this email. Otherwise, please continue reading.

Third-party integrations are not an officially sanctioned way to connect to Verisure. However, we hope that you are happy with the functionality provided through MyPages and Verisure app and will continue to use it. This email contains instructions for how to use third-party integrations together with 2-step verification.

Our goal is to keep our customers safe and secure. This includes maintaining a high security level for your Verisure account and reduce the risk of unauthorized access. In the next couple of weeks, we will therefor introduce 2-step verification for all logins to MyPages and the Verisure app.

Once 2-step verification is enabled for your account, you will need a one-time code in addition to your username and password.

Preparation for 2-step verification Please complete the following steps to prepare for 2-step verification. Go to Account in MyPages to check that your registered phone number is correct. Make sure that all users with access to your Verisure system have their own Verisure account. If there are users who share accounts, please ask the system owner or administrators to create individual accounts for them. This is done under Users in My Pages.

It is very important to have individual accounts with the correct phone number for each user. It ensures that the verification code is sent to the correct user and device at login.

If your alarm system is connected to the Verisure Monitoring Center, it also makes sure that the Verisure first responders can reach you in case of an emergency. This is especially important if you use mobile SOS services such as Verisure Guardian.

How does 2-step verification affect third-party integrations with Verisure? When 2-step verification is enabled, your connection through the third-party integration might stop working. Please note that if you disable 2-step verification, the risk of unauthorized access to your account is increased.

Follow these steps to restore the connection: Log in to MyPages with your username and password. Enter the verification code when you receive it. Go to Account and Subscription > Account > Login credentials > Disable 2-step verification Follow the instructions to disable 2-step verification. In order for us to get valuable input for potential future improvements for users that have a 3rd party integration to Verisure, we have created a short survey as part of the Disable 2-step verification steps. Best regards Verisure ```

UserTracking tab missing?

opened on 2020-10-08 23:24:20 by Soleg06

Up until recentely when I called the get_overview() command I got a "userTracing" tab in the json reply but now its missing. Anybody knows if Verisure hidden it or if the information is avalible somewhere else?

Power loss event?

opened on 2020-07-27 18:40:11 by JohNan

Hi,

In the app I get notified when there's a power outage and it is also visible in the history tab in the app. Is it possible to have a binary sensor that flips to true if there's a power outage?

Per Sandström
GitHub Repository