sensor
frequenz.client.microgrid.sensor ¤
Microgrid sensors.
This package provides classes and utilities for working with different types of
sensors in a microgrid environment. Sensor
s
measure various physical metrics in the surrounding environment, such as temperature,
humidity, and solar irradiance.
Streaming Sensor Data Samples¤
This package also provides several data structures for handling sensor readings and states:
SensorDataSamples
: Represents a collection of sensor data samples.SensorErrorCode
: Defines error codes that a sensor can report.SensorMetric
: Enumerates the different metrics a sensor can measure (e.g., temperature, voltage).SensorMetricSample
: Represents a single sample of a sensor metric, including its value and timestamp.SensorStateCode
: Defines codes representing the operational state of a sensor.SensorStateSample
: Represents a single sample of a sensor's state, including its state code and timestamp.
Classes¤
frequenz.client.microgrid.sensor.Sensor
dataclass
¤
Measures environmental metrics in the microgrid.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
identity
property
¤
identity: SensorId
The identity of this sensor.
This uses the sensor ID to identify a sensor without considering the other attributes, so even if a sensor state changed, the identity remains the same.
manufacturer
class-attribute
instance-attribute
¤
manufacturer: str | None = None
The manufacturer of this sensor.
model_name
class-attribute
instance-attribute
¤
model_name: str | None = None
The model name of this sensor.
operational_lifetime
class-attribute
instance-attribute
¤
The operational lifetime of this sensor.
Functions¤
frequenz.client.microgrid.sensor.SensorDataSamples
dataclass
¤
An aggregate of multiple metrics, states, and errors of a sensor.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
frequenz.client.microgrid.sensor.SensorErrorCode ¤
Bases: Enum
The various errors that can occur in sensors.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = ERROR_CODE_UNSPECIFIED
Default value (this should not be normally used and usually indicates an issue).
frequenz.client.microgrid.sensor.SensorMetric ¤
Bases: Enum
The metrics that can be reported by sensors in the microgrid.
These metrics correspond to various sensor readings primarily related to environmental conditions and physical measurements.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
ACCELERATION
class-attribute
instance-attribute
¤
ACCELERATION = SENSOR_METRIC_ACCELERATION
Acceleration in meters per second per second (m / s²).
ANGLE
class-attribute
instance-attribute
¤
ANGLE = SENSOR_METRIC_ANGLE
Angle, in degrees with respect to the (magnetic) North (°).
DEW_POINT
class-attribute
instance-attribute
¤
DEW_POINT = SENSOR_METRIC_DEW_POINT
Dew point, in Celsius (°C).
The temperature at which the air becomes saturated with water vapor.
HUMIDITY
class-attribute
instance-attribute
¤
HUMIDITY = SENSOR_METRIC_HUMIDITY
Humidity, in percentage (%).
IRRADIANCE
class-attribute
instance-attribute
¤
IRRADIANCE = SENSOR_METRIC_IRRADIANCE
Irradiance / Radiation flux, in watts per square meter (W / m²).
PRESSURE
class-attribute
instance-attribute
¤
PRESSURE = SENSOR_METRIC_PRESSURE
Pressure, in Pascal (Pa).
TEMPERATURE
class-attribute
instance-attribute
¤
TEMPERATURE = SENSOR_METRIC_TEMPERATURE
Temperature, in Celsius (°C).
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = SENSOR_METRIC_UNSPECIFIED
Default value (this should not be normally used and usually indicates an issue).
VELOCITY
class-attribute
instance-attribute
¤
VELOCITY = SENSOR_METRIC_VELOCITY
Velocity, in meters per second (m / s).
frequenz.client.microgrid.sensor.SensorMetricSample
dataclass
¤
A sample of a sensor metric at a specific time.
This represents a single sample of a specific metric, the value of which is either measured at a particular time.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
value
instance-attribute
¤
value: float | AggregatedMetricValue | None
The value of the sampled metric.
Functions¤
as_single_value ¤
as_single_value(
*, aggregation_method: AggregationMethod = AVG
) -> float | None
Return the value of this sample as a single value.
if value
is a float
,
it is returned as is. If value
is an
AggregatedMetricValue
,
the value is aggregated using the provided aggregation_method
.
PARAMETER | DESCRIPTION |
---|---|
aggregation_method
|
The method to use to aggregate the value when
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
float | None
|
The value of the sample as a single value, or |
Source code in frequenz/client/microgrid/sensor.py
frequenz.client.microgrid.sensor.SensorStateCode ¤
Bases: Enum
The various states that a sensor can be in.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
ERROR
class-attribute
instance-attribute
¤
ERROR = COMPONENT_STATE_ERROR
The sensor is in an error state.
UNSPECIFIED
class-attribute
instance-attribute
¤
UNSPECIFIED = COMPONENT_STATE_UNSPECIFIED
Default value (this should not be normally used and usually indicates an issue).
frequenz.client.microgrid.sensor.SensorStateSample
dataclass
¤
A sample of state, warnings, and errors for a sensor at a specific time.
Source code in frequenz/client/microgrid/sensor.py
Attributes¤
errors
instance-attribute
¤
errors: frozenset[SensorErrorCode | int]
The set of errors for the sensor.
This set will only contain errors if the sensor is in an error state.
states
instance-attribute
¤
states: frozenset[SensorStateCode | int]
The set of states of the sensor.
If the reported state is not known by the client (it could happen when using an
older version of the client with a newer version of the server), it will be
represented as an int
and not the
SensorStateCode.UNSPECIFIED
value (this value is used only when the state is not known by the server).
warnings
instance-attribute
¤
warnings: frozenset[SensorErrorCode | int]
The set of warnings for the sensor.