Projet de remplacement du "RPiPasserelle" d'Otec.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

variable.py 686B

123456789101112131415161718192021222324252627
  1. from pyheatpump.db import RowClass
  2. from pyheatpump.db import sql
  3. from datetime import date
  4. from .variable_type import VariableType
  5. class Variable(RowClass):
  6. address: int = None
  7. unit: str = None
  8. last_update: date = None
  9. type: str = None
  10. def __init__(self, **kwargs):
  11. super().__init__(**kwargs)
  12. @staticmethod
  13. def getall():
  14. return dict([
  15. (row.slabel, Variable.getall_of_type(row.slabel))
  16. for row in VariableType.getall().values()
  17. ])
  18. def getall_of_type(type: str):
  19. return [
  20. row['address'] for row in
  21. sql(f"SELECT address FROM variable WHERE type LIKE '{type}'")
  22. ]