def set_service(self, path): ''' format /api/user/building/entry/set/buildingid/service_id/value where service_id is the service id and value is the value that you wish to set for the actuator/service.''' if len(path) < self.PATH_START_IDX + 4: raise BadRequest("To set building services. You must supply a service id and its new value. Ex. /api/user/building/entry/set/buildingid/serviceid/0.") buildingID = self._get_buildingID(path) serviceID = self._get_serviceID(path) value = self._get_value(path) # Instantiate building if its not already done so Manager.lookup(buildingID) Manager.set_building_service(buildingID, serviceID, value) r = dict() r['returnvalue'] = True return r
def set_service(self, request, **kwargs): """ format /api/user/building/entry/set/buildingid/service_id/value where service_id is the service id and value is the value that you wish to set for the actuator/service.""" path = request.path.split("/") print path if len(path) < self.PATH_START_IDX + 4: raise BadRequest( "To set building services. You must supply a service id and its new value. Ex. /api/user/building/entry/set/buildingid/serviceid/0." ) buildingID = self._get_buildingID(path) serviceID = self._get_serviceID(path) value = self._get_value(path) # Instantiate building if its not already done so Manager.lookup(buildingID) Manager.set_building_service(buildingID, serviceID, value) r = dict() r["returnvalue"] = True return self.create_response(request, r)