def get(self, which): self.set_header("Content-Type", "text/plain") self.write(hexFromRgb(self.settings.brites[int(which)]))
"""takes 10-bit r,g,b returns even if the server is down """ log.debug("setColor(%r,%r)", lightName, rgb) if lightName == "bedroomBall": try: r = _req(method="PUT", url=lightResource["slash-zwave"], body="%g" % (rgb[0] / 1024), headers={}) return r except Exception, e: log.warn(e) return serv = lightResource[lightName] try: h = hexFromRgb(rgb) log.debug("put %r to %r", h, serv) r = _req(method="PUT", url=serv, body=h, headers={"content-type": "text/plain"}) return r except Exception, e: log.warn("Talking to: %r" % serv) log.warn(e) return None def setColorAsync(lightName, rgb): """ uses twisted http, return deferred or sometimes None when there was a warning """
def get(self, pos): self.set_header("Content-Type", "text/plain") self.write(hexFromRgb(self.settings.colors[int(pos)]))
""" log.debug("setColor(%r,%r)", lightName, rgb) if lightName == 'bedroomBall': try: r = _req(method='PUT', url=lightResource['slash-zwave'], body="%g" % (rgb[0] / 1024), headers={}) return r except Exception, e: log.warn(e) return serv = lightResource[lightName] try: h = hexFromRgb(rgb) log.debug("put %r to %r", h, serv) r = _req(method='PUT', url=serv, body=h, headers={"content-type": "text/plain"}) return r except Exception, e: log.warn("Talking to: %r" % serv) log.warn(e) return None def setColorAsync(lightName, rgb): """ uses twisted http, return deferred or sometimes None when there