Skip to content

Commit 76f8e05

Browse files
committed
Guard climate_settings=None on the control path too
Addresses review feedback on #309: _create_climate_settings accessed self.vehicle.climate_settings.operations directly, which AttributeErrors when climate_settings itself is None (full climate-settings 500), crashing the entity on a set-temperature/defrost action. getattr through both.
1 parent 900b92e commit 76f8e05

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

custom_components/toyota/climate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ def _create_climate_settings(self) -> ClimateSettingsModel:
230230
Returns:
231231
ClimateSettingsModel configured with the specified settings
232232
"""
233-
# Start with existing operations (None when climate-settings 500'd)
234-
ac_operations = (self.vehicle.climate_settings.operations or []).copy()
233+
# Start with existing operations. climate_settings itself (not just
234+
# .operations) can be None when the climate-settings endpoint 500'd, so
235+
# getattr through both to avoid an AttributeError on the control path.
236+
climate_settings = getattr(self.vehicle, "climate_settings", None)
237+
ac_operations = (getattr(climate_settings, "operations", None) or []).copy()
235238

236239
# Find and replace the defrost operation
237240
for i, operation in enumerate(ac_operations):

0 commit comments

Comments
 (0)