123456789101112131415161718192021222324252627 |
- from pyheatpump.db import RowClass
- from pyheatpump.db import sql
- from datetime import date
-
- from .variable_type import VariableType
-
- class Variable(RowClass):
- address: int = None
- unit: str = None
- last_update: date = None
- type: str = None
-
- def __init__(self, **kwargs):
- super().__init__(**kwargs)
-
- @staticmethod
- def getall():
- return dict([
- (row.slabel, Variable.getall_of_type(row.slabel))
- for row in VariableType.getall().values()
- ])
-
- def getall_of_type(type: str):
- return [
- row['address'] for row in
- sql(f"SELECT address FROM variable WHERE type LIKE '{type}'")
- ]
|