Include suppressed alerts in API event hook

60 views
Skip to first unread message

Fred Taylor-Young

unread,
Apr 3, 2020, 12:33:01 PM4/3/20
to Camect User Forum
I've written an event listener to parse alerts and store them in InfluxDB (thanks for the sample code in GitHub :-).
It would be great if events could be sent for all alerts, not just ones I've configured it to send Telegram/email messages for.
A property could be added to each event to denote that it's a suppressed alert, or they could be sent with a different type field altogether.

Currently we get something like:
{'type': 'alert', 'desc': 'Camera Front Door just saw a person.', 'url': 'https://home.camect.com/home/40-character-home-id-here/camera?id=20-char-cam-id1&ts=1585840980826'}

Suppressed alerts could look like this:
{'type': 'alert', 'desc': 'Camera Front Door just saw a person.', 'url': 'https://home.camect.com/home/40-character-home-id-here/camera?id=20-char-cam-id1&ts=1585840980826', 'suppressed': True}

Or like this:
{'type': 'suppressedalert', 'desc': 'Camera Front Door just saw a person.', 'url': 'https://home.camect.com/home/40-character-home-id-here/camera?id=20-char-cam-id1&ts=1585840980826'}

Thanks!

Cheers,
Fred

Arno Hautala

unread,
Apr 4, 2020, 9:50:02 PM4/4/20
to Camect User Forum
seconded

Brian Wilson

unread,
May 31, 2020, 9:17:23 PM5/31/20
to Camect User Forum
Fred, would you mind sharing your code? I'm trying to extend this to support other smart home platforms. I see the example on github about adding an event_listener, but I'm unsure how to have python wait for further events before exiting. Thanks! 

Arno Hautala

unread,
Jun 2, 2020, 9:28:17 AM6/2/20
to Camect User Forum
There may be a better way to do this, but a simple solution is just to sleep in a loop.

import camect
home = camect.Home(host, user, password)
home
.add_event_listener(lambda event: print(event))
while True:
    time
.sleep(5)
Reply all
Reply to author
Forward
0 new messages