1
0
mirror of https://github.com/daniviga/bite.git synced 2024-11-23 21:36:14 +01:00
bite/freedcs/telemetry/models.py

25 lines
781 B
Python
Raw Normal View History

2020-06-02 00:57:20 +02:00
from django.db import models
from django.core.validators import MinValueValidator
2020-06-02 00:57:20 +02:00
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)
transport = models.CharField(max_length=4,
choices=[('http', 'http'), ('mqtt', 'mqtt')],
default='http')
clock = models.IntegerField(
validators=[MinValueValidator(0)],
null=True)
2020-06-02 00:57:20 +02:00
payload = JSONField()
class Meta:
ordering = ['-time', 'device']
2020-06-02 00:57:20 +02:00
verbose_name_plural = "Telemetry"
def __str__(self):
return str(self.time)