예제 #1
0
def status_all():
    global logger
    for devname in insteon_utils.devices_byname:
        devnum = insteon_utils.devices_byname[devname]
        status = dev_status(devnum)
        logger.info("Status check - '" + devname + "' (" + str(devnum) +
                    ") - " + status)
예제 #2
0
def turn_off(devnum,devname,status):
	# Don't turn it off if it's already off!
	global logger
	if (status != "Off"):
		logger.info ("device_off(" + str(devnum) + ") # " + devname)
		device_off(devnum)
		status = dev_status(devnum)
		if (status == "On"):
			logger.error(devname + "(" + str(devnum) + ") did not turn off - Current status = " + status)
	else:
		logger.info("Do Nothing - " + devname + " is already OFF")
	return status
예제 #3
0
def turn_on(devnum,devname,ON_OFF_STATUS,status):
	# Don't turn it on if it's already on!
	global logger
	logger.debug("[" + ON_OFF_STATUS + "][" + status + "]")
	if (not re.match('.*On.*',status,re.I)):
		logger.info("device_on(" + str(devnum) + ", 5) # " + devname)
		device_on(devnum, 5)
		# Check that it's actually on now
		status = dev_status(devnum)
		if (status == "Off"):
			logger.error(devname + "(" + str(devnum) + ") did not turn on - Current status = " + status)
		else:
			logger.info("Do Nothing - " + devname + " is already ON")
	return status
예제 #4
0
def process_request(devname, ON_OFF_STATUS):
    global logger
    devnum = insteon_utils.devices_byname[devname]

    # Check current device status
    status = dev_status(devnum)
    # logger.info("[" + ON_OFF_STATUS + "][" + status + "]")
    if (re.match(ON_OFF_STATUS, status, re.I)):
        logger.info(devname + " is already " + status)
    else:
        logger.info(devname + " is currently " + status)

    # Asked to turn on
    if re.match('on|100', ON_OFF_STATUS, re.I):
        status = turn_on(devnum, devname, ON_OFF_STATUS, status)
    # Asked to turn off
    elif re.match('off|0', ON_OFF_STATUS, re.I):
        status = turn_off(devnum, devname, status)
    elif re.match('status', ON_OFF_STATUS, re.I):
        status = get_status(devnum)
    else:
        print("ERROR - " + str(ON_OFF_STATUS) + " " + devname)
    return status
예제 #5
0
def process_request(devname,ON_OFF_STATUS):
	global logger
	devnum = insteon_utils.devices_byname[devname]

	# Check current device status
	status = dev_status(devnum)
	# logger.info("[" + ON_OFF_STATUS + "][" + status + "]")
	if (re.match( ON_OFF_STATUS, status , re.I)):
		logger.info(devname + " is already " + status)
	else:
		logger.info(devname + " is currently " + status)

	# Asked to turn on
	if re.match( 'on|100', ON_OFF_STATUS, re.I):
		status = turn_on(devnum,devname,ON_OFF_STATUS,status)
	# Asked to turn off
	elif re.match( 'off|0', ON_OFF_STATUS , re.I):
		status = turn_off(devnum,devname,status)
	elif re.match( 'status', ON_OFF_STATUS , re.I):
		status = get_status(devnum)
	else:
		print("ERROR - " +  str(ON_OFF_STATUS) + " " + devname) 
	return status
예제 #6
0
def get_status(devnum):
    global logger
    status = dev_status(devnum)
    # no logging needed here. "dev_status" already logs
    # logger.info("Status check - '" + devname + "' (" + str(devnum) + ") - " + status)
    return status
예제 #7
0
def get_status(devnum):
	global logger
	status = dev_status(devnum)
	# no logging needed here. "dev_status" already logs
	# logger.info("Status check - '" + devname + "' (" + str(devnum) + ") - " + status)
	return status
예제 #8
0
def status_all():
	global logger
	for devname in insteon_utils.devices_byname:
		devnum = insteon_utils.devices_byname[devname]
		status = dev_status(devnum)
		logger.info("Status check - '" + devname + "' (" + str(devnum) + ") - " + status)