def startMonitoring(timekeeperIP, timekeeperPort): global TIMEKEEPER_HOST global TIMEKEEPER_PORT TIMEKEEPER_HOST = timekeeperIP TIMEKEEPER_PORT = timekeeperPort # add a listener for output setting events eventBus.addEventListener(eventBus.E_OUTPUT_SET, setOutputState) # add a listener for sending commands to the timekeeper eventBus.addEventListener(eventBus.E_SEND_TIMEKEEPER_COMMAND, sendCommand) # Thread to watch the Timekeeper Event stream monitorThread = threading.Thread( target = monitorSystem, args = (timekeeperIP, timekeeperPort) ) # thread to periodically ask for a full system status statusThread = threading.Thread( target = runFullSystemUpdates, args = (timekeeperIP, timekeeperPort) ) monitorThread.start() statusThread.start()
def startMonitoring(timekeeperIP, timekeeperPort): global TIMEKEEPER_HOST global TIMEKEEPER_PORT TIMEKEEPER_HOST = timekeeperIP TIMEKEEPER_PORT = timekeeperPort # add a listener for output setting events eventBus.addEventListener(eventBus.E_OUTPUT_SET, setOutputState) # add a listener for sending commands to the timekeeper eventBus.addEventListener(eventBus.E_SEND_TIMEKEEPER_COMMAND, sendCommand) # Thread to watch the Timekeeper Event stream monitorThread = threading.Thread(target=monitorSystem, args=(timekeeperIP, timekeeperPort)) # thread to periodically ask for a full system status statusThread = threading.Thread(target=runFullSystemUpdates, args=(timekeeperIP, timekeeperPort)) monitorThread.start() statusThread.start()
import monitor import time import apiserver import openHABInterface import eventBus # start the eventBus eventBus.startEventBus() # make sure that openHAB gets events eventBus.addEventListener(eventBus.E_OUTPUT_STATE, openHABInterface.reportStatusChange) # Start monitoring the TimeKeeper monitor.startMonitoring('192.168.1.200', 4000) # Start the API service apiserver.startServing(port=8000) # Goop to display the "on" outputs every few seconds while 1: for key in monitor.OutputStatuses.keys(): if monitor.OutputStatuses[key] == '64': print '%s: on' %key print '--------------------------' time.sleep(5)
import monitor import time import apiserver import openHABInterface import eventBus # start the eventBus eventBus.startEventBus() # make sure that openHAB gets events eventBus.addEventListener(eventBus.E_OUTPUT_STATE, openHABInterface.reportStatusChange) # Start monitoring the TimeKeeper monitor.startMonitoring('192.168.1.200', 4000) # Start the API service apiserver.startServing(port=8000) # Goop to display the "on" outputs every few seconds while 1: for key in monitor.OutputStatuses.keys(): if monitor.OutputStatuses[key] == '64': print '%s: on' % key print '--------------------------' time.sleep(5)