1 """Creates a select entity for the headlight of the mower."""
4 from typing
import cast
6 from aioautomower.model
import HeadlightModes
13 from .
import AutomowerConfigEntry
14 from .coordinator
import AutomowerDataUpdateCoordinator
15 from .entity
import AutomowerControlEntity, handle_sending_exception
17 _LOGGER = logging.getLogger(__name__)
21 HEADLIGHT_MODES: list = [
22 HeadlightModes.ALWAYS_OFF.lower(),
23 HeadlightModes.ALWAYS_ON.lower(),
24 HeadlightModes.EVENING_AND_NIGHT.lower(),
25 HeadlightModes.EVENING_ONLY.lower(),
31 entry: AutomowerConfigEntry,
32 async_add_entities: AddEntitiesCallback,
34 """Set up select platform."""
35 coordinator = entry.runtime_data
38 for mower_id
in coordinator.data
39 if coordinator.data[mower_id].capabilities.headlights
44 """Defining the headlight mode entity."""
46 _attr_options = HEADLIGHT_MODES
47 _attr_entity_category = EntityCategory.CONFIG
48 _attr_translation_key =
"headlight_mode"
53 coordinator: AutomowerDataUpdateCoordinator,
55 """Set up select platform."""
56 super().
__init__(mower_id, coordinator)
61 """Return the current option for the entity."""
63 HeadlightModes, self.
mower_attributesmower_attributes.settings.headlight.mode
66 @handle_sending_exception()
68 """Change the selected option."""
69 await self.coordinator.api.commands.set_headlight_mode(
70 self.
mower_idmower_id, cast(HeadlightModes, option.upper())
MowerAttributes mower_attributes(self)
None async_select_option(self, str option)
None __init__(self, str mower_id, AutomowerDataUpdateCoordinator coordinator)
None async_setup_entry(HomeAssistant hass, AutomowerConfigEntry entry, AddEntitiesCallback async_add_entities)