Utility Models

Types

class encodapy.config.types.AttributeTypes(*values)[source]

Bases: Enum

Enum class for the attribute types

Variables:
  • TIMESERIES (str) – Timeseries data “timeseries”

  • VALUE (str) – Single value data “value”

TIMESERIES = 'timeseries'
VALUE = 'value'
class encodapy.config.types.DataQueryTypes(*values)[source]

Bases: Enum

Enum class for the data query types, used for the functions to get data

Variables:
  • CALCULATION (str) – Calculation of the data “calculation”

  • CALIBRATION (str) – Calibration of the data “calibration”

CALCULATION = 'calculation'
CALIBRATION = 'calibration'
class encodapy.config.types.FileExtensionTypes(*values)[source]

Bases: Enum

Enum class for file Extensions, used for the file interface and defines the possible file formats

Variables:
  • CSV (str) – Comma-separated values “csv”

  • JSON (str) – JavaScript Object Notation “json”

CSV = '.csv'
JSON = '.json'
class encodapy.config.types.Interfaces(*values)[source]

Bases: Enum

Enum class for the interfaces

Variables:
  • MQTT (str) – MQTT interface “mqtt”

  • FIWARE (str) – FIWARE interface “fiware”

  • FILE (str) – File interface “file”

FILE = 'file'
FIWARE = 'fiware'
MQTT = 'mqtt'
class encodapy.config.types.MQTTFormatTypes(*values)[source]

Bases: Enum

Enum class for MQTT format types Possible values: - PLAIN (plain): Plain format - FIWARE_ATTR (fiware-attr): FIWARE attribute format - FIWARE_CMDEXE (fiware-cmdexe): FIWARE command execution format - TEMPLATE (template): Template-based format

FIWARE_ATTR = 'fiware-attr'
FIWARE_CMDEXE = 'fiware-cmdexe'
PLAIN = 'plain'
TEMPLATE = 'template'
class encodapy.config.types.TimerangeTypes(*values)[source]

Bases: Enum

Enum class for the timedelta types, used for the functions to get timeseries data

Variables:
  • ABSOLUTE (str) – The timedelta is calculated from the actual time “absolute”

  • RELATIVE (str) – The timedelta is calculated from the last timestamp “relative”

ABSOLUTE = 'absolute'
RELATIVE = 'relative'
pydantic model encodapy.config.mqtt_messages_template.MQTTTemplateConfigDoc[source]

Model for MQTT template configuration.

Mock class for documentation purposes.

Note

In the actual implementation, topic and payload are jinja2.Template objects, time_format is a str as time format for the timestamp in the payload. This mock uses dict to avoid import issues during documentation generation.

For more information, see MQTTTemplateConfig.

field topic: dict [Required]
field payload: dict [Required]
field time_format: str = '%Y-%m-%dT%H:%M:%S%z'

Datapoints

pydantic model encodapy.utils.datapoints.DataPointGeneral[source]

Bases: BaseModel

Model for datapoints of the controller component.

Variables:
  • value (Any) – The value of the datapoint, which can be of various types (string, float, int, boolean, dictionary, list, DataFrame, or None).

  • unit (Optional[DataUnits]) – Optional unit of the datapoint, if applicable.

  • time (Optional[datetime]) – Optional timestamp of the datapoint, if applicable.

Show JSON schema
{
   "title": "DataPointGeneral",
   "description": "Model for datapoints of the controller component.\n\nAttributes:\n    value (Any): The value of the datapoint, which can be of various types             (string, float, int, boolean, dictionary, list, DataFrame, or None).\n    unit (Optional[DataUnits]): Optional unit of the datapoint, if applicable.\n    time (Optional[datetime]): Optional timestamp of the datapoint, if applicable.",
   "type": "object",
   "properties": {
      "value": {
         "title": "Value"
      },
      "unit": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataUnits"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "time": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time"
      }
   },
   "$defs": {
      "DataUnits": {
         "description": "Possible units for the data\nUnits which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download\nor https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv)\nor here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf\nTODO:\n    - Is there a better way to handle the units?\n    - Add more units?",
         "enum": [
            "SEC",
            "HUR",
            "MIN",
            "CEL",
            "KEL",
            "LTR",
            "MTQ",
            "MQH",
            "MQS",
            "E32",
            "L2",
            "WTT",
            "WHR",
            "KWH",
            "CMT",
            "MTR",
            "MTK",
            "MTS",
            "P1",
            "OHM",
            "VLT"
         ],
         "title": "DataUnits",
         "type": "string"
      }
   },
   "required": [
      "value"
   ]
}

field value: Any [Required]
field unit: Optional[DataUnits] = None
field time: Optional[datetime] = None
pydantic model encodapy.utils.datapoints.DataPointNumber[source]

Bases: DataPointGeneral

Model for datapoints of the controller component.

Variables:
  • value (float | int) – The value of the datapoint, which is a number (float, int).

  • unit (Optional[DataUnits]) – Optional unit of the datapoint, if applicable.

  • time (Optional[datetime]) – Optional timestamp of the datapoint, if applicable.

Show JSON schema
{
   "title": "DataPointNumber",
   "description": "Model for datapoints of the controller component.\n\nAttributes:\n    value (float | int): The value of the datapoint, which is a number (float, int).\n    unit (Optional[DataUnits]): Optional unit of the datapoint, if applicable.\n    time (Optional[datetime]): Optional timestamp of the datapoint, if applicable.",
   "type": "object",
   "properties": {
      "value": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Value"
      },
      "unit": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataUnits"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "time": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time"
      }
   },
   "$defs": {
      "DataUnits": {
         "description": "Possible units for the data\nUnits which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download\nor https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv)\nor here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf\nTODO:\n    - Is there a better way to handle the units?\n    - Add more units?",
         "enum": [
            "SEC",
            "HUR",
            "MIN",
            "CEL",
            "KEL",
            "LTR",
            "MTQ",
            "MQH",
            "MQS",
            "E32",
            "L2",
            "WTT",
            "WHR",
            "KWH",
            "CMT",
            "MTR",
            "MTK",
            "MTS",
            "P1",
            "OHM",
            "VLT"
         ],
         "title": "DataUnits",
         "type": "string"
      }
   },
   "required": [
      "value"
   ]
}

field value: float | int [Required]
pydantic model encodapy.utils.datapoints.DataPointString[source]

Bases: DataPointGeneral

Model for datapoints of the controller component.

Variables:
  • value (str) – The value of the datapoint, which is a string.

  • unit (Optional[DataUnits]) – Optional unit of the datapoint, if applicable.

  • time (Optional[datetime]) – Optional timestamp of the datapoint, if applicable.

Show JSON schema
{
   "title": "DataPointString",
   "description": "Model for datapoints of the controller component.\n\nAttributes:\n    value (str): The value of the datapoint, which is a string.\n    unit (Optional[DataUnits]): Optional unit of the datapoint, if applicable.\n    time (Optional[datetime]): Optional timestamp of the datapoint, if applicable.",
   "type": "object",
   "properties": {
      "value": {
         "title": "Value",
         "type": "string"
      },
      "unit": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataUnits"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "time": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time"
      }
   },
   "$defs": {
      "DataUnits": {
         "description": "Possible units for the data\nUnits which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download\nor https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv)\nor here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf\nTODO:\n    - Is there a better way to handle the units?\n    - Add more units?",
         "enum": [
            "SEC",
            "HUR",
            "MIN",
            "CEL",
            "KEL",
            "LTR",
            "MTQ",
            "MQH",
            "MQS",
            "E32",
            "L2",
            "WTT",
            "WHR",
            "KWH",
            "CMT",
            "MTR",
            "MTK",
            "MTS",
            "P1",
            "OHM",
            "VLT"
         ],
         "title": "DataUnits",
         "type": "string"
      }
   },
   "required": [
      "value"
   ]
}

field value: str [Required]
pydantic model encodapy.utils.datapoints.DataPointDict[source]

Bases: DataPointGeneral

Model for datapoints of the controller component.

Variables:
  • value (dict) – The value of the datapoint, which is a dictionary.

  • unit (Optional[DataUnits]) – Optional unit of the datapoint, if applicable.

  • time (Optional[datetime]) – Optional timestamp of the datapoint, if applicable.

Show JSON schema
{
   "title": "DataPointDict",
   "description": "Model for datapoints of the controller component.\n\nAttributes:\n    value (dict): The value of the datapoint, which is a dictionary.\n    unit (Optional[DataUnits]): Optional unit of the datapoint, if applicable.\n    time (Optional[datetime]): Optional timestamp of the datapoint, if applicable.",
   "type": "object",
   "properties": {
      "value": {
         "title": "Value",
         "type": "object"
      },
      "unit": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataUnits"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "time": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time"
      }
   },
   "$defs": {
      "DataUnits": {
         "description": "Possible units for the data\nUnits which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download\nor https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv)\nor here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf\nTODO:\n    - Is there a better way to handle the units?\n    - Add more units?",
         "enum": [
            "SEC",
            "HUR",
            "MIN",
            "CEL",
            "KEL",
            "LTR",
            "MTQ",
            "MQH",
            "MQS",
            "E32",
            "L2",
            "WTT",
            "WHR",
            "KWH",
            "CMT",
            "MTR",
            "MTK",
            "MTS",
            "P1",
            "OHM",
            "VLT"
         ],
         "title": "DataUnits",
         "type": "string"
      }
   },
   "required": [
      "value"
   ]
}

field value: dict [Required]
pydantic model encodapy.utils.datapoints.DataPointBool[source]

Bases: DataPointGeneral

Model for datapoints of the controller component.

Variables:
  • value (bool) – The value of the datapoint, which is a boolean.

  • unit (Optional[DataUnits]) – Optional unit of the datapoint, if applicable.

  • time (Optional[datetime]) – Optional timestamp of the datapoint, if applicable.

Show JSON schema
{
   "title": "DataPointBool",
   "description": "Model for datapoints of the controller component.\n\nAttributes:\n    value (bool): The value of the datapoint, which is a boolean.\n    unit (Optional[DataUnits]): Optional unit of the datapoint, if applicable.\n    time (Optional[datetime]): Optional timestamp of the datapoint, if applicable.",
   "type": "object",
   "properties": {
      "value": {
         "title": "Value",
         "type": "boolean"
      },
      "unit": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataUnits"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "time": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time"
      }
   },
   "$defs": {
      "DataUnits": {
         "description": "Possible units for the data\nUnits which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download\nor https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv)\nor here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf\nTODO:\n    - Is there a better way to handle the units?\n    - Add more units?",
         "enum": [
            "SEC",
            "HUR",
            "MIN",
            "CEL",
            "KEL",
            "LTR",
            "MTQ",
            "MQH",
            "MQS",
            "E32",
            "L2",
            "WTT",
            "WHR",
            "KWH",
            "CMT",
            "MTR",
            "MTK",
            "MTS",
            "P1",
            "OHM",
            "VLT"
         ],
         "title": "DataUnits",
         "type": "string"
      }
   },
   "required": [
      "value"
   ]
}

field value: bool [Required]
pydantic model encodapy.utils.datapoints.DataPointMedium[source]

Bases: DataPointGeneral

Model for datapoints of the controller component which define the medium.

Variables:
  • value (Medium) – The value of the datapoint, which is a Medium representing the medium.

  • unit (Optional[DataUnits]) – Optional unit of the datapoint, if applicable.

  • time (Optional[datetime]) – Optional timestamp of the datapoint, if applicable.

Show JSON schema
{
   "title": "DataPointMedium",
   "description": "Model for datapoints of the controller component which define the medium.\n\nAttributes:\n    value (Medium): The value of the datapoint, which is a Medium representing the medium.\n    unit (Optional[DataUnits]): Optional unit of the datapoint, if applicable.\n    time (Optional[datetime]): Optional timestamp of the datapoint, if applicable.",
   "type": "object",
   "properties": {
      "value": {
         "$ref": "#/$defs/Medium"
      },
      "unit": {
         "anyOf": [
            {
               "$ref": "#/$defs/DataUnits"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "time": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Time"
      }
   },
   "$defs": {
      "DataUnits": {
         "description": "Possible units for the data\nUnits which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download\nor https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv)\nor here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf\nTODO:\n    - Is there a better way to handle the units?\n    - Add more units?",
         "enum": [
            "SEC",
            "HUR",
            "MIN",
            "CEL",
            "KEL",
            "LTR",
            "MTQ",
            "MQH",
            "MQS",
            "E32",
            "L2",
            "WTT",
            "WHR",
            "KWH",
            "CMT",
            "MTR",
            "MTK",
            "MTS",
            "P1",
            "OHM",
            "VLT"
         ],
         "title": "DataUnits",
         "type": "string"
      },
      "Medium": {
         "const": "water",
         "description": "Enum class for the mediums\n\nTODO: Add more mediums",
         "title": "Medium"
      }
   },
   "required": [
      "value"
   ]
}

field value: Medium [Required]

Units

class encodapy.utils.units.DataUnits(*values)[source]

Bases: Enum

Possible units for the data Units which are defined by Unit Code (https://unece.org/trade/cefact/UNLOCODE-Download or https://github.com/RWTH-EBC/FiLiP/blob/master/filip/data/unece-units/units_of_measure.csv) or here: https://unece.org/fileadmin/DAM/cefact/recommendations/rec20/rec20_rev3_Annex3e.pdf .. todo:

- Is there a better way to handle the units?
- Add more units?
CMT = 'CMT'
DEGREECELSIUS = 'CEL'
E32 = 'E32'
HOUR = 'HUR'
KELVIN = 'KEL'
KWH = 'KWH'
L2 = 'L2'
LITER = 'LTR'
MINUTE = 'MIN'
MQH = 'MQH'
MQS = 'MQS'
MTK = 'MTK'
MTQ = 'MTQ'
MTR = 'MTR'
MTS = 'MTS'
OHM = 'OHM'
PERCENT = 'P1'
SECOND = 'SEC'
VLT = 'VLT'
WHR = 'WHR'
WTT = 'WTT'
class encodapy.utils.units.TimeUnits(*values)[source]

Bases: Enum

Possible time units for the time series data

TODO: Is it better to use standard time units? Like in the unit code?

DAY = 'day'
HOUR = 'hour'
MINUTE = 'minute'
MONTH = 'month'
SECOND = 'second'
class encodapy.utils.units.TimeUnitsSeconds(*values)[source]

Bases: Enum

Seconds for the time units

DAY = 86400.0
HOUR = 3600.0
MINUTE = 60.0
MONTH = 2592000.0
SECOND = 1.0
encodapy.utils.units.get_time_unit_seconds(time_unit: TimeUnits | str | DataUnits) float | None[source]

Funktion to get the seconds for a time unit

Parameters:

time_unit (Union[TimeUnits, str, DataUnits]) – time unit / Name of the time unit If you use DataUnits, only the units which are also in TimeUnits are valid

Returns:

Number of seconds for the time unit or None if the time unit is not available

Return type:

Union[int, None]

Parameters:

time_unit (TimeUnits | str | DataUnits)

encodapy.utils.units.get_unit_adjustment_factor(unit_actual: DataUnits, unit_target: DataUnits) float | None[source]

Function to get the adjustment factor for the conversion of units

Parameters:
Returns:

Adjustment factor for the conversion of the units, if found

Return type:

Optional[float]

Parameters:

Mediums

class encodapy.utils.mediums.Medium(*values)[source]

Bases: Enum

Enum class for the mediums

TODO: Add more mediums

WATER = 'water'
pydantic model encodapy.utils.mediums.MediumParameters[source]

Bases: BaseModel

Base class for the medium parameters

Variables:
  • cp (float) – Specific heat capacity [kJ/kgK]

  • rho (float) – Density [kg/m³]

Show JSON schema
{
   "title": "MediumParameters",
   "description": "Base class for the medium parameters\n\nAttributes:\n    cp (float): Specific heat capacity [kJ/kgK]\n    rho (float): Density [kg/m\u00b3]",
   "type": "object",
   "properties": {
      "cp": {
         "title": "Cp",
         "type": "number"
      },
      "rho": {
         "title": "Rho",
         "type": "number"
      }
   },
   "required": [
      "cp",
      "rho"
   ]
}

field cp: float [Required]
field rho: float [Required]
encodapy.utils.mediums.get_medium_parameter(medium: Medium, temperature: float | None = None) MediumParameters[source]
Function to get the medium parameter
  • const values, if no temperature is set

  • calculation of cp and rho (constant pressure) as approximation of Glück
Parameters:
  • medium (Mediums) – The medium

  • temperature – float = None

Returns:

The parameters of the medium

Return type:

MediumParameters

Parameters: