Example #1
0
def checkTemp():
    print("Check temp   peč:" + str(getT1()) + "   zalogovnik: " +
          str(getT2()))
    try:

        if (getT1() > getT2()):
            print("T1 > T2")
            return True
        else:
            print("T1 < T2")
            return False
    except:
        print("exception checkTemp()")
        return False
Example #2
0
def info():
    logging.info('info ')
    t1 = Temp('Peč', getT1(), '28-03189779c4c9', datetime.datetime.now())
    t2 = Temp('Zalogovnik', getT2(), '28-03189779c4c9',
              datetime.datetime.now())
    relay = Relay('Rele za pumpo', getStatus(), '001', datetime.datetime.now())
    #jsonSez = parseSez(sez)
    return jsonify({'t1': t1.toJson, 't2': t2.toJson, 'relay': relay.toJson})
Example #3
0
def nadziraj():
    if (checkTemp() and not getStatus()):
        try:
            on()
            print("VKLOP")
            db.saveRelayStatus("PEČ", "ON", getT1(), getT2())
        except:
            raise Exception("Napaka v nadziraj -> relay.on()")
    elif (not checkTemp() and getStatus()):
        try:
            off()
            print("IZKLOP")
            db.saveRelayStatus("PEČ", "OFF", getT1(), getT2())
        except:
            raise Exception("Napa ka v nadziraj -> relay.off()")
    else:
        print("Ni sprememb!")
Example #4
0
def nadziraj():
    if (checkTemp() and not checkStatus()):
        try:
            response = requests.get(urlOn)
            logging.info("VKLOP")
            db.saveRelayStatus("PEČ", "ON", getT1(), getT2())
        except:
            raise Exception("Napaka v nadziraj -> relay.on()")
    elif (not checkTemp() and checkStatus()):
        try:
            response = requests.get(urlOff)
            logging.info("IZKLOP")
            db.saveRelayStatus("PEČ", "OFF", getT1(), getT2())
        except:
            raise Exception("Napa ka v nadziraj -> relay.off()")
    else:
        logging.info("Ni sprememb!")
Example #5
0
def getData2():
    content = request.json
    t2 = Temp('Zalogovnik', getT2(), '28-03189779c4c9',
              datetime.datetime.now())
    logging.info('t2' + str(t2))

    return jsonify({
        'name': t2.name,
        'vrednost': t2.val,
        'serial num': t2.sn,
        'cas': t2.date
    })