1
0
mirror of https://github.com/daniviga/bite.git synced 2024-12-24 17:21:25 +01:00
bite/freedcs/telemetry/models.py
Daniele Viganò e4a3684951
Enable NTP (#6)
* Add ntpd server to the stack

* Enable NTP updates on Arduino

* Fix telemetry when clock is 0
2020-06-03 18:53:33 +02:00

22 lines
606 B
Python

from django.db import models
from django.core.validators import MinValueValidator
from django.contrib.postgres.fields import JSONField
from api.models import Device
class Telemetry(models.Model):
device = models.ForeignKey(Device, on_delete=models.CASCADE)
time = models.DateTimeField(primary_key=True, auto_now_add=True)
clock = models.IntegerField(
validators=[MinValueValidator(0)],
null=True)
payload = JSONField()
class Meta:
ordering = ['-time', 'device']
verbose_name_plural = "Telemetry"
def __str__(self):
return str(self.time)