Exemplo n.º 1
0
def radio_test_ook():
    """Repeatedly test switch 1 ON then OFF"""

    radio.init()
    # init() defaults to standby()
    try:
        radio.modulation(ook=True)
        while True:
            print("Switch 1 ON")
            radio.transmit(enc_1on, TIMES)
            # auto returns to standby
            if DELAY != 0: time.sleep(DELAY)

            print("Switch 1 OFF")
            radio.transmit(enc_1off, TIMES)
            # auto returns to standby
            if DELAY != 0: time.sleep(DELAY)

    finally:
        radio.finished()
Exemplo n.º 2
0
def radio_test_ook():
    """Repeatedly test switch 1 ON then OFF"""

    radio.init()
    # init() defaults to standby()
    try:
        radio.modulation(ook=True)
        while True:
            print("Switch 1 ON")
            radio.transmit(enc_1on, TIMES)
            # auto returns to standby
            if DELAY!=0: time.sleep(DELAY)

            print("Switch 1 OFF")
            radio.transmit(enc_1off, TIMES)
            # auto returns to standby
            if DELAY!=0: time.sleep(DELAY)

    finally:
        radio.finished()
Exemplo n.º 3
0
def finished():
    """Cleanly close the Energenie system when finished"""
    radio.finished()
Exemplo n.º 4
0
def finished():
    """Cleanly close the Energenie system when finished"""
    radio.finished()
Exemplo n.º 5
0
            print "{}: Unexpected error 2 (connecting to DB): {}".format(
                datetime.now(), e)
            return

        try:
            sqlCursor.execute(
                "INSERT INTO server_power (powerTime, powerDate, powerValue, voltageValue, frequencyValue) VALUES(%s,%s,%s,%s,%s)",
                (strftime("%Y-%m-%d %H:%M:%S"), date.today(), power, voltage,
                 frequency))
            sqlConn.commit()
        except Exception, e:
            print "{}: Unexpected error 1 (Inserting into DB): {}".format(
                datetime.now(), e)
        sqlConn.close()
        return True

    # time.sleep(APP_DELAY)
    return False


if __name__ == "__main__":

    radio.init()
    OpenThings.init(Devices.CRYPT_PID)

    try:
        while energy_monitor_loop() is False:
            energy_monitor_loop()
    finally:
        radio.finished()