mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +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
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
HEADLIGHT_MODES: list = [
|
HEADLIGHT_MODES: list = [
|
||||||
HeadlightModes.ALWAYS_OFF.lower(),
|
HeadlightModes.ALWAYS_OFF,
|
||||||
HeadlightModes.ALWAYS_ON.lower(),
|
HeadlightModes.ALWAYS_ON,
|
||||||
HeadlightModes.EVENING_AND_NIGHT.lower(),
|
HeadlightModes.EVENING_AND_NIGHT,
|
||||||
HeadlightModes.EVENING_ONLY.lower(),
|
HeadlightModes.EVENING_ONLY,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -65,13 +65,11 @@ class AutomowerSelectEntity(AutomowerControlEntity, SelectEntity):
|
|||||||
@property
|
@property
|
||||||
def current_option(self) -> str:
|
def current_option(self) -> str:
|
||||||
"""Return the current option for the entity."""
|
"""Return the current option for the entity."""
|
||||||
return cast(
|
return cast(HeadlightModes, self.mower_attributes.settings.headlight.mode)
|
||||||
HeadlightModes, self.mower_attributes.settings.headlight.mode
|
|
||||||
).lower()
|
|
||||||
|
|
||||||
@handle_sending_exception()
|
@handle_sending_exception()
|
||||||
async def async_select_option(self, option: str) -> None:
|
async def async_select_option(self, option: str) -> None:
|
||||||
"""Change the selected option."""
|
"""Change the selected option."""
|
||||||
await self.coordinator.api.commands.set_headlight_mode(
|
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,
|
blocking=True,
|
||||||
)
|
)
|
||||||
mocked_method = mock_automower_client.commands.set_headlight_mode
|
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
|
assert len(mocked_method.mock_calls) == 1
|
||||||
|
|
||||||
mocked_method.side_effect = ApiError("Test error")
|
mocked_method.side_effect = ApiError("Test error")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user