コード例 #1
0
#!/usr/bin/env python

import constants

from classes import myezcontrol
import MySQLdb as mdb
from alarmevents import alarm_event


ezcontrol = myezcontrol(constants.xs1_.IP,constants.xs1_.USER,constants.xs1_.PASS)
threshold = 250
threshold_balk = 100
threshold_TVcont = 50
aes = alarm_event()
#add evalatuion when the last start was.

def main():
    print check_TuerSpy_health(30)

def check_sensor_health():
    #if (ezcontrol.GetBattery("Haustuer") <> "ok"):
    #    aes.new_event(description="Leere Battery in Haustuer", prio=1.3, karenz=24*60)
    #if (ezcontrol.GetBattery("Balkontuer") <> "ok"):
    #    aes.new_event(description="Leere Battery in Balkontuer", prio=1.3, karenz=24*60)        
    con = mdb.connect(constants.sql_.IP, constants.sql_.USER, constants.sql_.PASS, constants.sql_.DB)
    with con:
        cur = con.cursor()
        sql = 'SELECT * FROM `XS1DB`.`Wohnzimmer_T` WHERE Date > DATE_ADD(NOW(), INTERVAL -4 HOUR)'
        cur.execute(sql)
        results = cur.fetchall()
        if len(results) < threshold:
コード例 #2
0
ファイル: inp_xs1.py プロジェクト: chrihuc/steuerzentrale
from threading import Timer
import threading
import time
import sys
from time import localtime,strftime
from socket import socket, AF_INET, SOCK_DGRAM
from cmd_szenen import szenen
from alarmevents import alarm_event
from cmd_xs1 import myezcontrol

selfsupervision = True

aes = alarm_event()
conn = pycurl.Curl()
last_data = ""
ezcontrol = myezcontrol(constants.xs1_.IP) 
scenes = szenen()

def last_data_reset():
    last_data = ""
            
def on_receive(data):
    if not constants.run:
        sys.exit("Error message")
    global heartbeat
    global last_data
    global ldt
    if False:
        ldt.cancel()
        ldt = Timer(1, last_data_reset)
        ldt.start()