Add API route for logging alarm light value

This commit is contained in:
Tanner Collin 2020-11-17 08:14:56 +00:00
parent c3238f8b75
commit 750eed0fb6

View File

@ -484,6 +484,17 @@ class StatsViewSet(viewsets.ViewSet, List):
except KeyError: except KeyError:
raise exceptions.ValidationError(dict(data='This field is required.')) raise exceptions.ValidationError(dict(data='This field is required.'))
@action(detail=False, methods=['post'])
def alarm(self, request):
try:
logging.info('Alarm value: ' + str(request.data['data']))
#cache.set('alarm', int(request.data['data']))
return Response(200)
except ValueError:
raise exceptions.ValidationError(dict(data='Invalid integer.'))
except KeyError:
raise exceptions.ValidationError(dict(data='This field is required.'))
@action(detail=False, methods=['post']) @action(detail=False, methods=['post'])
def track(self, request): def track(self, request):
if 'name' in request.data: if 'name' in request.data: