def update(self, resource, debug=False): """ @summary: Rename lights, or set a light's state, as determined by the\ resource object. """ request = Request() if ('attr' in resource['data']): service = 'lights/{id}'.format(id=resource['which']) data = resource['data']['attr'] elif ('state' in resource['data']): service = 'lights/{id}/state'.format(id=resource['which']) data = resource['data']['state'] else: raise Exception('Unknown data type.') path = 'api/{username}/{service}'.format(username=self.user['name'], service=service) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, data) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): """ @summary: Rename lights, or set a light's state, as determined by the\ resource object. """ request = Request() if (resource['data'].has_key('attr')): service = 'lights/{id}'.format(id=resource['which']) data = resource['data']['attr'] elif (resource['data'].has_key('state')): service = 'lights/{id}/state'.format(id=resource['which']) data = resource['data']['state'] else: raise Exception('Unknown data type.') path = 'api/{username}/{service}'.format( username=self.user['name'], service=service ) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, data) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): """ """ request = Request() path = 'api/{username}/config'.format(username=self.user['name']) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, resource['data']['attr']) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): request = Request() service = 'scenes/{id}'.format(id=resource['which']) path = 'api/{username}/{service}'.format(username=self.user['name'], service=service) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, resource['data']) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): """ """ request = Request() service = "schedules/{id}".format(id=resource["which"]) path = "api/{username}/{service}".format(username=self.user["name"], service=service) url = "http://{bridge_ip}/{path}".format(bridge_ip=self.bridge["ip"], path=path) status, content = request.put(url, resource["data"]) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): request = Request() service = 'scenes/{id}'.format(id=resource['which']) path = 'api/{username}/{service}'.format( username=self.user['name'], service=service ) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, resource['data']) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): """ """ request = Request() if resource["data"].has_key("name"): service = "groups/{id}".format(id=resource["which"]) elif resource["data"].has_key("action"): service = "groups/{id}/action".format(id=resource["which"]) else: raise Exception("Unknown data type.") path = "api/{username}/{service}".format(username=self.user["name"], service=service) url = "http://{bridge_ip}/{path}".format(bridge_ip=self.bridge["ip"], path=path) status, content = request.put(url, resource["data"]["action"]) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): """ """ request = Request() if (resource['data'].has_key('name')): service = 'groups/{id}'.format(id=resource['which']) elif (resource['data'].has_key('action')): service = 'groups/{id}/action'.format(id=resource['which']) else: raise Exception('Unknown data type.') path = 'api/{username}/{service}'.format(username=self.user['name'], service=service) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, resource['data']['action']) if debug: return dict(info=status, resource=content) else: return dict(resource=content)
def update(self, resource, debug=False): """ """ request = Request() if (resource['data'].has_key('name')): service = 'groups/{id}'.format(id=resource['which']) elif (resource['data'].has_key('action')): service = 'groups/{id}/action'.format(id=resource['which']) else: raise Exception('Unknown data type.') path = 'api/{username}/{service}'.format( username=self.user['name'], service=service ) url = 'http://{bridge_ip}/{path}'.format(bridge_ip=self.bridge['ip'], path=path) status, content = request.put(url, resource['data']['action']) if debug: return dict(info=status, resource=content) else: return dict(resource=content)