1

So on my Raspberry Pi with Motioneye (not OS) installed and I'm trying to get the Pushover Notification to work. The problem is on Raspbian I'm not sure where to put the python script. I've put it in /usr/local/bin, /usr/bin but no matter where I place the script it never activates.

the pushover.py looks like this:

#!/usr/bin/python

#################################################################################
# Created by Wesley Archer (aka. Raspberry Coulis) to enable push notifications #
# via Pushover.net in MotionEyeOS. See Pushover's API FAQ for more detailed use #
# Also featured on Pi-Supply.com's Maker Zone.                                  #
#                                                                               #
# Follow me:    @RaspberryCoulis                                                #
# Visit me:     raspberrycoulis.co.uk                                           #
# Email me:     [email protected]                                    #
# Like me:  facebook.com/raspberrycoulis                                    #
#################################################################################

import httplib, urllib

conn = httplib.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
  urllib.urlencode({
    "token": "my api token"   # Insert app token here
    "user": "My user token",       # Insert user token here
    "html": "1",                                # 1 for HTML, 0 to disable
    "title": "Motion Detected!",                # Title of the message
    "message": "<b>Front Door</b> camera!",     # Content of the message
    "url": "http://IP.ADD.RE.SS",               # Link to be included in message
    "url_title": "View live stream",            # Text for the link
    "sound": "siren",                           # Define the sound played
  }), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()

When I try to execute the python script I get:

  File "./pushover.py", line 20
    "user": "My token",       # Insert user token here
          ^
SyntaxError: invalid syntax
8
  • 1
    Hello and welcome -- Simply insert user token there. Do you how can you get it? Commented Mar 9, 2020 at 1:56
  • 1
    I did, when I copy and pasted it to the question I made sure to replace the token with just api token or user token. I signed into PUshover and grab the tokens from there Commented Mar 9, 2020 at 2:08
  • 2
    I think you must add , at the end of line 19. Like "token": "my api token",. Commented Mar 9, 2020 at 5:14
  • i agree with @M.Rostami, the coding error is on the previous line
    – jsotola
    Commented Mar 9, 2020 at 6:09
  • 1
    @M.Rostami, i also do that in if statements with complex boolean expessions ... i put each ecpression on a separate line and place the && and || at the begining of lines
    – jsotola
    Commented Mar 9, 2020 at 6:24

1 Answer 1

2

You must add , at the end of line 19. Like "token": "my api token",. So your pushover.py gonna be like it:

#!/usr/bin/python

import httplib, urllib

conn = httplib.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
  urllib.urlencode({
    "token": "my api token",
    "user": "My user token",
    "html": "1",
    "title": "Motion Detected!",
    "message": "<b>Front Door</b> camera!",
    "url": "http://IP.ADD.RE.SS",
    "url_title": "View live stream",
    "sound": "siren",
  }), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.