.fetchone()[0],
			at=now)
		]
	try:
		feed.update()  # and update Xively with the latest
		# update the time in the database
		c.execute("update xively set utime=?;",(dbTime(),))
		dbconn.commit()
		dbconn.close() # close the data base
	except:
		lprint ("error: " + str(sys.exc_info()[0]))

lprint ("started")
# get the values I need from the rc file
# The Xively feed id and API key that is needed
hv = getHouseValues()
FEED_ID = hv["xively"]["feed"]
API_KEY = hv["xively"]["key"]
# the database where I'm storing stuff
DATABASE= hv["database"]

logging.basicConfig()

#------------------Stuff I schedule to happen -----
scheditem = BackgroundScheduler()
scheditem.start()
# every minute update the data store on Xively
# may have to use max_instances to allow for web problems
scheditem.add_job(updateXively, 'interval', seconds=60, max_instances=2)
#--------------------Xively interface----------------
# Initialize Xively api client
Exemple #2
0
    elif msg.topic == 'Desert-Home/Device/GarageFreezer':
        logIt("got garage freezer monitor")
        handleGarageFreezer(msg.payload)
    elif msg.topic == 'Desert-Home/Device/PowerMon':
        logIt("got power monitor")
        handlePowerMon(msg.payload)
    else:
        lprint("got odd topic back: {}".format(msg.topic))
        logIt("got odd topic back: {}".format(msg.topic))
    # update the timer for saving things.
    checkTimer.tick()


#-----------------------------------------------------------------
# get the stuff from the houserc file
hv = getHouseValues()
# the database where I'm storing house stuff
hdbName = hv["houseDatabase"]
hdbHost = hv["houseHost"]
hdbPassword = hv["housePassword"]
hdbUser = hv["houseUser"]
# the iris switch controller
irisControl = hv["iriscontrol"]["ipAddress"] + ":" + \
                    str(hv["iriscontrol"]["port"])
lprint("Iris Control is:", irisControl)
# the wemo switch controller
wemoControl = hv["wemocontrol"]["ipAddress"] + ":" + \
                    str(hv["wemocontrol"]["port"])
lprint("Wemo Control is:", wemoControl)

checkTimer = timer(None)
        help='show xml')
    parser.add_argument('count',type=int);
    args = parser.parse_args()
    if args.debug:
        print "Running with debug on"
        debug = True
    if args.xml:
        print "Running with showXML on"
        showXml = True
    targetNumber = args.count

    stars = "*********************************************"

    #-------------------------------------------------
    # the database where I'm storing stuff
    hv=getHouseValues()
    dbName = hv["houseDatabase"]
    dbHost = hv["houseHost"]
    dbPassword = hv["housePassword"]
    dbUser = hv["houseUser"]

    lprint("Using database ", dbName);
    
    # Get the ip address and port number you want to use
    # from the houserc file
    ipAddress=hv["wemocontrol"]["ipAddress"]
    port = hv["wemocontrol"]["port"]
    lprint("started looking for {} switches".format(targetNumber))

    # This works on my machine, but you may have to mess with it
    # The arp-scan below tells it not to look up the manufacturer because I
    @cherrypy.expose
    def index(self):
        return "Hello world!"
    
# This is the callback for my simple timer class
def ticker():
    lprint ("tick")
    
if __name__ == '__main__':
    # This timer will handle something on a periodic basis
    # Things like polling lights to see what they're doing right now
    jobTimer = timer(ticker, seconds=2)

    # Get the ip address and port number you want to use
    # from the houserc file
    ipAddress=getHouseValues()["wemocontrol"]["ipAddress"]
    port = getHouseValues()["wemocontrol"]["port"]
    # Now configure the cherrypy server using the values
    cherrypy.config.update({'server.socket_host' : ipAddress,
                            'server.socket_port': port,
                            'engine.autoreload_on': False,
                            })
    # Subscribe to the 'main' channel in cherrypy with my timer
    # tuck so the timers I use get updated
    cherrypy.engine.subscribe("main", checkTimer.tick)
    # Now just hang on the HTTP server looking for something to 
    # come in.  The cherrypy dispatcher will update the things that
    # are subscribed which will update the timers so the light
    # status gets recorded.
    cherrypy.quickstart(WemoSC())
        help='show xml')
    parser.add_argument('count',type=int);
    args = parser.parse_args()
    if args.debug:
        print "Running with debug on"
        debug = True
    if args.xml:
        print "Running with showXML on"
        showXml = True
    targetNumber = args.count

    stars = "*********************************************"

    #-------------------------------------------------
    # the database where I'm storing stuff
    hv=getHouseValues()
    dbName = hv["houseDatabase"]
    dbHost = hv["houseHost"]
    dbPassword = hv["housePassword"]
    dbUser = hv["houseUser"]

    lprint("Using database ", dbName);
    
    # Get the ip address and port number you want to use
    # from the houserc file
    ipAddress=hv["wemocontrol"]["ipAddress"]
    port = hv["wemocontrol"]["port"]
    lprint("started looking for {} switches".format(targetNumber))

    # This works on my machine, but you may have to mess with it
    # The arp-scan below tells it not to look up the manufacturer because I
Exemple #6
0
    "maxTempToday" : "default",
    "minTempToday" : "default"
    }

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-d", "--debug",
        action = "store_true",
        help='debug flag')
    args = parser.parse_args()
    if args.debug:
        print "Running with debug on"
        debug = True
  
    # the database where I'm storing stuff
    hv = getHouseValues()
    dbName = hv["weatherDatabase"]
    dbHost = hv["weatherHost"]
    dbPassword = hv["weatherPassword"]
    dbUser = hv["weatherUser"]
   # Get the ip address and port number you want to use
    # from the houserc file
    ipAddress=getHouseValues()["giveweather"]["ipAddress"]
    port = getHouseValues()["giveweather"]["port"]
    # periodically put a message into the log to indicate that
    # this is still alive
    keepAliveTimer = timer(keepAlive, minutes=4)
  
    cherrypy.config.update({'server.socket_host' : ipAddress.encode('ascii','ignore'),
                            'server.socket_port': port,
                            'engine.autoreload.on': False,
Exemple #7
0
        return "Hello world!"


# This is the callback for my simple timer class
def ticker():
    lprint("tick")


if __name__ == '__main__':
    # This timer will handle something on a periodic basis
    # Things like polling lights to see what they're doing right now
    jobTimer = timer(ticker, seconds=2)

    # Get the ip address and port number you want to use
    # from the houserc file
    ipAddress = getHouseValues()["wemocontrol"]["ipAddress"]
    port = getHouseValues()["wemocontrol"]["port"]
    # Now configure the cherrypy server using the values
    cherrypy.config.update({
        'server.socket_host': ipAddress,
        'server.socket_port': port,
        'engine.autoreload_on': False,
    })
    # Subscribe to the 'main' channel in cherrypy with my timer
    # tuck so the timers I use get updated
    cherrypy.engine.subscribe("main", checkTimer.tick)
    # Now just hang on the HTTP server looking for something to
    # come in.  The cherrypy dispatcher will update the things that
    # are subscribed which will update the timers so the light
    # status gets recorded.
    cherrypy.quickstart(WemoSC())