Skip to content

Commit 25cd074

Browse files
committed
Rename temperature_max fields to temperature
The name `temperature_max` of a single battery indicates that a single battery can have multiple temperatures. This is not the case for all batteries, and hence can't be part of the high level API. In the high level APIs, there should be just one temperature value per battery. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent ada7a61 commit 25cd074

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/frequenz/sdk/actor/_data_sourcing/microgrid_api_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_channel_name(self) -> str:
8484
ComponentMetricId.CAPACITY: lambda msg: msg.capacity,
8585
ComponentMetricId.POWER_LOWER_BOUND: lambda msg: msg.power_lower_bound,
8686
ComponentMetricId.POWER_UPPER_BOUND: lambda msg: msg.power_upper_bound,
87-
ComponentMetricId.TEMPERATURE_MAX: lambda msg: msg.temperature_max,
87+
ComponentMetricId.TEMPERATURE: lambda msg: msg.temperature,
8888
}
8989

9090
_InverterDataMethods: Dict[ComponentMetricId, Callable[[InverterData], float]] = {

src/frequenz/sdk/microgrid/component/_component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ class ComponentMetricId(Enum):
140140
ACTIVE_POWER_LOWER_BOUND = "active_power_lower_bound"
141141
ACTIVE_POWER_UPPER_BOUND = "active_power_upper_bound"
142142

143-
TEMPERATURE_MAX = "temperature_max"
143+
TEMPERATURE = "temperature"

src/frequenz/sdk/microgrid/component/_component_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class BatteryData(ComponentData):
141141
This will be a positive number, or zero if no charging is possible.
142142
"""
143143

144-
temperature_max: float
145-
"""The maximum temperature of all the blocks in a battery, in Celcius (°C)."""
144+
temperature: float
145+
"""The (average) temperature reported by the battery a battery, in Celcius (°C)."""
146146

147147
_relay_state: battery_pb.RelayState.ValueType
148148
"""State of the battery relay."""
@@ -172,7 +172,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> BatteryData:
172172
capacity=raw.battery.properties.capacity,
173173
power_lower_bound=raw.battery.data.dc.power.system_bounds.lower,
174174
power_upper_bound=raw.battery.data.dc.power.system_bounds.upper,
175-
temperature_max=raw.battery.data.temperature.max,
175+
temperature=raw.battery.data.temperature.avg,
176176
_relay_state=raw.battery.state.relay_state,
177177
_component_state=raw.battery.state.component_state,
178178
_errors=list(raw.battery.errors),

src/frequenz/sdk/timeseries/battery_pool/_metric_calculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def __init__(self, batteries: Set[int]) -> None:
246246
super().__init__(batteries)
247247

248248
self._metrics = [
249-
ComponentMetricId.TEMPERATURE_MAX,
249+
ComponentMetricId.TEMPERATURE,
250250
]
251251

252252
@classmethod
@@ -306,7 +306,7 @@ def calculate(
306306
if battery_id not in metrics_data:
307307
continue
308308
metrics = metrics_data[battery_id]
309-
temperature = metrics.get(ComponentMetricId.TEMPERATURE_MAX)
309+
temperature = metrics.get(ComponentMetricId.TEMPERATURE)
310310
if temperature is None:
311311
continue
312312
timestamp = max(timestamp, metrics.timestamp)

tests/utils/component_data_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__( # pylint: disable=too-many-arguments
4343
capacity: float = math.nan,
4444
power_lower_bound: float = math.nan,
4545
power_upper_bound: float = math.nan,
46-
temperature_max: float = math.nan,
46+
temperature: float = math.nan,
4747
_relay_state: battery_pb.RelayState.ValueType = (
4848
battery_pb.RelayState.RELAY_STATE_UNSPECIFIED
4949
),
@@ -66,7 +66,7 @@ def __init__( # pylint: disable=too-many-arguments
6666
capacity=capacity,
6767
power_lower_bound=power_lower_bound,
6868
power_upper_bound=power_upper_bound,
69-
temperature_max=temperature_max,
69+
temperature=temperature,
7070
_relay_state=_relay_state,
7171
_component_state=_component_state,
7272
_errors=_errors if _errors else [],

0 commit comments

Comments
 (0)