Author Topic: Gmail notifier - Using IP camera email notifications to trigger events in VC  (Read 27890 times)

0 Members and 8 Guests are viewing this topic.

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
thank you, it works perfectly now.  what an awesome code and guy.

just wondering, whenever i open the VC and if theres unread ("motion detected") email, it will treat as new mail and trigger the command and speak the message. is it possible not to do that?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Yes, that would be better. I'll look into it tomorrow and post an update.
« Last Edit: January 08, 2015, 09:18:36 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
just wondering, whenever i open the VC and if theres unread ("motion detected") email, it will treat as new mail and trigger the command and speak the message. is it possible not to do that?

I have now updated the python script in the first post to handle this. http://voxcommando.com/forum/index.php?topic=1679.msg14606#msg14606

James also (rightly) chastised me for not having proper exception handling/logging in the code, so I've added that.  :bonk

If anyone else has problems getting the gmail_notifier.py to work in the future, the VC log should help us to figure out what's happening.
« Last Edit: January 08, 2015, 09:19:31 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
thanks again!

I could confirm it works very nicely.

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
just curious, can you match with summary instead of subject of the email?

this is the original match subject,

Code: [Select]
                if subject.lower() == "security event: closing by user code 2".lower():
                    vc.triggerEvent("Security.Away",None)


if this is the body of the mail,

Quote
Security Event: Opening By User Code 2

Location: My House

Time: 2015-01-20 22:09:22

Partition:1

but i just want to match,

Quote
Security Event: Opening By User Code 2

Location: My House


is it possible and hard to do?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Yes it is possible.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
The gmail notifier script is extremely adaptable, which is one of the reasons I posted it. There's a lot that VC users can do with it.

I can't speak to the difficulty level, as that kind of determination is relative/subjective. I  guess you can give us your judgement on that once you've given it a whirl.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
yes, i got it.  thank you!

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
nime5ter,

I noticed that if i change the check interval to 2 sec or lower, after awhile python will stop working and the log will say "IndexError: Index was outside the bounds of the array."

is this normal?


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Does it continue to work afterwards?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Try the updated version in the first post.

Keep in mind that you're basically checking your gmail something like 40,000 times a day (at least).

Hopefully now the code will handle that more elegantly.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Soda97

  • Contributor
  • ***
  • Posts: 69
  • Karma: 1
    • View Profile
it stopped working before but now working fine with the updated version.

thank you!

[edit]
i guess the lowest you can go is 2 sec.  I tried 1 sec and after awhile, it gave me this (HTTPError: HTTP Error 401: basic auth failed.).   Maybe 'coz checking too much or too quick.
« Last Edit: January 23, 2015, 04:11:27 PM by Soda97 »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Technically, that should not stop the notifier code from continuing to run. The script will try again a second later (or whatever you set it to). But that doesn't mean the other end will be happy about it. Gmail may very well not like you hitting it every second.

Certainly any smaller company/server would be pretty pissed off with that rate of targeted non-stop requests. I didn't really expect anyone to try to use the code that way.
« Last Edit: January 23, 2015, 04:42:19 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Mirac78

  • Jr. Member
  • **
  • Posts: 49
  • Karma: 5
    • View Profile
    • M.S.Photography
Hi nime5ter,

i can't setup this script. Do everything, and i getting: [plugin] HTTPError: HTTP Error 401: Unauthorized in my log.

I'm shure that i provide ok user and pass, double checked.

Any advice?

TNX

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Yup, looks like gmail doesn't like this script. I'll review it to see if I made some mistakes while trying to meet the last user's "special needs", but it's possible things have changed on Google's end.

... I did see that I'd accidentally uploaded a version that checks gmail every second (which is BAD), but even when I try to check my mail once I'm getting an authorization error.

I'll look into it and get back to you.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)