Python Forum
Need help with a script (indentation)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with a script (indentation)
#10
Seems to be happy with indents now. Thnx all for help :)
Its for sending a push notification through prowl api server when pin 15 and ground are connected on my RPi.

#!/bin/usr/bin/python

# Imports for Pyrowl
from pyrowl import Pyrowl
from pprint import pprint
import os

# Imports for GPIO
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)

# Setup pyrowl with API key
p = None
p = Pyrowl("4f9b21b6b3cdf3cf41xxxxxxxxxxxx")

# Setup GPIO pin as input
# Check that this is the same pin you have your switch input plugged into!
GPIO.setup(15, GPIO.IN)


# Set initial state
previousstate = GPIO.input(15)

# Main loop
while True:
    # Check that this is the same pin you have your switch input plugged into!
       mybutton = GPIO.input(15)
if mybutton != previousstate:
    if mybutton == True:
        print "Door opened"
        res = p.push("My Raspberry Pi", 'House Warning','Door opened', batch_mode=False)
    else:
        print "Door closed"
        res = p.push("My Raspberry Pi", 'House Warning','Door closed', batch_mode=False)

previousstate = mybutton
# Print result if you like
# pprint(res)
time.sleep(.2)
Nothing happens when i run python ./1.py
Its like its loading. But i guess i should ask on a raspberry forum for that matter :)
Reply


Messages In This Thread
RE: Need help with a script (indentation) - by Fresh_Coder - Oct-05-2018, 01:43 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020