mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Improve select platform in Husqvarna Automower (#144117)
This commit is contained in:
parent
db2435dc36
commit
64b7f2c285
@ -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)
|
||||
)
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user