예제 #1
0
import sys
# CM19a module from https://github.com/Cuddon/cm19a
import CM19aDriver

# *************** CONFIGURATION ***************
POLLFREQ = 1  # Polling Frequency - Check for inbound commands every 1 second
# pinging Google's anycast DNS server
HOST = '8.8.8.8'
# FAILURE needs to be determined by what the system ping returns
FAILURE = '0 received'
# prior failure test
#if 'request timed out' in data or 'Unreachable' or "100% packet loss" in data:

# Start logging and initialize driver
log = CM19aDriver.startLogging()  # log is an instance of the logger class
cm19a = CM19aDriver.CM19aDevice(POLLFREQ, log, polling=True)


def test():
    if (os.path.exists('/tmp/teston')):
        if cm19a.initialised:
            print "Turning on test..."
            print time.ctime()
            result = cm19a.send("C", "1", "on")
            if result:
                print "...Success"
            else:
                print >> sys.stderr, "Command failed"
        os.remove('/tmp/teston')
    if (os.path.exists('/tmp/testoff')):
        if cm19a.initialised:
예제 #2
0
# *************** CODE ***************
VERSION = "3.00 (Beta)"

# Std Python modules
import sys, time, re

# CM19a module
import CM19aDriver

# Start logging
log = CM19aDriver.startLogging()  # log is an instance of the logger class

# Configure the CM19a and start polling for inbound commands from a remote
# Initialise device. Note: auto polling/receiving in a thread is turned ON
cm19a = CM19aDriver.CM19aDevice(
    POLLFREQ, log,
    polling=True)  # cm19a is an instance of the CM19aDevice class

if cm19a.initialised:
    # Firstly some simple send commands
    # Send the command 'ON' to X10 device A1 wirelessly via the CM19a (and a receiver of course)
    print "Turning ON A1..."
    result = cm19a.send("A", "1", "ON")  # True if the command was sent OK
    if result:
        print "...Success"
    else:
        print >> sys.stderr, "Command failed"

    print "Waiting 5 seconds (so we can check that the device has turned on)..."
    time.sleep(5)