Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session.get_history: params notificationCategories vs eventCategories #112

Closed
thomasgermain opened this issue May 31, 2019 · 1 comment
Closed

Comments

@thomasgermain
Copy link
Contributor

Hi,

I was looking for a way to figure out if my alarm is ringing or not (for home automation goals).

I realized that session.get_arm_state only returns armed or disarmed, which sounds logic after all.

So I started looking at session.get_history and through mypages.verisure.com GUI. You're code allows me to pass filters so I decided to to something like this:

session.get_history(('INTRUSION', 'FIRE', 'WATER', 'SOS'), 1, 0)

This basically means give me the most recent history for intrusion, fire, water, or sos. It's actually not working, i'm receiving the last history like there is no filter. So i dig a little bit and I found that get_history is using a notificationCategories param to do the filtering. But the GUI is using eventCategories.

So I did this: (ok, ok, code is not clean, but it's just to give you an overview). So I just replaced notificationCategories param by eventCategories. And this is actually working.

import json

import requests
import verisure


session = verisure.Session('user', 'pass')
session.login()


def get_eventlog(filters=(), pagesize=15, offset=0):
    response = requests.get(
        verisure.session.urls.history(session._giid),
        headers={
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Cookie': 'vid={}'.format(session._vid)},
        params={
            "offset": int(offset),
            "pagesize": int(pagesize),
            "eventCategories": filters})
    return json.loads(response.text)


result = session.get_history(('INTRUSION', 'FIRE', 'WATER', 'SOS'), 1, 0)
print(result)
print('-----')
result = get_eventlog(('INTRUSION', 'FIRE', 'WATER', 'SOS'), 1, 0)
print(result)
print('-----')

OUTPUT:

{'moreDataAvailable': True, 'eventLogItems': [{'deviceArea': 'Xxx', 'gatewayArea': 'Xxx', 'deviceType': 'KEYPAD', 'eventType': 'OP', 'eventCategory': 'DISARM', 'eventId': '3270076853212086273', 'eventSource': 'GATEWAY', 'eventTime': '2019-05-31T09:15:53.000Z', 'userName': 'Xxx', 'armState': 'DISARMED', 'userType': 'CUSTOMER', 'deviceLabel': 'XXXXXXXX}]}
-----
{'moreDataAvailable': True, 'eventLogItems': [{'deviceArea': 'Xxxx', 'gatewayArea': 'Xxxx', 'deviceType': 'SIREN', 'eventType': 'FR', 'eventCategory': 'FIRE', 'eventId': '3259209336117723141', 'eventSource': 'GATEWAY', 'eventTime': '2019-04-01T09:48:38.000Z', 'armState': 'DISARMED', 'deviceLabel': 'XXXXXXXX'}]}
-----

Moreover, if you're just asking for 'ARM' filter (for instance), it won't work neither.

So I really think the param should be replace ( I could do the PR), but I preferred created the issue to have your point of view.

Regards,

Thomas

@persandstrom
Copy link
Owner

Hi Thomas,

Good catch, please do a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants