Improve select platform in Husqvarna Automower (#144117)

This commit is contained in:
Thomas55555 2025-05-03 14:39:46 +02:00 committed by GitHub
parent db2435dc36
commit 64b7f2c285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 9 deletions

View File

@ -19,10 +19,10 @@ _LOGGER = logging.getLogger(__name__)
PARALLEL_UPDATES = 1
HEADLIGHT_MODES: list = [
HeadlightModes.ALWAYS_OFF.lower(),
HeadlightModes.ALWAYS_ON.lower(),
HeadlightModes.EVENING_AND_NIGHT.lower(),
HeadlightModes.EVENING_ONLY.lower(),
HeadlightModes.ALWAYS_OFF,
HeadlightModes.ALWAYS_ON,
HeadlightModes.EVENING_AND_NIGHT,
HeadlightModes.EVENING_ONLY,
]
@ -65,13 +65,11 @@ class AutomowerSelectEntity(AutomowerControlEntity, SelectEntity):
@property
def current_option(self) -> str:
"""Return the current option for the entity."""
return cast(
HeadlightModes, self.mower_attributes.settings.headlight.mode
).lower()
return cast(HeadlightModes, self.mower_attributes.settings.headlight.mode)
@handle_sending_exception()
async def async_select_option(self, option: str) -> None:
"""Change the selected option."""
await self.coordinator.api.commands.set_headlight_mode(
self.mower_id, cast(HeadlightModes, option.upper())
self.mower_id, HeadlightModes(option)
)

View File

@ -74,7 +74,7 @@ async def test_select_commands(
blocking=True,
)
mocked_method = mock_automower_client.commands.set_headlight_mode
mocked_method.assert_called_once_with(TEST_MOWER_ID, service.upper())
mocked_method.assert_called_once_with(TEST_MOWER_ID, service)
assert len(mocked_method.mock_calls) == 1
mocked_method.side_effect = ApiError("Test error")