@@ -0,0 +1,966 @@
+%22%22%22%0A Script:  restConn.py%0A Author:  Lenny Shirley %3Chttp://www.lennysh.com%3E%0A Date:    February 8, 2016%0A Purpose: Provides a connection to the OpenHAB REST API%0A%22%22%22%0A%0Aimport sys%0Aimport requests%0Afrom requests.exceptions import ConnectionError%0A%0Adebug = 1%0A%0Aclass restConnection(object):%0A    %22%22%22Centralizes the REST logic%22%22%22%0A%0A    def config(self, logger, url):%0A        %22%22%22Configures the client%22%22%22%0A        %0A        self.logger = logger%0A        self.url = url%0A%0A    def publish(self, message, destination):%0A        %22%22%22Called by others to publish a message to a Destination%22%22%22%0A%0A        try:%0A            msg = %22Published message '%25s' to '%25s'%22 %25 (message, destination)%0A            if debug:%0A                print msg%0A            requests.put(self.url + destination + %22/state/%22,data=message)%0A            self.logger.info(msg)%0A        except:%0A            msg = %22Unexpected error publishing message: %25s%22 %25 (sys.exc_info()%5B0%5D)%0A            print msg%0A            self.logger.error(msg)%0A

Create restConn.py