'# 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["****"])
while True:
try:
arm_state = session.request(session.arm_state())
print(arm_state)
time.sleep(report_intervall)
except Exception as e:
print(e)
Used the example_usage.py and added a while loop that polls arm_status every 5 minutes. It loops for about 3 iterations and returns an exception:
Invalid response, status code: 401 - Data: 401 Unauthorized
Code:
'# example_usage.py
import verisure import time
USERNAME = *** PASSWORD = **** report_intervall = 300
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["****"])
while True: try: arm_state = session.request(session.arm_state()) print(arm_state) time.sleep(report_intervall) except Exception as e: print(e)
Response:
code:** '** {'Road': 'giids no.'} {'data': {'installation': {'armState': {'type': None, 'statusType': 'DISARMED', 'date': '2023-04-13T05:04:58.000Z', 'name': ' *', 'changedVia': 'CODE', 'typename': 'ArmState'}, 'typename': 'Installation'}}} {'data': {'installation': {'armState': {'type': None, 'statusType': 'DISARMED', 'date': '2023-04-13T05:04:58.000Z', 'name': ' *', 'changedVia': 'CODE', 'typename': 'ArmState'}, 'typename': 'Installation'}}} {'data': {'installation': {'armState': {'type': None, 'statusType': 'DISARMED', 'date': '2023-04-13T05:04:58.000Z', 'name': '** *****', 'changedVia': 'CODE', 'typename': 'ArmState'}, 'typename': 'Installation'}}} Invalid response, status code: 401 - Data: 401 Unauthorized