2424from frequenz .sdk .actor import ResamplerConfig
2525from frequenz .sdk .actor .power_distributing import BatteryStatus
2626from frequenz .sdk .microgrid .component import ComponentCategory
27- from frequenz .sdk .timeseries import Energy , Power , Quantity , Sample
27+ from frequenz .sdk .timeseries import Energy , Percentage , Power , Sample
2828from frequenz .sdk .timeseries .battery_pool import BatteryPool , Bound , PowerMetrics
2929from frequenz .sdk .timeseries .battery_pool ._metric_calculator import (
3030 battery_inverter_mapping ,
@@ -688,29 +688,29 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
688688 now = datetime .now (tz = timezone .utc )
689689 expected = Sample (
690690 timestamp = now ,
691- value = Quantity (10.0 ),
691+ value = Percentage . from_percent (10.0 ),
692692 )
693693 compare_messages (msg , expected , WAIT_FOR_COMPONENT_DATA_SEC + 0.2 )
694694
695695 batteries_in_pool = list (battery_pool .battery_ids )
696- scenarios : list [Scenario [Sample [Quantity ]]] = [
696+ scenarios : list [Scenario [Sample [Percentage ]]] = [
697697 Scenario (
698698 batteries_in_pool [0 ],
699699 {"capacity" : 150 , "soc" : 10 },
700- Sample (now , Quantity (2.5 )),
700+ Sample (now , Percentage . from_percent (2.5 )),
701701 ),
702702 Scenario (
703703 batteries_in_pool [0 ],
704704 {
705705 "soc_lower_bound" : 0.0 ,
706706 },
707- Sample (now , Quantity (12.727272727272727 )),
707+ Sample (now , Percentage . from_percent (12.727272727272727 )),
708708 ),
709709 # If NaN, then not include that battery in the metric.
710710 Scenario (
711711 batteries_in_pool [0 ],
712712 {"soc_upper_bound" : float ("NaN" )},
713- Sample (now , Quantity (10.0 )),
713+ Sample (now , Percentage . from_percent (10.0 )),
714714 ),
715715 # All batteries are sending NaN, can't calculate SoC so we should send None
716716 Scenario (
@@ -721,7 +721,7 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
721721 Scenario (
722722 batteries_in_pool [1 ],
723723 {"soc" : 30 },
724- Sample (now , Quantity (10.0 )),
724+ Sample (now , Percentage . from_percent (10.0 )),
725725 ),
726726 # Final metric didn't change, so nothing should be received.
727727 Scenario (
@@ -734,17 +734,17 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
734734 Scenario (
735735 batteries_in_pool [1 ],
736736 {"capacity" : 0 },
737- Sample (now , Quantity (0.0 )),
737+ Sample (now , Percentage . from_percent (0.0 )),
738738 ),
739739 Scenario (
740740 batteries_in_pool [0 ],
741741 {"capacity" : 50 , "soc" : 55.0 },
742- Sample (now , Quantity (50.0 )),
742+ Sample (now , Percentage . from_percent (50.0 )),
743743 ),
744744 Scenario (
745745 batteries_in_pool [1 ],
746746 {"capacity" : 150 },
747- Sample (now , Quantity (25.0 )),
747+ Sample (now , Percentage . from_percent (25.0 )),
748748 ),
749749 ]
750750
@@ -757,15 +757,15 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
757757 all_batteries = all_batteries ,
758758 batteries_in_pool = batteries_in_pool ,
759759 waiting_time_sec = waiting_time_sec ,
760- all_pool_result = Sample (now , Quantity (25.0 )),
761- only_first_battery_result = Sample (now , Quantity (50.0 )),
760+ all_pool_result = Sample (now , Percentage . from_percent (25.0 )),
761+ only_first_battery_result = Sample (now , Percentage . from_percent (50.0 )),
762762 )
763763
764764 # One battery stopped sending data.
765765 await streamer .stop_streaming (batteries_in_pool [1 ])
766766 await asyncio .sleep (MAX_BATTERY_DATA_AGE_SEC + 0.2 )
767767 msg = await asyncio .wait_for (receiver .receive (), timeout = waiting_time_sec )
768- compare_messages (msg , Sample (now , Quantity (50.0 )), 0.2 )
768+ compare_messages (msg , Sample (now , Percentage . from_percent (50.0 )), 0.2 )
769769
770770 # All batteries stopped sending data.
771771 await streamer .stop_streaming (batteries_in_pool [0 ])
@@ -777,7 +777,7 @@ async def run_soc_test(setup_args: SetupArgs) -> None:
777777 latest_data = streamer .get_current_component_data (batteries_in_pool [0 ])
778778 streamer .start_streaming (latest_data , sampling_rate = 0.1 )
779779 msg = await asyncio .wait_for (receiver .receive (), timeout = waiting_time_sec )
780- compare_messages (msg , Sample (now , Quantity (50.0 )), 0.2 )
780+ compare_messages (msg , Sample (now , Percentage . from_percent (50.0 )), 0.2 )
781781
782782
783783async def run_power_bounds_test ( # pylint: disable=too-many-locals
0 commit comments