Skip to content

Add preset mode to SmartThings climate #142180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion homeassistant/components/smartthings/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
"""Define a SmartThings Air Conditioner."""

_attr_name = None
_attr_preset_mode = None

def __init__(self, client: SmartThings, device: FullDevice) -> None:
"""Init the class."""
Expand Down Expand Up @@ -545,6 +544,18 @@ def swing_mode(self) -> str:
SWING_OFF,
)

@property
def preset_mode(self) -> str | None:
"""Return the preset mode."""
if self.supports_capability(Capability.CUSTOM_AIR_CONDITIONER_OPTIONAL_MODE):
mode = self.get_attribute_value(
Capability.CUSTOM_AIR_CONDITIONER_OPTIONAL_MODE,
Attribute.AC_OPTIONAL_MODE,
)
if mode == WINDFREE:
return WINDFREE
return None

def _determine_preset_modes(self) -> list[str] | None:
"""Return a list of available preset modes."""
if self.supports_capability(Capability.CUSTOM_AIR_CONDITIONER_OPTIONAL_MODE):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
"timestamp": "2024-09-10T10:26:28.781Z"
},
"acOptionalMode": {
"value": "off",
"value": "windFree",
"timestamp": "2025-02-09T09:14:39.642Z"
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/components/smartthings/snapshots/test_climate.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
]),
'max_temp': 35,
'min_temp': 7,
'preset_mode': None,
'preset_mode': 'windFree',
'preset_modes': list([
'windFree',
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@
'custom.airConditionerOptionalMode': dict({
'acOptionalMode': dict({
'timestamp': '2025-02-09T09:14:39.642Z',
'value': 'off',
'value': 'windFree',
}),
'supportedAcOptionalMode': dict({
'timestamp': '2024-09-10T10:26:28.781Z',
Expand Down
Loading