From 9551e869cf4262099e9215c9a49837ada45477a6 Mon Sep 17 00:00:00 2001 From: Gregory Temwa Date: Tue, 30 Dec 2025 21:51:38 +0300 Subject: [PATCH 1/5] Refactor device property accessors to use properties instead of methods --- smart_control/simulator/air_handler_test.py | 4 ++-- smart_control/simulator/boiler_test.py | 16 ++++++++-------- smart_control/simulator/simulator.py | 4 ++-- smart_control/simulator/simulator_building.py | 8 ++++---- .../simulator/simulator_flexible_floor_plan.py | 4 ++-- .../simulator_flexible_floor_plan_test.py | 4 ++-- smart_control/simulator/simulator_test.py | 4 ++-- smart_control/simulator/smart_device.py | 8 ++++++++ smart_control/simulator/smart_device_test.py | 10 +++++----- smart_control/simulator/vav_test.py | 4 ++-- 10 files changed, 37 insertions(+), 29 deletions(-) diff --git a/smart_control/simulator/air_handler_test.py b/smart_control/simulator/air_handler_test.py index 7961574e..64500229 100644 --- a/smart_control/simulator/air_handler_test.py +++ b/smart_control/simulator/air_handler_test.py @@ -444,7 +444,7 @@ def test_observable_field_names(self): ) self.assertSameElements( - handler.observable_field_names(), + handler.observable_field_names, [ 'differential_pressure_setpoint', 'supply_air_flowrate_sensor', @@ -507,7 +507,7 @@ def test_action_field_names(self): self.fan_efficiency, ) self.assertSameElements( - handler.action_field_names(), + handler.action_field_names, [ 'supply_air_heating_temperature_setpoint', 'supply_air_cooling_temperature_setpoint', diff --git a/smart_control/simulator/boiler_test.py b/smart_control/simulator/boiler_test.py index 8b8e76f9..d48a1a0b 100644 --- a/smart_control/simulator/boiler_test.py +++ b/smart_control/simulator/boiler_test.py @@ -247,12 +247,12 @@ def test_observable_field_names(self): b = self.get_default_boiler() self.assertSameElements( - b.observable_field_names(), - [ - 'supply_water_setpoint', - 'supply_water_temperature_sensor', - 'heating_request_count', - ], + b.observable_field_names, + [ + 'supply_water_setpoint', + 'supply_water_temperature_sensor', + 'heating_request_count', + ], ) def test_observe_supply_water_setpoint(self): @@ -432,7 +432,7 @@ def test_compute_thermal_dissipation_rate_invalid(self): def test_action_field_names(self): b = self.get_default_boiler() - self.assertSameElements(b.action_field_names(), ['supply_water_setpoint']) + self.assertSameElements(b.action_field_names, ['supply_water_setpoint']) def test_action_supply_water_setpoint(self): b = self.get_default_boiler() @@ -456,7 +456,7 @@ def test_device_type(self): def test_device_id(self): b = self.get_default_boiler() - device_id = b.device_id() + device_id = b.device_id self.assertEqual(device_id, 'boiler_id') diff --git a/smart_control/simulator/simulator.py b/smart_control/simulator/simulator.py index 447d0f17..264c555e 100644 --- a/smart_control/simulator/simulator.py +++ b/smart_control/simulator/simulator.py @@ -795,7 +795,7 @@ def _get_air_handler_reward_infos( This data is used to compute the instantaneous reward. """ air_handler_reward_infos = {} - air_handler_id = self._hvac.air_handler.device_id() + air_handler_id = self._hvac.air_handler.device_id blower_electrical_energy_rate = ( self._hvac.air_handler.compute_intake_fan_energy_rate() + self._hvac.air_handler.compute_exhaust_fan_energy_rate() @@ -824,7 +824,7 @@ def _get_boiler_reward_infos( This data is used to compute the instantaneous reward. """ boiler_reward_infos = {} - boiler_id = self._hvac.boiler.device_id() + boiler_id = self._hvac.boiler.device_id return_water_temp = self._hvac.boiler.return_water_temperature_sensor natural_gas_heating_energy_rate = ( self._hvac.boiler.compute_thermal_energy_rate( diff --git a/smart_control/simulator/simulator_building.py b/smart_control/simulator/simulator_building.py index 62d9942e..28ecfa13 100644 --- a/smart_control/simulator/simulator_building.py +++ b/smart_control/simulator/simulator_building.py @@ -60,7 +60,7 @@ def __init__( (hvac.air_handler, self._create_device_info(hvac.air_handler)), ] all_devices.extend([ - (vav, self._create_device_info(vav, vav.zone_id())) + (vav, self._create_device_info(vav, vav.zone_id)) for vav in hvac.vavs.values() ]) @@ -96,11 +96,11 @@ def _create_device_info( device: SmartDevice to create info object for. zone_id: Zone Id of the device. """ - observable_fields = device.observable_field_names() - action_fields = device.action_field_names() + observable_fields = device.observable_field_names + action_fields = device.action_field_names device_info = smart_control_building_pb2.DeviceInfo() - device_info.device_id = device.device_id() + device_info.device_id = device.device_id device_info.namespace = f"device_namespace_{uuid.uuid4()}" device_info.code = f"device_code_{uuid.uuid4()}" device_info.zone_id = zone_id diff --git a/smart_control/simulator/simulator_flexible_floor_plan.py b/smart_control/simulator/simulator_flexible_floor_plan.py index 8a91a507..5e5f11c4 100644 --- a/smart_control/simulator/simulator_flexible_floor_plan.py +++ b/smart_control/simulator/simulator_flexible_floor_plan.py @@ -238,7 +238,7 @@ def _get_air_handler_reward_infos( This data is used to compute the instantaneous reward. """ air_handler_reward_infos = {} - air_handler_id = self._hvac.air_handler.device_id() + air_handler_id = self._hvac.air_handler.device_id blower_electrical_energy_rate = ( self._hvac.air_handler.compute_intake_fan_energy_rate() + self._hvac.air_handler.compute_exhaust_fan_energy_rate() @@ -267,7 +267,7 @@ def _get_boiler_reward_infos( This data is used to compute the instantaneous reward. """ boiler_reward_infos = {} - boiler_id = self._hvac.boiler.device_id() + boiler_id = self._hvac.boiler.device_id return_water_temp = self._hvac.boiler.return_water_temperature_sensor natural_gas_heating_energy_rate = ( self._hvac.boiler.compute_thermal_energy_rate( diff --git a/smart_control/simulator/simulator_flexible_floor_plan_test.py b/smart_control/simulator/simulator_flexible_floor_plan_test.py index 32970ab2..86b0b398 100644 --- a/smart_control/simulator/simulator_flexible_floor_plan_test.py +++ b/smart_control/simulator/simulator_flexible_floor_plan_test.py @@ -1505,7 +1505,7 @@ def test_reward_info(self): self.assertEqual(reward_info.zone_reward_infos, expected_zone_reward_infos) air_handler_reward_info = reward_info.air_handler_reward_infos[ - sim._hvac.air_handler.device_id() + sim._hvac.air_handler.device_id ] blower_electrical_energy_rate = ( @@ -1533,7 +1533,7 @@ def test_reward_info(self): ) boiler_reward_info = reward_info.boiler_reward_infos[ - sim._hvac.boiler.device_id() + sim._hvac.boiler.device_id ] natural_gas_heating_energy_rate = ( sim._hvac.boiler.compute_thermal_energy_rate( diff --git a/smart_control/simulator/simulator_test.py b/smart_control/simulator/simulator_test.py index cd9227c0..740743e9 100644 --- a/smart_control/simulator/simulator_test.py +++ b/smart_control/simulator/simulator_test.py @@ -1053,7 +1053,7 @@ def test_reward_info(self): self.assertEqual(reward_info.zone_reward_infos, expected_zone_reward_infos) air_handler_reward_info = reward_info.air_handler_reward_infos[ - sim._hvac.air_handler.device_id() + sim._hvac.air_handler.device_id ] blower_electrical_energy_rate = ( @@ -1081,7 +1081,7 @@ def test_reward_info(self): ) boiler_reward_info = reward_info.boiler_reward_infos[ - sim._hvac.boiler.device_id() + sim._hvac.boiler.device_id ] natural_gas_heating_energy_rate = ( sim._hvac.boiler.compute_thermal_energy_rate( diff --git a/smart_control/simulator/smart_device.py b/smart_control/simulator/smart_device.py index e5cabc29..189e7ea5 100644 --- a/smart_control/simulator/smart_device.py +++ b/smart_control/simulator/smart_device.py @@ -60,10 +60,14 @@ def __init__( self._action_timestamp = None self._observation_timestamp = None + + @property def device_id(self) -> str: """Returns device id.""" return self._device_id + + @property def zone_id(self) -> Optional[str]: """Returns zone_id.""" return self._zone_id @@ -72,10 +76,14 @@ def device_type(self) -> smart_control_building_pb2.DeviceInfo.DeviceType: """Returns device type.""" return self._device_type + + @property def observable_field_names(self) -> Sequence[str]: """Returns all observable field names.""" return self._observable_fields.keys() # pytype: disable=bad-return-type + + @property def action_field_names(self) -> Sequence[str]: """Returns all action field names.""" return self._action_fields.keys() # pytype: disable=bad-return-type diff --git a/smart_control/simulator/smart_device_test.py b/smart_control/simulator/smart_device_test.py index 3c7d85cc..65c19397 100644 --- a/smart_control/simulator/smart_device_test.py +++ b/smart_control/simulator/smart_device_test.py @@ -49,26 +49,26 @@ def __init__(self): def test_device_id(self): heater = self.heater_class() - self.assertEqual(heater.device_id(), 'heater_id') + self.assertEqual(heater.device_id, 'heater_id') def test_zone_id(self): heater = self.heater_class() - self.assertEqual(heater.zone_id(), 'zone_id') + self.assertEqual(heater.zone_id, 'zone_id') def test_observable_field_names(self): heater = self.heater_class() self.assertSameElements( - heater.observable_field_names(), - ['obs_temp', 'obs_heat_setting', 'obs_seconds_active', 'obs_bad'], + heater.observable_field_names, + ['obs_temp', 'obs_heat_setting', 'obs_seconds_active', 'obs_bad'], ) def test_action_field_names(self): heater = self.heater_class() self.assertSameElements( - heater.action_field_names(), ['act_heat_setting', 'act_bad'] + heater.action_field_names, ['act_heat_setting', 'act_bad'] ) def test_observable_type(self): diff --git a/smart_control/simulator/vav_test.py b/smart_control/simulator/vav_test.py index 2bd99773..9151f326 100644 --- a/smart_control/simulator/vav_test.py +++ b/smart_control/simulator/vav_test.py @@ -425,7 +425,7 @@ def test_observable_field_names(self): v = vav.Vav(max_air_flow_rate, reheat_max_water_flow_rate, t, b) self.assertSameElements( - v.observable_field_names(), + v.observable_field_names, [ 'supply_air_damper_percentage_command', 'supply_air_flowrate_setpoint', @@ -477,7 +477,7 @@ def test_action_field_names(self): v = vav.Vav(max_air_flow_rate, reheat_max_water_flow_rate, t, b) self.assertSameElements( - v.action_field_names(), ['supply_air_damper_percentage_command'] + v.action_field_names, ['supply_air_damper_percentage_command'] ) def test_action_supply_air_flowrate_setpoint(self): From 85226a86625931bb5fb1d97bac89f6ade2c1f1e0 Mon Sep 17 00:00:00 2001 From: Greg Date: Sat, 24 Jan 2026 05:35:07 +0300 Subject: [PATCH 2/5] Fix: Removed extra blank lines as requested. --- smart_control/simulator/smart_device.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/smart_control/simulator/smart_device.py b/smart_control/simulator/smart_device.py index 189e7ea5..e4044854 100644 --- a/smart_control/simulator/smart_device.py +++ b/smart_control/simulator/smart_device.py @@ -60,13 +60,10 @@ def __init__( self._action_timestamp = None self._observation_timestamp = None - @property def device_id(self) -> str: """Returns device id.""" return self._device_id - - @property def zone_id(self) -> Optional[str]: """Returns zone_id.""" @@ -76,13 +73,11 @@ def device_type(self) -> smart_control_building_pb2.DeviceInfo.DeviceType: """Returns device type.""" return self._device_type - @property def observable_field_names(self) -> Sequence[str]: """Returns all observable field names.""" return self._observable_fields.keys() # pytype: disable=bad-return-type - @property def action_field_names(self) -> Sequence[str]: """Returns all action field names.""" From e4aef2890aac3967949f89efc5a883fadc7a50cc Mon Sep 17 00:00:00 2001 From: Michael Rossetti Date: Mon, 26 Jan 2026 11:17:43 -0500 Subject: [PATCH 3/5] Restore indentation --- smart_control/simulator/vav_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smart_control/simulator/vav_test.py b/smart_control/simulator/vav_test.py index 9151f326..d527bb83 100644 --- a/smart_control/simulator/vav_test.py +++ b/smart_control/simulator/vav_test.py @@ -425,7 +425,7 @@ def test_observable_field_names(self): v = vav.Vav(max_air_flow_rate, reheat_max_water_flow_rate, t, b) self.assertSameElements( - v.observable_field_names, + v.observable_field_names, [ 'supply_air_damper_percentage_command', 'supply_air_flowrate_setpoint', @@ -477,7 +477,7 @@ def test_action_field_names(self): v = vav.Vav(max_air_flow_rate, reheat_max_water_flow_rate, t, b) self.assertSameElements( - v.action_field_names, ['supply_air_damper_percentage_command'] + v.action_field_names, ['supply_air_damper_percentage_command'] ) def test_action_supply_air_flowrate_setpoint(self): From e545a4122e077f099387c000a26fb9410035d1b7 Mon Sep 17 00:00:00 2001 From: Michael Rossetti Date: Mon, 26 Jan 2026 11:18:53 -0500 Subject: [PATCH 4/5] Restore indentation --- smart_control/simulator/boiler_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/smart_control/simulator/boiler_test.py b/smart_control/simulator/boiler_test.py index d48a1a0b..d2dfb5aa 100644 --- a/smart_control/simulator/boiler_test.py +++ b/smart_control/simulator/boiler_test.py @@ -247,12 +247,12 @@ def test_observable_field_names(self): b = self.get_default_boiler() self.assertSameElements( - b.observable_field_names, - [ - 'supply_water_setpoint', - 'supply_water_temperature_sensor', - 'heating_request_count', - ], + b.observable_field_names, + [ + 'supply_water_setpoint', + 'supply_water_temperature_sensor', + 'heating_request_count', + ], ) def test_observe_supply_water_setpoint(self): From d939508fffc2a0c23b9d5c2942f8f49dfb1697a0 Mon Sep 17 00:00:00 2001 From: Michael Rossetti Date: Mon, 26 Jan 2026 11:28:28 -0500 Subject: [PATCH 5/5] Restore blank line between methods --- smart_control/simulator/smart_device.py | 1 + 1 file changed, 1 insertion(+) diff --git a/smart_control/simulator/smart_device.py b/smart_control/simulator/smart_device.py index e4044854..1f76cd71 100644 --- a/smart_control/simulator/smart_device.py +++ b/smart_control/simulator/smart_device.py @@ -64,6 +64,7 @@ def __init__( def device_id(self) -> str: """Returns device id.""" return self._device_id + @property def zone_id(self) -> Optional[str]: """Returns zone_id."""