from django.db import models
from django.utils.timezone import now
from datetime import datetime
from django.utils import timezone
from tinymce import models as tinymce_models
from model_utils import Choices
# Create your models here.





class sensoresfijos(models.Model):
    idsensor = models.CharField(max_length=5, null=False, unique=False, verbose_name='Tarjeta Sensor')
    temp = models.FloatField(null=True, blank=True, verbose_name='Temperatura')
    hume = models.FloatField(null=True, blank=True, verbose_name='Humedad')
    fecha = models.DateField(auto_now_add=True, verbose_name='Fecha')
    hora = models.TimeField(default=timezone.now, verbose_name='Hora')
    fecharango = models.DateTimeField(auto_now_add=True, verbose_name='Fecha por rango')

    def __str__(self):
            return self.idsensor
        
    class Meta:
            verbose_name = 'Sensor Fijo'
            verbose_name_plural = 'Sensor Fijo'
            ordering = ['idsensor']



class AltaSensoresFijos(models.Model):
    STATUS1 = Choices('SI', 'NO')
    idsensor = models.CharField(max_length=5, null=False, unique=True, verbose_name='Tarjeta Sensor')
    nombre = models.CharField(max_length=255, null=False, blank=False, verbose_name='Ubicacion')
    temp_media = models.FloatField(null=True, blank=True, verbose_name='Temperatura Media')
    temp_min = models.FloatField(null=False, blank=False, verbose_name='Temperatura Minima')
    temp_max = models.FloatField(null=False, blank=False, verbose_name='Temperatura Maxima')
    hume_min = models.FloatField(null=False, blank=False, verbose_name='Humedad Minima')
    hume_max = models.FloatField(null=False, blank=False, verbose_name='Humedad Maxima')
    activo = models.CharField(choices=STATUS1, default=STATUS1.NO, max_length=5, verbose_name='Activo?')
    ver_humedad = models.CharField(choices=STATUS1, default=STATUS1.NO, max_length=5, verbose_name='ver Humedad?')

    def __str__(self):
            return self.idsensor
        
    class Meta:
            verbose_name = 'Alta Sensor Fijo'
            verbose_name_plural = 'Alta Sensor Fijo'
            ordering = ['idsensor']


class telegram(models.Model):
    idBot = models.CharField(max_length=250, null=False, unique=True, verbose_name='ID del Bot')
    idGrupo = models.CharField(max_length=250, null=False, unique=True, verbose_name='ID del Grupo')

    def __str__(self):
            return self.idGrupo
        
    class Meta:
            verbose_name = 'telegram conf'
            verbose_name_plural = 'telegram conf'
            ordering = ['id']